Fix flaky MCP adapter activity snapshot tests#9982
Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR addresses flakiness in MCP adapter activity snapshot tests by removing nondeterministic top-level ASP.NET Core HttpRequestIn spans from captured activity roots prior to snapshotting, aligning the behavior across Diagnostics and Fusion test suites.
Changes:
- Updated
McpAdapterActivityTestssnapshot helper to strip top-levelMicrosoft.AspNetCore.Hosting.HttpRequestInroot spans before snapshotting. - Clarified/expanded the rationale comments in both helpers and added reciprocal “keep in sync” notes.
- Regenerated affected snapshots (including NET11_0 variants) after removing the transport root span.
Reviewed changes
Copilot reviewed 12 out of 12 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| src/HotChocolate/Fusion/test/Fusion.Diagnostics.Tests/FusionMcpAdapterActivityTests.cs | Expanded explanation of why top-level transport HttpRequestIn spans are dropped and added a keep-in-sync reference. |
| src/HotChocolate/Diagnostics/test/Diagnostics.Tests/McpAdapterActivityTests.cs | Implemented pre-snapshot filtering to remove top-level HttpRequestIn roots; retained session-id scrubbing. |
| src/HotChocolate/Diagnostics/test/Diagnostics.Tests/snapshots/McpAdapterActivityTests.Mcp_GetPrompt.snap | Updated snapshot output after dropping the transport root span. |
| src/HotChocolate/Diagnostics/test/Diagnostics.Tests/snapshots/McpAdapterActivityTests.Mcp_GetPrompt_NET11_0.snap | Updated NET11_0 snapshot output after dropping the transport root span. |
| src/HotChocolate/Diagnostics/test/Diagnostics.Tests/snapshots/McpAdapterActivityTests.Mcp_CallTool.snap | Updated snapshot output after dropping the transport root span. |
| src/HotChocolate/Diagnostics/test/Diagnostics.Tests/snapshots/McpAdapterActivityTests.Mcp_CallTool_NET11_0.snap | Updated NET11_0 snapshot output after dropping the transport root span. |
| src/HotChocolate/Diagnostics/test/Diagnostics.Tests/snapshots/McpAdapterActivityTests.Mcp_CallTool_Tool_Does_Not_Exist.snap | Updated snapshot output after dropping the transport root span. |
| src/HotChocolate/Diagnostics/test/Diagnostics.Tests/snapshots/McpAdapterActivityTests.Mcp_CallTool_Tool_Does_Not_Exist_NET11_0.snap | Updated NET11_0 snapshot output after dropping the transport root span. |
| src/HotChocolate/Diagnostics/test/Diagnostics.Tests/snapshots/McpAdapterActivityTests.Mcp_CallTool_GraphQL_Field_Error.snap | Updated snapshot output after dropping the transport root span. |
| src/HotChocolate/Diagnostics/test/Diagnostics.Tests/snapshots/McpAdapterActivityTests.Mcp_CallTool_GraphQL_Field_Error_NET11_0.snap | Updated NET11_0 snapshot output after dropping the transport root span. |
| src/HotChocolate/Diagnostics/test/Diagnostics.Tests/snapshots/McpAdapterActivityTests.Mcp_CallTool_Field_Does_Not_Exist.snap | Updated snapshot output after dropping the transport root span. |
| src/HotChocolate/Diagnostics/test/Diagnostics.Tests/snapshots/McpAdapterActivityTests.Mcp_CallTool_Field_Does_Not_Exist_NET11_0.snap | Updated NET11_0 snapshot output after dropping the transport root span. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
McpAdapterActivityTestscaptured the ASP.NET CoreHttpRequestInserver span for the MCP streamable-HTTP transport request, whose terminal status is nondeterministic relative to the capture window, making the activity snapshots flaky.MatchActivitySnapshotnow strips top-levelHttpRequestInroots before snapshotting, mirroringFusionMcpAdapterActivityTests; both helpers carry reciprocal keep-in-sync comments.Test plan
McpAdapterActivityTestsgreen on net10.0 and net11.0.