Skip to content

Commit 0d9ff6a

Browse files
authored
fix: set a longer timeout to wait for callbacks to be executed (#1478)
* fix: set a longer timeout to wait for callbacks to be executed * fix format
1 parent e54cf7d commit 0d9ff6a

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

google-cloud-bigtable/src/test/java/com/google/cloud/bigtable/data/v2/stub/metrics/BuiltinMetricsTracerTest.java

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -313,10 +313,12 @@ public void testRetryCount() {
313313
stub.mutateRowCallable()
314314
.call(RowMutation.create(TABLE_ID, "random-row").setCell("cf", "q", "value"));
315315

316-
// onOperationComplete() is called in TracerFinisher which will be called after the mutateRow
317-
// call is returned. So there's a race between when the call returns and when the putRetryCount
318-
// is called in onOperationCompletion().
319-
verify(statsRecorderWrapper, timeout(20)).putRetryCount(retryCount.capture());
316+
// In TracedUnaryCallable, we create a future and add a TraceFinisher to the callback. Main
317+
// thread is blocked on waiting for the future to be completed. When onComplete is called on
318+
// the grpc thread, the future is completed, however we might not have enough time for
319+
// TraceFinisher to run. Add a 1 second time out to wait for the callback. This shouldn't have
320+
// any impact on production code.
321+
verify(statsRecorderWrapper, timeout(1000)).putRetryCount(retryCount.capture());
320322

321323
assertThat(retryCount.getValue()).isEqualTo(fakeService.getAttemptCounter().get() - 1);
322324
}

0 commit comments

Comments
 (0)