Test CI stability#2684
Conversation
420b49d to
0d838c1
Compare
Test Failure AnalysisSummary: CI is failing due to pre-existing resource task test failures, not the Uvicorn 0.39+ cleanup fixes in this PR. Root Cause: All tests in Suggested Solution:
To proceed with this PR: Either fix the resource task tests or temporarily skip them with Detailed AnalysisFailing Tests (Pre-existing on base branch)All 6 tests in mcp.shared.exceptions.McpError: 'document'The error originates from the MCP SDK when the server returns a JSON-RPC error response. The error message is just the string Tests Modified by This PR (All Passing)The PR correctly fixes test cleanup issues caused by Uvicorn 0.39.0's context isolation changes: For real Uvicorn servers (
For mocked servers (
Local Test Results$ uv run pytest tests/server/test_logging.py tests/client/test_streamable_http.py tests/client/test_sse.py -v
======================== 22 passed, 1 xfailed in 10.35s ========================All tests modified by this PR pass successfully on Linux. Related FilesModified by PR (all passing):
Failing (pre-existing issue):
|
(due to issues with the release/2.x branch, this had to be deleted and replaced with #2696)
Uvicorn 0.39.0 introduced a fix for ContextVars pollution (encode/uvicorn#2742) that wraps ASGI tasks in empty contexts. This is a workaround for a CPython bug (python/cpython#140947) being fixed in Python 3.13+.
The context isolation breaks task cancellation propagation, causing test cleanup to hang when we
task.cancel()andawait taskon uvicorn server tasks.Fix: Use graceful shutdown (
server.should_exit = True) for real uvicorn servers, and add timeouts for mocked server cleanup.Files changed:
tests/server/test_logging.py- Add timeout to mocked server cleanuptests/client/test_streamable_http.py- Use graceful shutdown for nested_server fixturetests/client/test_sse.py- Use graceful shutdown for nested_sse_server fixture