test: Fix flaky test TestServerStreaming_ClientCallSendMsgTwice in end2end_test.go.#9004
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #9004 +/- ##
=======================================
Coverage 82.99% 82.99%
=======================================
Files 411 411
Lines 32917 32929 +12
=======================================
+ Hits 27319 27330 +11
- Misses 4196 4197 +1
Partials 1402 1402 🚀 New features to boost your workflow:
|
|
/gemini review |
There was a problem hiding this comment.
Code Review
This pull request modifies the TestServerStreaming_ClientCallSendMsgTwice end-to-end test. The change introduces a polling mechanism to repeatedly call stream.SendMsg until an error is returned or a timeout occurs, ensuring the test correctly waits for the stream's context to be canceled and a codes.Canceled error. The review suggests simplifying the polling logic for better readability by checking context cancellation directly in the loop condition and defining the 10 * time.Millisecond sleep duration as a named constant to improve clarity and maintainability.
TestServerStreaming_ClientCallSendMsgTwice in end2end_test.go.TestServerStreaming_ClientCallSendMsgTwice in end2end_test.go.
Fixes: #8993
This PR will fix the flaky test
TestServerStreaming_ClientCallSendMsgTwiceintroduced in PR #8385 .The test expected a single call to
stream.SendMsg()to return acodes.Cancelederror immediately after the stream's context was marked as done.Solution: Introduced a retry loop with a timeout for the
stream.SendMsg()call. Instead of testing a single invocation, the server handler now continuously attempts to send a message until it either receives an error or timeout expired.Successfully run the test on forge for 1 million times without any flake.
RELEASE NOTES: N/A