Skip to content

Commit b4b41d9

Browse files
authored
test(bigquerystorage): increase await timeout for createReadSession to 1 minute (#14125)
## Description Increases the `await()` timeout to 1 minute in `ITBigQueryStorageTest` (v1beta1, v1beta2) and adds the 1-minute retry logic to the production v1 test helper (`Helper.processRowsAtSnapshot`) when creating read sessions. ### Context In CI environments, table metadata propagation from `bigquery.googleapis.com` to `bigquerystorage.googleapis.com` can take longer than 10 seconds, causing `ConditionTimeoutException` or `NotFoundException` test flakes (e.g., in `sponge/b1dc622b-9c70-41cb-953e-74c2dfbb3f31`). Setting a 1-minute retry ceiling: - Provides sufficient buffer for metadata propagation across busy CI runners. - Ensures consistency across v1, v1beta1, and v1beta2 test suites. - Matches the 1-minute timeout used elsewhere in the test suite (e.g. `job.waitFor(..., RetryOption.totalTimeoutDuration(Duration.ofMinutes(1)))`). - Adds zero extra latency to successful runs, as `await()` returns immediately upon session creation.
1 parent 9ac5561 commit b4b41d9

3 files changed

Lines changed: 19 additions & 3 deletions

File tree

java-bigquerystorage/google-cloud-bigquerystorage-it/src/test/java/com/google/cloud/bigquery/storage/v1/it/util/Helper.java

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,12 @@
1616

1717
package com.google.cloud.bigquery.storage.v1.it.util;
1818

19+
import static org.awaitility.Awaitility.await;
1920
import static org.junit.jupiter.api.Assertions.assertEquals;
2021
import static org.junit.jupiter.api.Assertions.fail;
2122

2223
import com.google.api.core.ApiFutureCallback;
24+
import com.google.api.gax.rpc.NotFoundException;
2325
import com.google.api.gax.rpc.ServerStream;
2426
import com.google.auth.oauth2.ServiceAccountCredentials;
2527
import com.google.cloud.bigquery.storage.v1.AppendRowsResponse;
@@ -38,8 +40,10 @@
3840
import java.io.ByteArrayInputStream;
3941
import java.io.IOException;
4042
import java.io.InputStream;
43+
import java.time.Duration;
4144
import java.util.ArrayList;
4245
import java.util.List;
46+
import java.util.concurrent.atomic.AtomicReference;
4347
import org.apache.avro.Schema;
4448
import org.apache.avro.generic.GenericData;
4549
import org.apache.avro.generic.GenericRecordBuilder;
@@ -159,7 +163,19 @@ public static void processRowsAtSnapshot(
159163
ReadSession.TableReadOptions.newBuilder().setRowRestriction(filter).build());
160164
}
161165

162-
ReadSession session = client.createReadSession(createSessionRequestBuilder.build());
166+
CreateReadSessionRequest request = createSessionRequestBuilder.build();
167+
AtomicReference<ReadSession> sessionRef = new AtomicReference<>();
168+
await()
169+
.atMost(Duration.ofMinutes(1))
170+
.pollInterval(Duration.ofSeconds(1))
171+
// retry if the newly-created table has not yet fully propagated
172+
.ignoreException(NotFoundException.class)
173+
.until(
174+
() -> {
175+
sessionRef.set(client.createReadSession(request));
176+
return true;
177+
});
178+
ReadSession session = sessionRef.get();
163179
assertEquals(
164180
1,
165181
session.getStreamsCount(),

java-bigquerystorage/google-cloud-bigquerystorage-it/src/test/java/com/google/cloud/bigquery/storage/v1beta1/it/ITBigQueryStorageTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1236,7 +1236,7 @@ private void ProcessRowsAtSnapshot(
12361236
CreateReadSessionRequest request = createSessionRequestBuilder.build();
12371237
AtomicReference<ReadSession> sessionRef = new AtomicReference<>();
12381238
await()
1239-
.atMost(Duration.ofSeconds(10))
1239+
.atMost(Duration.ofMinutes(1))
12401240
.pollInterval(Duration.ofSeconds(1))
12411241
// retry if the newly-created table has not yet fully propagated
12421242
.ignoreException(NotFoundException.class)

java-bigquerystorage/google-cloud-bigquerystorage-it/src/test/java/com/google/cloud/bigquery/storage/v1beta2/it/ITBigQueryStorageTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1217,7 +1217,7 @@ private void ProcessRowsAtSnapshot(
12171217
CreateReadSessionRequest request = createSessionRequestBuilder.build();
12181218
AtomicReference<ReadSession> sessionRef = new AtomicReference<>();
12191219
await()
1220-
.atMost(Duration.ofSeconds(10))
1220+
.atMost(Duration.ofMinutes(1))
12211221
.pollInterval(Duration.ofSeconds(1))
12221222
// retry if the newly-created table has not yet fully propagated
12231223
.ignoreException(NotFoundException.class)

0 commit comments

Comments
 (0)