Commit cb4760d
committed
Run transport security tests in process instead of over sockets
The SSE and StreamableHTTP security tests each spawned a uvicorn
subprocess on a port picked by bind-then-close, then polled until the
port accepted connections. Under pytest-xdist two workers can pick the
same port in that window: the second server fails to bind, the
readiness poll succeeds against the other worker's server, and the test
asserts against a server configured with different security settings
(e.g. 421 for a host the test explicitly allowed).
Rewrite both files to drive the same Starlette apps in process through
the interaction suite's StreamingASGITransport (re-exported from
tests.interaction.transports as the sanctioned import point): no
sockets, no subprocesses, no ports to race over. Assertions are
unchanged. The new in-process GET test covers the validation-failure
return in _handle_get_request; the pragma on that line was already
stale (the success path has been driven in process by the interaction
suite since it merged) and is removed.
Also deflake test_idle_session_is_reaped, which slept 0.1s after a
0.05s idle timeout and failed on slow runners when the reaper had not
fired yet. Re-requesting the session to poll for the 404 would push its
idle deadline forward, so instead wait on the manager's "idle timeout"
log record, which is emitted synchronously with the session being
unregistered.1 parent a938126 commit cb4760d
5 files changed
Lines changed: 212 additions & 454 deletions
File tree
- src/mcp/server
- tests
- interaction/transports
- server
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
669 | 669 | | |
670 | 670 | | |
671 | 671 | | |
672 | | - | |
| 672 | + | |
673 | 673 | | |
674 | 674 | | |
675 | 675 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
0 commit comments