test: Fix flaky test_lifecycle_on_platform_without_websocket - #1121
Open
vdusek wants to merge 1 commit into
Open
test: Fix flaky test_lifecycle_on_platform_without_websocket#1121vdusek wants to merge 1 commit into
test_lifecycle_on_platform_without_websocket#1121vdusek wants to merge 1 commit into
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #1121 +/- ##
==========================================
+ Coverage 92.75% 92.78% +0.02%
==========================================
Files 53 53
Lines 3519 3519
==========================================
+ Hits 3264 3265 +1
+ Misses 255 254 -1
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
vdusek
marked this pull request as ready for review
September 7, 2026 13:09
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.
test_lifecycle_on_platform_without_websocketpointed the events WebSocket URL at a hard-codedws://localhost:56565and asserted that the connection is refused. That port sits inside the OS ephemeral range (32768-60999 on Linux, 49152-65535 on Windows), so anybind(host, 0)elsewhere in the parallel suite can be handed exactly that port, and this test file alone starts three such servers. When a sibling xdist worker got 56565, the connection succeeded and the test failed withDID NOT RAISE RuntimeError, as in this Windows run. Attempt 2 of the same run passed on the same commit.The test now reserves a port instead of guessing one. A new
_unreachable_ws_urlhelper binds('127.0.0.1', 0)and holds the socket open without callinglisten(). Holding it keeps the OS from handing the port to anyone else, and a bound socket that never listens refuses every connect withECONNREFUSED, which is theOSErrorthe test asserts as the cause. The assertions themselves are unchanged.Running a real WebSocket server on
127.0.0.1:56565reproduces the CI failure exactly, which gives a before/after: 20/20 runs failed before the fix, 0/100 after. The fixed test also survived 0/25 whole-file runs under--numprocesses=autowith that port occupied, and 0/60 runs with a background process holding ~400 rotating ephemeral listeners.✍️ Drafted by Claude Code