Skip to content

test(gax): use FakeApiClock in DirectRetryingExecutorTest to avoid Thread.sleep - #14705

Merged
lqiu96 merged 4 commits into
googleapis:mainfrom
lqiu96:fix/gax-direct-retrying-executor-fake-clock-14625
Oct 22, 2026
Merged

lqiu96 merged 4 commits into
googleapis:mainfrom
lqiu96:fix/gax-direct-retrying-executor-fake-clock-14625

Conversation

@lqiu96

@lqiu96 lqiu96 commented Oct 20, 2026 •

Copy link
Copy Markdown
Member

Use FakeApiClock and RecordingScheduler in ScheduledRetryingExecutorTest so non-concurrent retry tests execute deterministically without sleeping. Isolate asynchronous polling and cancellation tests to use per-iteration local ScheduledExecutorService instances and NanoClock. Make RecordingScheduler stubbings lenient to avoid UnnecessaryStubbingException when recorded metrics are not queried.

Fixes #13535

…read.sleep

Replace CurrentMillisClock and real Thread.sleep delays in
DirectRetryingExecutorTest with FakeApiClock and a sleep() override
that advances virtual time deterministically. This prevents
testMaxRetriesExceeded from flaking with premature totalTimeout
expiration on slow CI runners.

Fixes googleapis#14625
@lqiu96
lqiu96 requested a review from jinseopkim0 October 20, 2026 19:34

@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 refactors AbstractRetryingExecutorTest and DirectRetryingExecutorTest to use a deterministic FakeApiClock and simulated sleep delays instead of relying on wall-clock pauses, which improves test reliability and execution speed on slow CI environments. The feedback suggests initializing the FakeApiClock with a non-zero value rather than 0L to prevent potential conflicts with internal components that might treat 0L as an uninitialized sentinel value.

@lqiu96
lqiu96 marked this pull request as ready for review October 20, 2026 19:47
@lqiu96
lqiu96 requested a review from a team as a code owner October 20, 2026 19:47
@lqiu96 lqiu96 added the kokoro:force-run Add this label to force Kokoro to re-run the tests. label Oct 21, 2026
@yoshi-kokoro yoshi-kokoro removed the kokoro:force-run Add this label to force Kokoro to re-run the tests. label Oct 21, 2026
@lqiu96
lqiu96 requested a review from blakeli0 October 21, 2026 17:43
@lqiu96
lqiu96 enabled auto-merge (squash) October 21, 2026 22:14
@lqiu96
lqiu96 disabled auto-merge October 21, 2026 22:14
@lqiu96
lqiu96 enabled auto-merge (squash) October 21, 2026 22:14
@lqiu96
lqiu96 merged commit beee46f into googleapis:main Oct 22, 2026
281 of 284 checks passed
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.

Nightly-java8 build on windows-2025 failed.

3 participants