|
26 | 26 | import com.google.bigtable.v2.ReadRowsResponse.CellChunk;
|
27 | 27 | import com.google.cloud.bigtable.data.v2.BigtableDataSettings;
|
28 | 28 | import com.google.cloud.bigtable.data.v2.FakeServiceHelper;
|
| 29 | +import com.google.cloud.bigtable.data.v2.models.BulkMutation; |
29 | 30 | import com.google.cloud.bigtable.data.v2.models.Query;
|
30 | 31 | import com.google.cloud.bigtable.data.v2.stub.EnhancedBigtableStub;
|
31 | 32 | import com.google.cloud.bigtable.data.v2.stub.EnhancedBigtableStubSettings;
|
|
46 | 47 | import java.util.concurrent.TimeUnit;
|
47 | 48 | import java.util.concurrent.atomic.AtomicInteger;
|
48 | 49 | import org.junit.After;
|
| 50 | +import org.junit.Assert; |
49 | 51 | import org.junit.Before;
|
50 | 52 | import org.junit.Rule;
|
51 | 53 | import org.junit.Test;
|
@@ -327,6 +329,24 @@ public Object answer(InvocationOnMock invocation) throws Throwable {
|
327 | 329 | assertThat(attemptLatency).isIn(Range.closed(sleepTime, elapsed - sleepTime));
|
328 | 330 | }
|
329 | 331 |
|
| 332 | + @Test |
| 333 | + public void testInvalidRequest() throws InterruptedException { |
| 334 | + try { |
| 335 | + stub.bulkMutateRowsCallable().call(BulkMutation.create(TABLE_ID)); |
| 336 | + Assert.fail("Invalid request should throw exception"); |
| 337 | + } catch (IllegalStateException e) { |
| 338 | + Thread.sleep(100); |
| 339 | + // Verify that the latency is recorded with an error code (in this case UNKNOWN) |
| 340 | + long attemptLatency = |
| 341 | + getAggregationValueAsLong( |
| 342 | + RpcViewConstants.BIGTABLE_ATTEMPT_LATENCY_VIEW, |
| 343 | + ImmutableMap.of( |
| 344 | + RpcMeasureConstants.BIGTABLE_OP, TagValue.create("Bigtable.MutateRows"), |
| 345 | + RpcMeasureConstants.BIGTABLE_STATUS, TagValue.create("UNKNOWN"))); |
| 346 | + assertThat(attemptLatency).isAtLeast(0); |
| 347 | + } |
| 348 | + } |
| 349 | + |
330 | 350 | @SuppressWarnings("unchecked")
|
331 | 351 | private static <T> StreamObserver<T> anyObserver(Class<T> returnType) {
|
332 | 352 | return (StreamObserver<T>) any(returnType);
|
|
0 commit comments