Skip to content

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

Open
lqiu96 wants to merge 1 commit into
googleapis:mainfrom
lqiu96:fix/gax-direct-retrying-executor-fake-clock-14625
Open

lqiu96 wants to merge 1 commit 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.

This branch has not been deployed

No deployments
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 test ScheduledRetryingExecutorTest.testSuccessWithFailuresGetAttempt

1 participant