Skip to content

test(bigquerystorage): Fix flaky testMultiStreamClosed_multiplexingEnabled#13665

Merged
lqiu96 merged 4 commits into
mainfrom
fix-issue-13664-java
Jul 6, 2026
Merged

test(bigquerystorage): Fix flaky testMultiStreamClosed_multiplexingEnabled#13665
lqiu96 merged 4 commits into
mainfrom
fix-issue-13664-java

Conversation

@lqiu96

@lqiu96 lqiu96 commented Jul 6, 2026

Copy link
Copy Markdown
Member

Fixes: #13664

lqiu96 added 3 commits July 6, 2026 19:26
…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

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

Copy link
Copy Markdown
Contributor

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 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
lqiu96 marked this pull request as ready for review July 6, 2026 19:45
@lqiu96
lqiu96 requested review from a team as code owners July 6, 2026 19:45
@lqiu96
lqiu96 requested a review from jinseopkim0 July 6, 2026 19:45
@lqiu96
lqiu96 enabled auto-merge (squash) July 6, 2026 19:45
@lqiu96
lqiu96 merged commit c8d69cc into main Jul 6, 2026
211 of 212 checks passed
@lqiu96
lqiu96 deleted the fix-issue-13664-java branch July 6, 2026 20:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Flaky Bigquerystorage test: testMultiStreamClosed_multiplexingEnabled

2 participants