From 629f1999149ee94ef9ac43f30a1b9147f1cab82e Mon Sep 17 00:00:00 2001 From: Blake Li Date: Fri, 12 Jun 2026 20:30:03 +0000 Subject: [PATCH 1/5] chore(deps): introduce awaitility to sdk-platform-java Introduces awaitility version 4.3.0 to gapic-generator-java-pom-parent and gax-java, and migrates ThresholdBatcherTest to use it with 1 second timeouts instead of brittle Thread.sleep. --- .../gapic-generator-java-pom-parent/pom.xml | 1 + sdk-platform-java/gax-java/gax/pom.xml | 5 +++++ .../google/api/gax/batching/ThresholdBatcherTest.java | 11 +++++------ sdk-platform-java/gax-java/pom.xml | 6 ++++++ 4 files changed, 17 insertions(+), 6 deletions(-) diff --git a/sdk-platform-java/gapic-generator-java-pom-parent/pom.xml b/sdk-platform-java/gapic-generator-java-pom-parent/pom.xml index c8a8ee8554d9..bcf344855474 100644 --- a/sdk-platform-java/gapic-generator-java-pom-parent/pom.xml +++ b/sdk-platform-java/gapic-generator-java-pom-parent/pom.xml @@ -38,6 +38,7 @@ 1.7.0 5.11.4 4.11.0 + 4.3.0 2.0.16 true diff --git a/sdk-platform-java/gax-java/gax/pom.xml b/sdk-platform-java/gax-java/gax/pom.xml index 76688e04ef86..3316c766da89 100644 --- a/sdk-platform-java/gax-java/gax/pom.xml +++ b/sdk-platform-java/gax-java/gax/pom.xml @@ -111,6 +111,11 @@ ${junit.version} test + + org.awaitility + awaitility + test + io.grpc grpc-api diff --git a/sdk-platform-java/gax-java/gax/src/test/java/com/google/api/gax/batching/ThresholdBatcherTest.java b/sdk-platform-java/gax-java/gax/src/test/java/com/google/api/gax/batching/ThresholdBatcherTest.java index f87b772d3b4e..b59efcabbd4b 100644 --- a/sdk-platform-java/gax-java/gax/src/test/java/com/google/api/gax/batching/ThresholdBatcherTest.java +++ b/sdk-platform-java/gax-java/gax/src/test/java/com/google/api/gax/batching/ThresholdBatcherTest.java @@ -37,6 +37,7 @@ import static org.mockito.ArgumentMatchers.eq; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.times; +import static org.awaitility.Awaitility.await; import static org.mockito.Mockito.verify; import static org.mockito.Mockito.when; @@ -44,6 +45,7 @@ import com.google.api.gax.batching.FlowController.FlowControlException; import com.google.api.gax.batching.FlowController.LimitExceededBehavior; import com.google.common.collect.ImmutableList; +import java.time.Duration; import java.util.AbstractMap.SimpleEntry; import java.util.ArrayList; import java.util.Arrays; @@ -194,14 +196,12 @@ void testBatching() throws Exception { batcher.add(SimpleBatch.fromInteger(3)); batcher.add(SimpleBatch.fromInteger(5)); // Give time for the executor to push the batch - Thread.sleep(100); - assertThat(receiver.getBatches()).hasSize(1); + await().atMost(Duration.ofSeconds(1)).untilAsserted(() -> assertThat(receiver.getBatches()).hasSize(1)); batcher.add(SimpleBatch.fromInteger(7)); batcher.add(SimpleBatch.fromInteger(9)); // Give time for the executor to push the batch - Thread.sleep(100); - assertThat(receiver.getBatches()).hasSize(2); + await().atMost(Duration.ofSeconds(1)).untilAsserted(() -> assertThat(receiver.getBatches()).hasSize(2)); batcher.add(SimpleBatch.fromInteger(11)); @@ -228,8 +228,7 @@ void testBatchingWithDelay() throws Exception { batcher.add(SimpleBatch.fromInteger(3)); batcher.add(SimpleBatch.fromInteger(5)); // Give time for the delay to trigger and push the batch - Thread.sleep(500); - assertThat(receiver.getBatches()).hasSize(1); + await().atMost(Duration.ofSeconds(1)).untilAsserted(() -> assertThat(receiver.getBatches()).hasSize(1)); batcher.add(SimpleBatch.fromInteger(11)); diff --git a/sdk-platform-java/gax-java/pom.xml b/sdk-platform-java/gax-java/pom.xml index e46f1018a813..fc7cf36e5aed 100644 --- a/sdk-platform-java/gax-java/pom.xml +++ b/sdk-platform-java/gax-java/pom.xml @@ -175,6 +175,12 @@ pom import + + org.awaitility + awaitility + ${awaitility.version} + test + From 06cd2e03286d56bbcc635344a9338b36465cb888 Mon Sep 17 00:00:00 2001 From: Blake Li Date: Fri, 12 Jun 2026 20:36:19 +0000 Subject: [PATCH 2/5] chore(deps): configure awaitility version locally in gax-java and increase test timeouts to 5s --- .../com/google/api/gax/batching/ThresholdBatcherTest.java | 6 +++--- sdk-platform-java/gax-java/pom.xml | 1 + 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/sdk-platform-java/gax-java/gax/src/test/java/com/google/api/gax/batching/ThresholdBatcherTest.java b/sdk-platform-java/gax-java/gax/src/test/java/com/google/api/gax/batching/ThresholdBatcherTest.java index b59efcabbd4b..0aed693375b3 100644 --- a/sdk-platform-java/gax-java/gax/src/test/java/com/google/api/gax/batching/ThresholdBatcherTest.java +++ b/sdk-platform-java/gax-java/gax/src/test/java/com/google/api/gax/batching/ThresholdBatcherTest.java @@ -196,12 +196,12 @@ void testBatching() throws Exception { batcher.add(SimpleBatch.fromInteger(3)); batcher.add(SimpleBatch.fromInteger(5)); // Give time for the executor to push the batch - await().atMost(Duration.ofSeconds(1)).untilAsserted(() -> assertThat(receiver.getBatches()).hasSize(1)); + await().atMost(Duration.ofSeconds(5)).untilAsserted(() -> assertThat(receiver.getBatches()).hasSize(1)); batcher.add(SimpleBatch.fromInteger(7)); batcher.add(SimpleBatch.fromInteger(9)); // Give time for the executor to push the batch - await().atMost(Duration.ofSeconds(1)).untilAsserted(() -> assertThat(receiver.getBatches()).hasSize(2)); + await().atMost(Duration.ofSeconds(5)).untilAsserted(() -> assertThat(receiver.getBatches()).hasSize(2)); batcher.add(SimpleBatch.fromInteger(11)); @@ -228,7 +228,7 @@ void testBatchingWithDelay() throws Exception { batcher.add(SimpleBatch.fromInteger(3)); batcher.add(SimpleBatch.fromInteger(5)); // Give time for the delay to trigger and push the batch - await().atMost(Duration.ofSeconds(1)).untilAsserted(() -> assertThat(receiver.getBatches()).hasSize(1)); + await().atMost(Duration.ofSeconds(5)).untilAsserted(() -> assertThat(receiver.getBatches()).hasSize(1)); batcher.add(SimpleBatch.fromInteger(11)); diff --git a/sdk-platform-java/gax-java/pom.xml b/sdk-platform-java/gax-java/pom.xml index fc7cf36e5aed..f20d7cc59c55 100644 --- a/sdk-platform-java/gax-java/pom.xml +++ b/sdk-platform-java/gax-java/pom.xml @@ -36,6 +36,7 @@ UTF-8 1.8 1.8 + 4.3.0 From e69f121b0fc18f70abcae527183aa05a6d371104 Mon Sep 17 00:00:00 2001 From: Blake Li Date: Fri, 12 Jun 2026 20:45:01 +0000 Subject: [PATCH 3/5] chore(deps): revert duplicate property in gax-java/pom.xml --- sdk-platform-java/gax-java/pom.xml | 1 - 1 file changed, 1 deletion(-) diff --git a/sdk-platform-java/gax-java/pom.xml b/sdk-platform-java/gax-java/pom.xml index f20d7cc59c55..fc7cf36e5aed 100644 --- a/sdk-platform-java/gax-java/pom.xml +++ b/sdk-platform-java/gax-java/pom.xml @@ -36,7 +36,6 @@ UTF-8 1.8 1.8 - 4.3.0 From 5a64acf6f24ecf38197515387e384c5c61e8fc1a Mon Sep 17 00:00:00 2001 From: Blake Li Date: Fri, 12 Jun 2026 20:53:01 +0000 Subject: [PATCH 4/5] chore(deps): format Awaitility changes in ThresholdBatcherTest --- .../api/gax/batching/ThresholdBatcherTest.java | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/sdk-platform-java/gax-java/gax/src/test/java/com/google/api/gax/batching/ThresholdBatcherTest.java b/sdk-platform-java/gax-java/gax/src/test/java/com/google/api/gax/batching/ThresholdBatcherTest.java index 0aed693375b3..29b1628338a0 100644 --- a/sdk-platform-java/gax-java/gax/src/test/java/com/google/api/gax/batching/ThresholdBatcherTest.java +++ b/sdk-platform-java/gax-java/gax/src/test/java/com/google/api/gax/batching/ThresholdBatcherTest.java @@ -30,6 +30,7 @@ package com.google.api.gax.batching; import static com.google.common.truth.Truth.assertThat; +import static org.awaitility.Awaitility.await; import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertThrows; import static org.mockito.ArgumentMatchers.any; @@ -37,7 +38,6 @@ import static org.mockito.ArgumentMatchers.eq; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.times; -import static org.awaitility.Awaitility.await; import static org.mockito.Mockito.verify; import static org.mockito.Mockito.when; @@ -196,12 +196,16 @@ void testBatching() throws Exception { batcher.add(SimpleBatch.fromInteger(3)); batcher.add(SimpleBatch.fromInteger(5)); // Give time for the executor to push the batch - await().atMost(Duration.ofSeconds(5)).untilAsserted(() -> assertThat(receiver.getBatches()).hasSize(1)); + await() + .atMost(Duration.ofSeconds(5)) + .untilAsserted(() -> assertThat(receiver.getBatches()).hasSize(1)); batcher.add(SimpleBatch.fromInteger(7)); batcher.add(SimpleBatch.fromInteger(9)); // Give time for the executor to push the batch - await().atMost(Duration.ofSeconds(5)).untilAsserted(() -> assertThat(receiver.getBatches()).hasSize(2)); + await() + .atMost(Duration.ofSeconds(5)) + .untilAsserted(() -> assertThat(receiver.getBatches()).hasSize(2)); batcher.add(SimpleBatch.fromInteger(11)); @@ -228,7 +232,9 @@ void testBatchingWithDelay() throws Exception { batcher.add(SimpleBatch.fromInteger(3)); batcher.add(SimpleBatch.fromInteger(5)); // Give time for the delay to trigger and push the batch - await().atMost(Duration.ofSeconds(5)).untilAsserted(() -> assertThat(receiver.getBatches()).hasSize(1)); + await() + .atMost(Duration.ofSeconds(5)) + .untilAsserted(() -> assertThat(receiver.getBatches()).hasSize(1)); batcher.add(SimpleBatch.fromInteger(11)); From 0643d311f3b2374c2ebfc634b35d83da77d70a1d Mon Sep 17 00:00:00 2001 From: Blake Li Date: Fri, 12 Jun 2026 21:04:20 +0000 Subject: [PATCH 5/5] chore(deps): add awaitility to bazel dependencies --- sdk-platform-java/gax-java/dependencies.properties | 2 ++ sdk-platform-java/gax-java/gax/BUILD.bazel | 1 + 2 files changed, 3 insertions(+) diff --git a/sdk-platform-java/gax-java/dependencies.properties b/sdk-platform-java/gax-java/dependencies.properties index 261ff0a9f8af..e35d7127e29b 100644 --- a/sdk-platform-java/gax-java/dependencies.properties +++ b/sdk-platform-java/gax-java/dependencies.properties @@ -96,3 +96,5 @@ maven.io_opentelemetry_opentelemetry_sdk=io.opentelemetry:opentelemetry-sdk:1.57 maven.io_opentelemetry_opentelemetry_sdk_common=io.opentelemetry:opentelemetry-sdk-common:1.57.0 maven.io_opentelemetry_opentelemetry_sdk_metrics=io.opentelemetry:opentelemetry-sdk-metrics:1.57.0 maven.com_google_guava_guava_testlib=com.google.guava:guava-testlib:32.1.3-jre +maven.org_awaitility_awaitility=org.awaitility:awaitility:4.3.0 + diff --git a/sdk-platform-java/gax-java/gax/BUILD.bazel b/sdk-platform-java/gax-java/gax/BUILD.bazel index 7faa2d2597bb..773e9b9beb45 100644 --- a/sdk-platform-java/gax-java/gax/BUILD.bazel +++ b/sdk-platform-java/gax-java/gax/BUILD.bazel @@ -49,6 +49,7 @@ _TEST_COMPILE_DEPS = [ "@io_opentelemetry_opentelemetry_sdk_metrics//jar", "@io_opentelemetry_opentelemetry_sdk_common//jar", "@com_google_guava_guava_testlib//jar", + "@org_awaitility_awaitility//jar", ] java_library(