7070import com .google .cloud .bigtable .data .v2 .stub .EnhancedBigtableStub ;
7171import com .google .cloud .bigtable .data .v2 .stub .EnhancedBigtableStubSettings ;
7272import com .google .common .base .Stopwatch ;
73+ import com .google .common .collect .Comparators ;
7374import com .google .common .collect .Range ;
7475import com .google .protobuf .ByteString ;
7576import com .google .protobuf .BytesValue ;
@@ -719,8 +720,11 @@ public void testQueuedOnChannelServerStreamLatencies() throws Exception {
719720 .put (CLIENT_NAME_KEY , CLIENT_NAME )
720721 .build ();
721722
722- Duration value = Duration .ofMillis (getAggregatedValue (clientLatency , attributes ));
723- assertThat (value ).isAtLeast (CHANNEL_BLOCKING_LATENCY .minus (proxyDelayPriorTest ));
723+ assertThat (Duration .ofMillis (getAggregatedValue (clientLatency , attributes )))
724+ .isAtLeast (
725+ // Offset the expected latency to deal with asynchrony and jitter
726+ CHANNEL_BLOCKING_LATENCY .minus (
727+ Comparators .max (proxyDelayPriorTest , Duration .ofMillis (1 ))));
724728 }
725729
726730 @ Test
@@ -743,8 +747,11 @@ public void testQueuedOnChannelUnaryLatencies() throws Exception {
743747 .put (CLIENT_NAME_KEY , CLIENT_NAME )
744748 .build ();
745749
746- Duration actual = Duration .ofMillis (getAggregatedValue (clientLatency , attributes ));
747- assertThat (actual ).isAtLeast (CHANNEL_BLOCKING_LATENCY .minus (proxyDelayPriorTest ));
750+ assertThat (Duration .ofMillis (getAggregatedValue (clientLatency , attributes )))
751+ .isAtLeast (
752+ // Offset the expected latency to deal with asynchrony and jitter
753+ CHANNEL_BLOCKING_LATENCY .minus (
754+ Comparators .max (proxyDelayPriorTest , Duration .ofMillis (1 ))));
748755 }
749756
750757 @ Test
0 commit comments