Repository navigation
test(mcp): stop the discovery walk test failing on a worker stall - #44000
Closed
pylaterreur wants to merge 1 commit into
Closed
pylaterreur wants to merge 1 commit into
pylaterreur wants to merge 1 commit into
Conversation
test_optional_discovery_rejects_incomplete_walks gives every case a 0.2 s client timeout, which the client uses as the HTTP timeout and as the deadline for the whole page walk. Since 6997223, mcp-integration on main has failed 5 of 20 runs on cases that do not test the deadline at all, internal_error and method_not_found on resources/templates/list. The failed case took 0.56 to 0.97 s instead of the usual 0.04 s, and the four failures that reached the request count show that no page request got to the mock server, so the worker had stalled for longer than the whole budget. The shard runs without reruns, so one stall fails the job Give the deadline case 2 s and every other case 30 s, the same split test_cancellation_delivers_termination_over_tcp already uses. Blocking the event loop for 0.5 s at the first page request reproduces the CI errors for all 42 cases on main, and all 42 pass with this change, with a 1 s stall too. The six deadline cases now wait 2 s each, so the file takes about 11 s longer
Contributor
|
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
Author
|
Closing as superseded by #44007, which fixed the same flaky test with a manual-clock event loop |
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.
TLDR
Problem this solves:
How it solves it:
The failing test is
test_optional_discovery_rejects_incomplete_walks, and the failing cases wereinternal_errorandmethod_not_foundonresources/templates/list. They don't test the deadline, yet the client turns its 0.2 s timeout into the deadline for the whole page walk. In the five failures the case took 0.56 to 0.97 s instead of the usual 0.04 s, and in the four that got as far as counting requests, no page request had reached the mock server, so the walk ran out of time before its first page. The shard runs withreruns: 0, so one stall turns the job redUser Flow
Before: a contributor's pull request goes red on an MCP test their change never touched
mcp-integrationshardtest_optional_discovery_rejects_incomplete_walks[False-internal_error-resources/templates/list]fails withassert 0 == 2After: the same pull request gets a green
mcp-integrationcheckmcp-integrationshardtest_optional_discovery_rejects_incomplete_walkscases passPre-Submission checklist
Please complete all items before asking a LiteLLM maintainer to review your PR
uv run pytest tests/unit/<your_test_file>.py -v. Leave the suites (make test-unit-*,make test-unit) to CI: it finishes in ~15 minutes where a laptop takes an hour or more@greptileaito re-request a review after pushing changes)No new tests, since this only changes the timeout one existing test passes to its client.
tests/unit/experimental_mcp_client/passes locally, 428 tests, and every assertion in the changed test is untouchedDelays in PR merge?
If you're seeing a delay in your PR being merged, ping the LiteLLM Team on Slack (#pr-review).
Screenshots / Proof of Fix
Tests-only PR, so there is no request to curl. Product code is the same in Before and After. The CI failures this reproduces are on main at 0980f756bd, 6d7d183a80, ef6aa4ad66, 0c515ed7a8 and 6997223068
The stall comes from this local pytest plugin, saved at the repository root and not part of the PR. It blocks the event loop once per test, the first time the test asks for a page of prompts, resources or resource templates, the way the CI worker stalled
stall_first_list_page.py
Before (0980f75)
0.5 s stall
STALL_SECONDS=0.5 PYTHONPATH=. uv run pytest -p stall_first_list_page tests/unit/experimental_mcp_client/test_mcp_client.py -k test_optional_discovery_rejects_incomplete_walks[False-internal_error-resources/templates/list]fails withassert 0 == 2and logsMCP client list_resource_templates failed - Error Type: TimeoutError, the same as CI[True-method_not_found-resources/templates/list]fails withTimeoutErrorraised byanyio.fail_afterafteranyio.WouldBlock, the same as the ef6aa4a failureNo stall
uv run pytest tests/unit/experimental_mcp_client/test_mcp_client.py -k test_optional_discovery_rejects_incomplete_walksAfter (7966a35)
0.5 s stall
STALL_SECONDS=0.5 PYTHONPATH=. uv run pytest -p stall_first_list_page tests/unit/experimental_mcp_client/test_mcp_client.py -k test_optional_discovery_rejects_incomplete_walksSTALL_SECONDS=1.0, 42 passedNo stall
uv run pytest tests/unit/experimental_mcp_client/test_mcp_client.py -k test_optional_discovery_rejects_incomplete_walksType
Test
Caveats (if any)
Low
Final Attestation