Skip to content

Commit 9f2dfc0

Browse files
test: deflake prepare plan refresh timeout test (#2628)
Change-Id: I806076a455be746f8d0ef3a63f70b53cf49f5820
1 parent 27b44b4 commit 9f2dfc0

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

google-cloud-bigtable/src/test/java/com/google/cloud/bigtable/data/v2/stub/sql/PlanRefreshingCallableTest.java

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -258,7 +258,10 @@ public void planRefreshDelayIsFactoredIntoExecuteTimeout() throws InterruptedExc
258258
ExecuteQueryCallContext callContext =
259259
ExecuteQueryCallContext.create(preparedStatement.bind().build(), metadataFuture);
260260

261-
Duration originalAttemptTimeout = Duration.ofMillis(100);
261+
// This deadline is used for the prepare call and the ultimate execute call after
262+
// that completes. It needs to leave a lot of margin for error for the scheduler below to
263+
// be slower than expected to resolve. Previously 100ms deadline was not enough.
264+
Duration originalAttemptTimeout = Duration.ofMillis(5000);
262265
scheduler.schedule(
263266
() -> {
264267
prepareFuture.set(
@@ -278,6 +281,9 @@ public void planRefreshDelayIsFactoredIntoExecuteTimeout() throws InterruptedExc
278281
callable.call(callContext, outerObserver, context);
279282
scheduler.shutdown();
280283
scheduler.awaitTermination(30, TimeUnit.SECONDS);
284+
// Make sure prepare didn't time out and return an error.
285+
// Otherwise, the observer should not be done
286+
assertFalse(outerObserver.isDone());
281287
GrpcCallContext grpcCallContext =
282288
(GrpcCallContext) innerCallable.popLastCall().getApiCallContext();
283289
Deadline executeDeadline = grpcCallContext.getCallOptions().getDeadline();

0 commit comments

Comments
 (0)