Visitar URL original
test: add a test for readrows tags for fix #1477 · mutianf/java-bigtable@ee5ea42 · GitHub
Skip to content

Commit ee5ea42

Browse files
committed
test: add a test for readrows tags for fix googleapis#1477
1 parent 6db9326 commit ee5ea42

1 file changed

Lines changed: 24 additions & 1 deletion

File tree

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

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -324,7 +324,7 @@ public void testRetryCount() {
324324
}
325325

326326
@Test
327-
public void testMutateRowAttempts() {
327+
public void testMutateRowAttemptsTagValues() {
328328
when(mockFactory.newTracer(any(), any(), any()))
329329
.thenReturn(
330330
new BuiltinMetricsTracer(
@@ -345,6 +345,29 @@ public void testMutateRowAttempts() {
345345
assertThat(status.getAllValues()).containsExactly("UNAVAILABLE", "UNAVAILABLE", "OK");
346346
}
347347

348+
@Test
349+
public void testReadRowsAttemptsTagValues() {
350+
when(mockFactory.newTracer(any(), any(), any()))
351+
.thenReturn(
352+
new BuiltinMetricsTracer(
353+
OperationType.ServerStreaming,
354+
SpanName.of("Bigtable", "ReadRows"),
355+
statsRecorderWrapper));
356+
357+
Lists.newArrayList(stub.readRowsCallable().call(Query.create("fake-table")).iterator());
358+
359+
// Set a timeout to reduce flakiness of this test. BasicRetryingFuture will set
360+
// attempt succeeded and set the response which will call complete() in AbstractFuture which
361+
// calls releaseWaiters(). onOperationComplete() is called in TracerFinisher which will be
362+
// called after the mutateRow call is returned. So there's a race between when the call returns
363+
// and when the record() is called in onOperationCompletion().
364+
verify(statsRecorderWrapper, timeout(50).times(fakeService.getAttemptCounter().get()))
365+
.recordAttempt(status.capture(), tableId.capture(), zone.capture(), cluster.capture());
366+
assertThat(zone.getAllValues()).containsExactly("global", ZONE);
367+
assertThat(cluster.getAllValues()).containsExactly("unspecified", CLUSTER);
368+
assertThat(status.getAllValues()).containsExactly("UNAVAILABLE", "OK");
369+
}
370+
348371
private static class FakeService extends BigtableGrpc.BigtableImplBase {
349372

350373
static List<ReadRowsResponse> createFakeResponse() {

0 commit comments

Comments
 (0)