fix(gax): use fake clock in ScheduledRetryingExecutorTest for robust and fast execution#13553
fix(gax): use fake clock in ScheduledRetryingExecutorTest for robust and fast execution#13553lqiu96 wants to merge 3 commits into
Conversation
…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
There was a problem hiding this comment.
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.
…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
|
|



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