Repository navigation
test(bindings): remove cancellation test timing races - #14974
Conversation
Signed-off-by: jthomson04 <jwillthomson19@gmail.com>
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Enterprise Run ID: 📒 Files selected for processing (1)
Included review availability: Your plan provides up to 12 included reviews per hour; 11 remain after this review. WalkthroughChangesThe cancellation tests now coordinate through an Cancellation test synchronization
Priority: ⬇️ Low Estimated code review effort: 2 (Simple) | ~10 minutes Merge Risk: ⚪ Minimal · up to No actionable merge-blocking risk remains for this cancellation-test synchronization change. 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
Comment |
jthomson04
left a comment
There was a problem hiding this comment.
Automated review of the diff, traced into lib/bindings/python/rust/ to confirm which stream terminations are actually reachable. Eight inline comments above; one finding has no anchorable diff line:
server fixture still synchronizes startup with a fixed sleep (line 180)
await asyncio.sleep(0.5) in the server fixture is the same anti-pattern this PR removes from the tests, and it is both unsound and wasted. On a loaded CI runner serve_endpoint may not have registered within 500 ms -- the fixture yields anyway, and the tests only survive because client.wait_for_instances() (line 199) does the real blocking. On a fast machine it is pure dead time: 0.5 s x 7 tests x 2 transports is ~7 s per run of a module marked unit + pre_merge. Since wait_for_instances() already establishes the invariant, the sleep can simply be deleted.
The two highest-value changes, in my view: keep a bounded response-count assertion instead of pass (line 360), and apply the same context_cancelled fix to the two tests at lines 229 and 263 that carry the identical race.
🤖 Generated with Claude Code
Signed-off-by: jthomson04 <jwillthomson19@gmail.com>
|
Updated in For the remaining review-level suggestions:
Each inline thread has a separate disposition. The handler event omission is fixed, while its proposed handler refactor remains deferred. |
Summary
An already-cancelled request can return a response before its stop signal reaches the worker. The cancellation tests assume that the stop always arrives first, so they can fail under scheduling delays. In this CI failure, the stop reached the worker after 140 ms, while the mock handler waits only 100 ms before its first response.
Use an explicit server cancellation event in all four affected tests. The two pre-cancelled request tests consume early responses and wait for stream termination plus server acknowledgement under one five-second deadline. They accept only the exact expected terminal cancellation error; request errors and other stream errors still propagate. The two mid-stream cancellation tests replace their 200 ms sleeps with bounded event waits, including the metadata case.
Preserve the tests' cancellation order and existing response, metadata, and stopped/not-killed assertions. Add a 30-second module timeout to bound fixture setup and teardown, and remove the redundant event reset. Runtime behavior is unchanged.
Validation
git diff --checkpassed.Tests ran outside the sandbox with an existing local
ai-dynamo-runtime1.5.0 wheel built from99224822bdbbd45a520d2ec1a4c9e38ca967e8e7with unrelated AISimulate changes. The relevant runtime cancellation and TCP code matches the inspected source.Related Issues
Summary by CodeRabbit