diff --git a/google-cloud-bigtable/src/test/java/com/google/cloud/bigtable/data/v2/stub/metrics/MetricsTracerTest.java b/google-cloud-bigtable/src/test/java/com/google/cloud/bigtable/data/v2/stub/metrics/MetricsTracerTest.java index 9314391afa..9fd78c5cd5 100644 --- a/google-cloud-bigtable/src/test/java/com/google/cloud/bigtable/data/v2/stub/metrics/MetricsTracerTest.java +++ b/google-cloud-bigtable/src/test/java/com/google/cloud/bigtable/data/v2/stub/metrics/MetricsTracerTest.java @@ -237,7 +237,10 @@ public Object answer(InvocationOnMock invocation) throws Throwable { getAggregationValueAsLong( RpcViewConstants.BIGTABLE_READ_ROWS_FIRST_ROW_LATENCY_VIEW, ImmutableMap.of()); - assertThat(firstRowLatency).isIn(Range.closed(beforeSleep, elapsed - afterSleep)); + + // adding buffer time to the upper range to allow for a race between the emulator and the client + // recording the duration + assertThat(firstRowLatency).isIn(Range.closed(beforeSleep, elapsed - afterSleep / 2)); } @Test