From 0d9ff6ab3bd5bf853f1d371312036b14c924ae5e Mon Sep 17 00:00:00 2001 From: Mattie Fu Date: Wed, 26 Oct 2022 12:27:23 -0400 Subject: [PATCH] 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 --- .../data/v2/stub/metrics/BuiltinMetricsTracerTest.java | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/google-cloud-bigtable/src/test/java/com/google/cloud/bigtable/data/v2/stub/metrics/BuiltinMetricsTracerTest.java b/google-cloud-bigtable/src/test/java/com/google/cloud/bigtable/data/v2/stub/metrics/BuiltinMetricsTracerTest.java index d64570488a..76bb7384ed 100644 --- a/google-cloud-bigtable/src/test/java/com/google/cloud/bigtable/data/v2/stub/metrics/BuiltinMetricsTracerTest.java +++ b/google-cloud-bigtable/src/test/java/com/google/cloud/bigtable/data/v2/stub/metrics/BuiltinMetricsTracerTest.java @@ -313,10 +313,12 @@ public void testRetryCount() { stub.mutateRowCallable() .call(RowMutation.create(TABLE_ID, "random-row").setCell("cf", "q", "value")); - // onOperationComplete() is called in TracerFinisher which will be called after the mutateRow - // call is returned. So there's a race between when the call returns and when the putRetryCount - // is called in onOperationCompletion(). - verify(statsRecorderWrapper, timeout(20)).putRetryCount(retryCount.capture()); + // In TracedUnaryCallable, we create a future and add a TraceFinisher to the callback. Main + // thread is blocked on waiting for the future to be completed. When onComplete is called on + // the grpc thread, the future is completed, however we might not have enough time for + // TraceFinisher to run. Add a 1 second time out to wait for the callback. This shouldn't have + // any impact on production code. + verify(statsRecorderWrapper, timeout(1000)).putRetryCount(retryCount.capture()); assertThat(retryCount.getValue()).isEqualTo(fakeService.getAttemptCounter().get() - 1); }