Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: update the accounting of partial batch mutations #2149

Merged
merged 32 commits into from
Mar 27, 2024
Merged
Changes from 1 commit
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Prev Previous commit
Next Next commit
fix test
  • Loading branch information
ron-gal committed Mar 20, 2024
commit 3f6c60a97fe2945587422c4f483ebb19b60a05e7
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,13 @@
package com.google.cloud.bigtable.data.v2.stub;

import static com.google.common.truth.Truth.assertThat;
import static org.junit.Assert.assertThrows;

import com.google.api.client.json.gson.GsonFactory;
import com.google.api.client.json.webtoken.JsonWebSignature;
import com.google.api.gax.batching.Batcher;
import com.google.api.gax.batching.BatcherImpl;
import com.google.api.gax.batching.BatchingException;
import com.google.api.gax.batching.BatchingSettings;
import com.google.api.gax.batching.FlowControlSettings;
import com.google.api.gax.batching.FlowController.LimitExceededBehavior;
Expand Down Expand Up @@ -120,7 +122,7 @@ public class EnhancedBigtableStubTest {
public void setUp() throws IOException, IllegalAccessException, InstantiationException {
metadataInterceptor = new MetadataInterceptor();
contextInterceptor = new ContextInterceptor();
fakeDataService = new FakeDataService();
fakeDataService = Mockito.spy(new FakeDataService());

server =
FakeServiceBuilder.create(fakeDataService)
Expand Down Expand Up @@ -595,7 +597,7 @@ public void testReadChangeStreamWaitTimeoutIsSet() throws Exception {
}

@Test
public void testBatchMutationsPartialFailure() throws InterruptedException {
public void testBatchMutationsPartialFailure() {
Batcher<RowMutationEntry, Void> batcher =
enhancedBigtableStub.newMutateRowsBatcher("table1", GrpcCallContext.createDefault());

Expand All @@ -621,13 +623,16 @@ public void testBatchMutationsPartialFailure() throws InterruptedException {
observer.onCompleted();
return null;
})
.when(Mockito.mock(FakeDataService.class))
.when(fakeDataService)
.mutateRows(Mockito.any(MutateRowsRequest.class), Mockito.any(StreamObserver.class));
batcher.close();
BatchingException batchingException =
assertThrows(BatchingException.class, () -> batcher.close());
assertThat(batchingException.getMessage())
.contains("Batching finished with 1 partial failures. The 1 partial failures contained 1 entries that failed with: 1 ApiException(1 PERMISSION_DENIED).");
}

@Test
public void testBatchMutationRPCErrorCode() throws InterruptedException {
public void testBatchMutationRPCErrorCode() {
Batcher<RowMutationEntry, Void> batcher =
enhancedBigtableStub.newMutateRowsBatcher("table1", GrpcCallContext.createDefault());

Expand All @@ -637,11 +642,15 @@ public void testBatchMutationRPCErrorCode() throws InterruptedException {
observer.onError(io.grpc.Status.PERMISSION_DENIED.asException());
return null;
})
.when(Mockito.mock(FakeDataService.class))
.when(fakeDataService)
.mutateRows(Mockito.any(MutateRowsRequest.class), Mockito.any(StreamObserver.class));

batcher.add(RowMutationEntry.create("key0").deleteRow());
batcher.close();
BatchingException batchingException =
assertThrows(BatchingException.class, () -> batcher.close());
assertThat(batchingException.getMessage())
.contains(
"Batching finished with 1 batches failed to apply due to: 1 ApiException(1 INTERNAL) and 0 partial failures");
}

igorbernstein2 marked this conversation as resolved.
Show resolved Hide resolved
private static class MetadataInterceptor implements ServerInterceptor {
Expand Down