Skip to content

Fix flaky MCP adapter activity snapshot tests#9982

Merged
glen-84 merged 2 commits into
mainfrom
gai/mcp-activity-snapshot-transport-strip
Jun 24, 2026
Merged

Fix flaky MCP adapter activity snapshot tests#9982
glen-84 merged 2 commits into
mainfrom
gai/mcp-activity-snapshot-transport-strip

Conversation

@glen-84

@glen-84 glen-84 commented Jun 24, 2026

Copy link
Copy Markdown
Member

Summary

  • McpAdapterActivityTests captured the ASP.NET Core HttpRequestIn server span for the MCP streamable-HTTP transport request, whose terminal status is nondeterministic relative to the capture window, making the activity snapshots flaky.
  • MatchActivitySnapshot now strips top-level HttpRequestIn roots before snapshotting, mirroring FusionMcpAdapterActivityTests; both helpers carry reciprocal keep-in-sync comments.
  • Regenerated the affected MCP snapshots across both target-framework variants.

Test plan

  • McpAdapterActivityTests green on net10.0 and net11.0.
  • Looped the class 50× on net11.0 with no failures.

Copilot AI review requested due to automatic review settings June 24, 2026 13:53

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 McpAdapterActivityTests snapshot helper to strip top-level Microsoft.AspNetCore.Hosting.HttpRequestIn root 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.

@glen-84 glen-84 merged commit da055ad into main Jun 24, 2026
141 checks passed
@glen-84 glen-84 deleted the gai/mcp-activity-snapshot-transport-strip branch June 24, 2026 15:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants