-
-
Notifications
You must be signed in to change notification settings - Fork 313
fix: Fixes assert issue in websocket integration tests #1261
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
WalkthroughThe WebSocket integration test was changed to use order-independent, set-based assertions for verifying three response messages (replacing three sequential recv checks in two places) and added an assertion that the server reports "Connection closed" after the final test command. Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~8 minutes
Poem
Pre-merge checks and finishing touches❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing touches
🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
🧹 Nitpick comments (1)
integration_tests/test_web_sockets.py (1)
21-21: Excellent - this directly fixes the "Slim Shady" error from issue #1188.The set-based assertion here mirrors the fix on line 15 and specifically addresses the intermittent failure mentioned in the linked issue. The test will now pass regardless of the order in which these three messages arrive.
Optional improvement for debugging: Consider adding a comment explaining why set-based comparison is used, or using
sorted()instead ofset()for clearer assertion failure messages:- assert set([ws.recv() for _ in range(3)]) == set(["hi", "hello", "*chika* *chika* Slim Shady."]) + # Messages may arrive in any order due to WebSocket broadcast behavior + received = sorted([ws.recv() for _ in range(3)]) + expected = sorted(["hi", "hello", "*chika* *chika* Slim Shady."]) + assert received == expectedThis produces more readable diffs when assertions fail, showing the sorted lists instead of set representations.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
integration_tests/test_web_sockets.py(1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (20)
- GitHub Check: ubuntu tests with python 3.12
- GitHub Check: ubuntu tests with python 3.13
- GitHub Check: ubuntu tests with python 3.9
- GitHub Check: ubuntu tests with python 3.10
- GitHub Check: ubuntu tests with python 3.11
- GitHub Check: windows tests with python 3.9
- GitHub Check: windows tests with python 3.13
- GitHub Check: windows tests with python 3.12
- GitHub Check: lint
- GitHub Check: linux (3.12, x86_64)
- GitHub Check: linux (3.11, i686)
- GitHub Check: macos (3.11)
- GitHub Check: windows (3.9, x64)
- GitHub Check: linux (3.11, x86_64)
- GitHub Check: macos (3.10)
- GitHub Check: macos (3.12)
- GitHub Check: linux (3.9, i686)
- GitHub Check: linux (3.9, x86_64)
- GitHub Check: linux (3.10, x86_64)
- GitHub Check: benchmarks
🔇 Additional comments (1)
integration_tests/test_web_sockets.py (1)
15-15: Good fix for the race condition!The set-based comparison correctly addresses the intermittent test failure by removing the assumption of message ordering. This allows the three WebSocket responses to arrive in any order while still validating that all expected messages are received.
CodSpeed Performance ReportMerging #1261 will not alter performanceComparing Summary
Footnotes |
* This fixes, assert error occurred randomly in websocket test, due to getting data not in same order as sent from server
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ready to be merged
sansyrox
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Love it. Good job @thePromger
|
Do merge it bro |
Description
In the WebSocket test, an intermittent assertion error occurs when the received data order does not match the order in which messages were sent by the server.
This issue appears mostly in CI environments due to timing or concurrency differences.
Summary
PR Checklist
Please ensure that:
Pre-Commit Instructions:
Summary by CodeRabbit