Skip to content

test: harden the client-hosted MCP tests - #955

Merged
Blind-Striker merged 2 commits into
masterfrom
fix/938-client-mcp-test-hardening
Nov 17, 2026
Merged

Blind-Striker merged 2 commits into
masterfrom
fix/938-client-mcp-test-hardening

Conversation

@Blind-Striker

Copy link
Copy Markdown
Collaborator

📝 Description

What does this PR do?

It works through the client-hosted MCP test follow-ups from the reviews of #529. It is tests only: no production code changes.

  • Shared helper: the loopback listener that both the client-MCP and the terminal tests use moves to the test project's root Support/ as LoopbackUpgradeListener, per testing-style.md §1. Its own tests move with it.
  • Clearer failures: a collapsed boolean becomes IsEqualTo(caller.Token). Three tests are renamed to say what they check. A check repeated identically in four parameterized rows becomes one test of its own.
  • Assertions that could not fail are removed: the scripted socket's own close status and description, an application-owned task's IsCompleted, two IsCompleted checks on always-completed dispatch tasks, and a WhenAll on them.
  • Two connection tests that could hang now fail at an assertion. They race the listener's admission against a retry signal from the public WebSocketFactory. A regression that fails the upgrade before the request now fails at the oracle instead of waiting for the runner's timeout. No production seam was added.
  • Dispatch order proofs:
    • The order proof holds the dispatcher's lock through the Lock type's own Enter()/Exit(), so .NET Framework no longer depends on the downlevel lock being built on Monitor.
    • The ping-after-unreadable-method test now dispatches back to back, so it sees reply order.
    • Awaits on product completions are bounded with HangGuard.Bound.

Related Issue(s):

🔄 Type of Change

  • 🧪 Test improvements

🎯 Protocol & API Surface

  • No public API change
  • No generated output changed
  • The pinned snapshot (spec/) is untouched
  • Nothing under external/ was hand-edited

🧪 Testing

Mutation proofs, through a bounded runner that restores the source byte for byte. Each mutant is killed at its oracle on net10.0, net11.0 and net472:

Mutant Killed by
The upgrade fails before it sends a request both admission tests (Expected to be the same reference)
The whole response is deferred off the read loop again the back-to-back ping test (collection has 0 items but expected 2)

Items of #938 settled without a code change:

  • The private-field reflection in ClientMcpDispatchTests stays. It backs the check that completed responses leave the dispatcher's outstanding list, so that list stays bounded. No existing surface can observe that removal, and adding one would be production surface for tests only. A rename fails loudly at run time: GetField returns null and the dereference throws. A one-line comment at the read says so.
  • The null handler task message is not changed. A test cannot arrange a null handler task without a new analyzer exception: VSTHRD114 and MA0022 reject a literal null, and VSTHRD003 rejects one supplied from outside. The same analyzers and nullable annotations keep callers from writing one, and today's outcome is still an isError text answer, not a crash.
  • HttpListener ErrorCode 32 (a port held by a plain TCP socket) gets its own fix only if it shows up in CI, as the issue says.

✅ Completion Gate

  • The local check in quality-gates.md passes on the head rebased onto master: whitespace, format/style, clones, slopwatch, the release build, all test projects, the API snapshots, generate --verify, the fixed point, Extensions and Native AOT.

✅ Code Quality Checklist

  • No new analyzer warnings, and no new suppressions
  • No tests skipped or weakened. Only assertions that could not fail were deleted, and every existing expected result is unchanged.
  • Branch is up to date with the target branch, no merge conflicts
  • Commit messages carry no AI-attribution trailers

🔍 Additional Notes

Breaking Changes: none. Dependencies: none. CHANGELOG: none; tests only.

@Blind-Striker Blind-Striker added this to the Next milestone Nov 17, 2026
@Blind-Striker
Blind-Striker added this pull request to the merge queue Nov 17, 2026
Merged via the queue into master with commit 52932df Nov 17, 2026
15 checks passed
@Blind-Striker
Blind-Striker deleted the fix/938-client-mcp-test-hardening branch November 17, 2026 14:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Client-hosted MCP tests: helper placement, a collapsed boolean, names and two weak assertions

1 participant