Skip to content

fix(gax): use fake clock in ScheduledRetryingExecutorTest for robust and fast execution#13553

Draft
lqiu96 wants to merge 3 commits into
mainfrom
fix-issue-13535-java
Draft

fix(gax): use fake clock in ScheduledRetryingExecutorTest for robust and fast execution#13553
lqiu96 wants to merge 3 commits into
mainfrom
fix-issue-13535-java

Conversation

@lqiu96

@lqiu96 lqiu96 commented Jun 24, 2026

Copy link
Copy Markdown
Member

Introduced FakeApiClock and RecordingScheduler to ScheduledRetryingExecutorTest to run most tests (including the flaky testSuccessWithFailuresGetAttempt) instantly without real-time delays.

Isolated tests that rely on asynchronous polling or cancellation to use local real executors and clocks, with increased timeout (10s) to avoid flakiness on slow VMs.

Made RecordingScheduler stubbings lenient to avoid UnnecessaryStubbingException in tests that do not query all recorded metrics.

Fixes: #13535

…and fast execution

Introduced FakeApiClock and RecordingScheduler to ScheduledRetryingExecutorTest
to run most tests (including the flaky testSuccessWithFailuresGetAttempt)
instantly without real-time delays.

Isolated tests that rely on asynchronous polling or cancellation to use
local real executors and clocks, with increased timeout (10s) to avoid
flakiness on slow VMs.

Made RecordingScheduler stubbings lenient to avoid UnnecessaryStubbingException
in tests that do not query all recorded metrics.

TAG=agy
CONV=71af906a-b7dc-4dda-a2fa-ebe24b5d8b91
BUG=13535

@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 the test suite in ScheduledRetryingExecutorTest to use a fake clock and introduces local scheduled executors for isolated test runs. It also applies Mockito.lenient() to mock configurations in RecordingScheduler to prevent strict stubbing errors. The review feedback suggests moving the creation and shutdown of the local executors inside the test loops for testSuccessWithFailuresPeekAttempt and testCancelOuterFutureAfterStart to ensure complete isolation between iterations and avoid potential test flakiness.

lqiu96 added 2 commits June 24, 2026 18:07
…xecutorTest

Addressed PR comments by moving the creation and shutdown of local
executors inside the test loops for testSuccessWithFailuresPeekAttempt
and testCancelOuterFutureAfterStart to ensure complete isolation
between iterations and avoid potential flakiness.

TAG=agy
CONV=71af906a-b7dc-4dda-a2fa-ebe24b5d8b91
BUG=13535
Applied fmt-maven-plugin to fix formatting issues in
RecordingScheduler.java and ScheduledRetryingExecutorTest.java.

TAG=agy
CONV=71af906a-b7dc-4dda-a2fa-ebe24b5d8b91
BUG=13535
@sonarqubecloud

Copy link
Copy Markdown

@sonarqubecloud

Copy link
Copy Markdown

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