From 8595478d1fc54e5aa1656212cf7aa3a825b97200 Mon Sep 17 00:00:00 2001 From: Mattie Fu Date: Wed, 26 Oct 2022 10:33:02 -0400 Subject: [PATCH 1/2] fix: set a longer timeout to wait for callbacks to be executed --- .../v2/stub/metrics/BuiltinMetricsTracerTest.java | 11 +++++++---- 1 file changed, 7 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..ea21bd9b31 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,13 @@ 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. + verify(statsRecorderWrapper, timeout(1000)).putRetryCount(retryCount.capture()); assertThat(retryCount.getValue()).isEqualTo(fakeService.getAttemptCounter().get() - 1); } From 05eb67fe4bca1fee5b02d9ec0305a1b8c82fb17b Mon Sep 17 00:00:00 2001 From: Mattie Fu Date: Wed, 26 Oct 2022 10:36:52 -0400 Subject: [PATCH 2/2] fix format --- .../data/v2/stub/metrics/BuiltinMetricsTracerTest.java | 7 +++---- 1 file changed, 3 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 ea21bd9b31..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 @@ -314,11 +314,10 @@ public void testRetryCount() { .call(RowMutation.create(TABLE_ID, "random-row").setCell("cf", "q", "value")); // 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 + // 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. + // 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);