test(bigquerystorage): Fix flaky testMultiStreamClosed_multiplexingEnabled#13665
Merged
Conversation
…ut sleeping The test `testMultiStreamClosed_multiplexingEnabled` was flaky because it relied on requests not finishing during the scaling phase. The mock server had a fixed response delay, which could be shorter than the time it took to complete the request submission loop on slow machines, causing requests to finish early and preventing the pool from scaling up. Instead of relying on timing and sleeps, this change introduces a `CountDownLatch` to synchronize the mock server responses. A new helper `BlockingResponseSupplier` blocks the mock server responses until the test thread has finished sending all requests. This guarantees that all requests remain in-flight during the scaling phase, making the test 100% stable and faster. Fixes #13664 TAG=agy CONV=76d8911b-bc84-4f0a-8a39-dceadbb18cf7
…orkerPoolTest Refactor the flaky test fix to use a lambda expression for the mock server response supplier, removing the need for the helper class BlockingResponseSupplier. TAG=agy CONV=76d8911b-bc84-4f0a-8a39-dceadbb18cf7
…ctionWorkerPoolTest Add a comment explaining the purpose of using CountDownLatch in testMultiStreamClosed_multiplexingEnabled. TAG=agy CONV=76d8911b-bc84-4f0a-8a39-dceadbb18cf7
Contributor
There was a problem hiding this comment.
Code Review
This pull request updates ConnectionWorkerPoolTest.java to use a CountDownLatch to block mock server responses, ensuring all requests remain in-flight simultaneously to force connection scaling. However, if the assertions fail before the latch is released, the mock server threads will block indefinitely. It is recommended to wrap the assertions in a try-finally block to guarantee that latch.countDown() is always executed.
…tch release Wrap connection count assertions in a try-finally block to ensure that latch.countDown() is always called, preventing mock server threads from blocking indefinitely if the assertions fail. TAG=agy CONV=76d8911b-bc84-4f0a-8a39-dceadbb18cf7
lqiu96
marked this pull request as ready for review
July 6, 2026 19:45
lqiu96
enabled auto-merge (squash)
July 6, 2026 19:45
jinseopkim0
approved these changes
Jul 6, 2026
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.
Fixes: #13664