Skip to content

test: Fix flaky test TestServerStreaming_ClientCallSendMsgTwice in end2end_test.go.#9004

Merged
Pranjali-2501 merged 3 commits intogrpc:masterfrom
Pranjali-2501:issue-8993
Mar 25, 2026
Merged

test: Fix flaky test TestServerStreaming_ClientCallSendMsgTwice in end2end_test.go.#9004
Pranjali-2501 merged 3 commits intogrpc:masterfrom
Pranjali-2501:issue-8993

Conversation

@Pranjali-2501
Copy link
Copy Markdown
Contributor

@Pranjali-2501 Pranjali-2501 commented Mar 24, 2026

Fixes: #8993

This PR will fix the flaky test TestServerStreaming_ClientCallSendMsgTwice introduced in PR #8385 .

The test expected a single call to stream.SendMsg() to return a codes.Canceled error 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

@Pranjali-2501 Pranjali-2501 added this to the 1.81 Release milestone Mar 24, 2026
@Pranjali-2501 Pranjali-2501 added Area: Testing Includes tests and testing utilities that we have for unit and e2e tests within our repo. Type: Testing and removed Area: Testing Includes tests and testing utilities that we have for unit and e2e tests within our repo. labels Mar 24, 2026
@codecov
Copy link
Copy Markdown

codecov bot commented Mar 24, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 82.99%. Comparing base (ccc8d7b) to head (af59c6d).
⚠️ Report is 6 commits behind head on master.

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           

see 28 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@Pranjali-2501
Copy link
Copy Markdown
Contributor Author

/gemini review

Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@arjan-bal arjan-bal assigned Pranjali-2501 and unassigned arjan-bal Mar 24, 2026
Copy link
Copy Markdown
Contributor

@arjan-bal arjan-bal left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@arjan-bal arjan-bal assigned Pranjali-2501 and unassigned arjan-bal Mar 25, 2026
@arjan-bal arjan-bal changed the title Fix flaky test TestServerStreaming_ClientCallSendMsgTwice in end2end_test.go. test: Fix flaky test TestServerStreaming_ClientCallSendMsgTwice in end2end_test.go. Mar 25, 2026
@Pranjali-2501 Pranjali-2501 merged commit 6477252 into grpc:master Mar 25, 2026
15 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Flaky test: TestServerStreaming_ClientCallSendMsgTwice

4 participants