-
Notifications
You must be signed in to change notification settings - Fork 90
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: count row merging errors as internal errors
Currently they dont have a status associated and thus get counted as UNKOWN Change-Id: Ida3470a0609f2e2ad51534eb3141db394af1dcdc
- Loading branch information
1 parent
6b48606
commit 40573ab
Showing
2 changed files
with
116 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
99 changes: 99 additions & 0 deletions
99
...oud-bigtable/src/test/java/com/google/cloud/bigtable/data/v2/functional/ReadRowsTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,99 @@ | ||
package com.google.cloud.bigtable.data.v2.functional; | ||
|
||
import com.google.api.gax.rpc.InternalException; | ||
import com.google.bigtable.v2.BigtableGrpc; | ||
import com.google.bigtable.v2.ReadRowsRequest; | ||
import com.google.bigtable.v2.ReadRowsResponse; | ||
import com.google.cloud.bigtable.data.v2.BigtableDataClient; | ||
import com.google.cloud.bigtable.data.v2.BigtableDataSettings; | ||
import com.google.cloud.bigtable.data.v2.FakeServiceBuilder; | ||
import com.google.cloud.bigtable.data.v2.models.Query; | ||
import com.google.cloud.bigtable.data.v2.models.Row; | ||
import com.google.protobuf.ByteString; | ||
import com.google.protobuf.BytesValue; | ||
import com.google.protobuf.StringValue; | ||
import io.grpc.Server; | ||
import io.grpc.stub.StreamObserver; | ||
import org.junit.After; | ||
import org.junit.Assert; | ||
import org.junit.Before; | ||
import org.junit.Test; | ||
import org.junit.runner.RunWith; | ||
import org.junit.runners.JUnit4; | ||
|
||
import java.util.ArrayList; | ||
import java.util.Collections; | ||
import java.util.List; | ||
|
||
@RunWith(JUnit4.class) | ||
public class ReadRowsTest { | ||
private FakeService service; | ||
private Server server; | ||
|
||
@Before | ||
public void setUp() throws Exception { | ||
service = new FakeService(); | ||
server = FakeServiceBuilder.create(service) | ||
.start(); | ||
} | ||
|
||
@After | ||
public void tearDown() throws Exception { | ||
server.shutdown(); | ||
} | ||
|
||
@Test | ||
public void rowMergingErrorsUseInternalStatus() throws Exception { | ||
BigtableDataSettings settings = BigtableDataSettings.newBuilderForEmulator(server.getPort()) | ||
.setProjectId("fake-project") | ||
.setInstanceId("fake-instance") | ||
.build(); | ||
|
||
service.readRowsResponses.add( | ||
ReadRowsResponse.newBuilder() | ||
.addChunks( | ||
ReadRowsResponse.CellChunk.newBuilder() | ||
.setRowKey(ByteString.copyFromUtf8("z")) | ||
.setFamilyName(StringValue.newBuilder().setValue("f")) | ||
.setQualifier(BytesValue.newBuilder().setValue(ByteString.copyFromUtf8("q")).build()) | ||
.setTimestampMicros(1000) | ||
.setValue(ByteString.copyFromUtf8("v")) | ||
.setCommitRow(true) | ||
) | ||
.addChunks( | ||
ReadRowsResponse.CellChunk.newBuilder() | ||
.setRowKey(ByteString.copyFromUtf8("a")) | ||
.setFamilyName(StringValue.newBuilder().setValue("f")) | ||
.setQualifier(BytesValue.newBuilder().setValue(ByteString.copyFromUtf8("q")).build()) | ||
.setTimestampMicros(1000) | ||
.setValue(ByteString.copyFromUtf8("v")) | ||
.setCommitRow(true) | ||
) | ||
.build() | ||
); | ||
|
||
try (BigtableDataClient client = BigtableDataClient.create(settings)) { | ||
Assert.assertThrows( | ||
InternalException.class, | ||
() -> { | ||
for (Row ignored : client.readRows(Query.create("fake-table"))) { | ||
|
||
} | ||
} | ||
); | ||
} | ||
} | ||
|
||
|
||
static class FakeService extends BigtableGrpc.BigtableImplBase { | ||
private List<ReadRowsResponse> readRowsResponses = Collections.synchronizedList(new ArrayList<>()); | ||
|
||
@Override | ||
public void readRows(ReadRowsRequest request, StreamObserver<ReadRowsResponse> responseObserver) { | ||
for (ReadRowsResponse r : readRowsResponses) { | ||
responseObserver.onNext(r); | ||
} | ||
responseObserver.onCompleted(); | ||
} | ||
} | ||
} |