From b68449db9f43a696f9446966939f97e7d8b888ea Mon Sep 17 00:00:00 2001 From: blakeli Date: Mon, 4 Nov 2024 22:22:20 -0500 Subject: [PATCH 1/3] fix: Fix flaky test ScheduledRetryingExecutorTest.testCancelOuterFutureAfterStart. --- .../gax/retrying/ScheduledRetryingExecutorTest.java | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/gax-java/gax/src/test/java/com/google/api/gax/retrying/ScheduledRetryingExecutorTest.java b/gax-java/gax/src/test/java/com/google/api/gax/retrying/ScheduledRetryingExecutorTest.java index 53c1707290..1d92de58f9 100644 --- a/gax-java/gax/src/test/java/com/google/api/gax/retrying/ScheduledRetryingExecutorTest.java +++ b/gax-java/gax/src/test/java/com/google/api/gax/retrying/ScheduledRetryingExecutorTest.java @@ -41,6 +41,8 @@ import com.google.api.core.NanoClock; import com.google.api.gax.retrying.FailingCallable.CustomException; import com.google.api.gax.rpc.testing.FakeCallContext; + +import java.util.Optional; import java.util.concurrent.CancellationException; import java.util.concurrent.ExecutionException; import java.util.concurrent.Executors; @@ -195,13 +197,13 @@ void testCancelGetAttempt(boolean withCustomRetrySettings) throws Exception { setUp(withCustomRetrySettings); for (int executionsCount = 0; executionsCount < EXECUTIONS_COUNT; executionsCount++) { ScheduledExecutorService localExecutor = Executors.newSingleThreadScheduledExecutor(); - final int maxRetries = 100; + final int maxRetries = 20; FailingCallable callable = new FailingCallable(maxRetries - 1, "request", "SUCCESS", tracer); RetrySettings retrySettings = FAST_RETRY_SETTINGS .toBuilder() - .setTotalTimeoutDuration(java.time.Duration.ofMillis(1000L)) + .setTotalTimeoutDuration(java.time.Duration.ofMillis(5000L)) .setMaxAttempts(maxRetries) .build(); @@ -259,10 +261,10 @@ void testCancelOuterFutureAfterStart() throws Exception { .toBuilder() // These params were selected to ensure that future tries to run and fail (at least // once) but does not complete before it is cancelled. Assuming no computation time, - // it would take 25 + 100 + 400 + 1000 = 1525ms for the future to complete, which should + // it would take 2500 + 10000 + 10000 + 10000 = 32500ms for the future to complete, which should // be more than enough time to cancel the future. - .setInitialRetryDelayDuration(java.time.Duration.ofMillis(25L)) - .setMaxRetryDelayDuration(java.time.Duration.ofMillis(1000L)) + .setInitialRetryDelayDuration(java.time.Duration.ofMillis(2500L)) + .setMaxRetryDelayDuration(java.time.Duration.ofMillis(10000L)) .setRetryDelayMultiplier(4.0) .setTotalTimeoutDuration(java.time.Duration.ofMillis(60000L)) // Set this test to not use jitter as the randomized retry delay (RRD) may introduce From b031b18a9bb35b77ca21d3665217aa4c219ced57 Mon Sep 17 00:00:00 2001 From: blakeli Date: Tue, 5 Nov 2024 18:06:21 -0500 Subject: [PATCH 2/3] fix: Fix flaky test ScheduledRetryingExecutorTest.testCancelOuterFutureAfterStart. --- .../google/api/gax/retrying/ScheduledRetryingExecutorTest.java | 2 -- 1 file changed, 2 deletions(-) diff --git a/gax-java/gax/src/test/java/com/google/api/gax/retrying/ScheduledRetryingExecutorTest.java b/gax-java/gax/src/test/java/com/google/api/gax/retrying/ScheduledRetryingExecutorTest.java index 1d92de58f9..4c9e597909 100644 --- a/gax-java/gax/src/test/java/com/google/api/gax/retrying/ScheduledRetryingExecutorTest.java +++ b/gax-java/gax/src/test/java/com/google/api/gax/retrying/ScheduledRetryingExecutorTest.java @@ -41,8 +41,6 @@ import com.google.api.core.NanoClock; import com.google.api.gax.retrying.FailingCallable.CustomException; import com.google.api.gax.rpc.testing.FakeCallContext; - -import java.util.Optional; import java.util.concurrent.CancellationException; import java.util.concurrent.ExecutionException; import java.util.concurrent.Executors; From 26f205a22afb17a79545f03f39e3dadda524e6e8 Mon Sep 17 00:00:00 2001 From: blakeli Date: Tue, 5 Nov 2024 18:13:31 -0500 Subject: [PATCH 3/3] chore: format --- .../google/api/gax/retrying/ScheduledRetryingExecutorTest.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/gax-java/gax/src/test/java/com/google/api/gax/retrying/ScheduledRetryingExecutorTest.java b/gax-java/gax/src/test/java/com/google/api/gax/retrying/ScheduledRetryingExecutorTest.java index 4c9e597909..5a65895ef0 100644 --- a/gax-java/gax/src/test/java/com/google/api/gax/retrying/ScheduledRetryingExecutorTest.java +++ b/gax-java/gax/src/test/java/com/google/api/gax/retrying/ScheduledRetryingExecutorTest.java @@ -259,7 +259,8 @@ void testCancelOuterFutureAfterStart() throws Exception { .toBuilder() // These params were selected to ensure that future tries to run and fail (at least // once) but does not complete before it is cancelled. Assuming no computation time, - // it would take 2500 + 10000 + 10000 + 10000 = 32500ms for the future to complete, which should + // it would take 2500 + 10000 + 10000 + 10000 = 32500ms for the future to complete, + // which should // be more than enough time to cancel the future. .setInitialRetryDelayDuration(java.time.Duration.ofMillis(2500L)) .setMaxRetryDelayDuration(java.time.Duration.ofMillis(10000L))