Repository navigation
test(ui,mcp): count scanner work and pin ping deadlines instead of timing them - #5409
Conversation
…ming them Two tests failed whenever the CI runner was busy, turning unrelated PRs red. - The envelope "not quadratic" test timed 100k streaming calls against a 5 s wall clock. It now counts the characters the envelope scanner examines (exactly one pass: 400089 for a 400089-char envelope); a per-token rescan would be ~2e10 and fails the bound. - The ping-deadline test needed the stub's ping to land in a 0.5 s window that the stub's own Python start-up ate into. The stub is now warmed with a first request, and the test asserts the ping reply is written with the request's own deadline rather than inferring it from elapsed time.
|
Verdict: Approve This PR fixes two unit tests that went red on busy CI runners. Both were checking timing, and now they check the behaviour directly. The envelope test counts how many characters the scanner reads instead of racing a 5 s clock. The ping test checks that the ping reply gets the request's own deadline, and it warms the stub up first so start-up time no longer eats into the window. Both new assertions still fail when the product bug they guard against comes back, so the tests lose no protection. There are no blocking issues. Real-world evidenceN/A: this PR only changes tests, with no CLI, API, MCP or UI change. The verdict rests on static review plus the author's stress-run numbers in the test plan. 🔍 Technical detailsChecked against the source
Issues found None blocking. 🟢 One optional point: the ping test no longer measures elapsed time at all, so a Strengths
|
Two unit tests failed whenever a CI runner was busy, so unrelated PRs went red (the envelope test on #5282 and #5337; the ping test timed out on loaded machines). Before: the envelope "not quadratic" test raced a 5 s wall clock, and the ping test needed a ping to land in a 0.5 s window that the stub's own start-up ate into. After: both assert what they claim directly, so they pass or fail the same way on any machine. Under a 40-process CPU burn they went from 16/16 and 10/16 failing to 0 of 120. The third test from the report,
test_turn_waiting_on_the_user_lets_other_chats_run, was already fixed on main by #5396. Both of its CI failures predate that fix, and it passed 325/325 under the same burn.🔍 Technical details
_json_object_endexamines. A 400,089-char envelope scans exactly 400,089 characters. A per-token rescan scans ~2e10 and fails the≤ 2×lenbound; I checked this on a 20 KB envelope, where a rescan was 2,500× over._writeand asserts the ping reply gets the same deadline as the request. If the product gives the ping reply a freshself.timeout, the test fails deterministically.self._stream_buffer += chunkcopying the held buffer per token. That is microseconds per token at real generation rates.test_stdio_hung_server.pyalso fail under heavy load.test_redaction_stays_fast_on_dense_escapesand..._linear_on_long_non_ascii_secretsuse a< 0.25 swall-clock assert.test_a_server_that_misses_the_connect_deadline_is_stoppedandtest_a_timed_out_request_is_cancelled_on_the_serverread marker files before the stub writes them.Test plan
pytest -p no:randomly --count 60 -n 8on both fixed tests: 120/120 idle, 120/120 under a 40-process CPU burn (before: 16/16 and 10/16 failing under the same burn)test_sse_handler.py,test_stdio_hung_server.py,test_turn_slot_reliability.pyin full: 521 passedpython util/lint.py --black --isort