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

feat: add support for awaiting Data Boost #2329

Merged
merged 27 commits into from
Sep 16, 2024
Merged
Changes from 1 commit
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
1617301
Introduce ConsistencyParams model
djyau Aug 30, 2024
54e6540
Create AwaitConsistencyCallable, a delegate for AwaitReplicationCallable
djyau Sep 4, 2024
d1b4320
Address some PR comments
djyau Sep 4, 2024
febfb02
Remove unused imports from AwaitReplicationCallable
djyau Sep 4, 2024
84a2422
Plumb the Consistency callable through to some places, add some tests
djyau Sep 6, 2024
0f1faec
Add integration test
djyau Sep 6, 2024
20f7809
Rework the ConsistencyRequest model, plumb through RequestContext to …
djyau Sep 6, 2024
2c47294
Fix imports
djyau Sep 6, 2024
ce0a439
Fix more imports, fix some tests
djyau Sep 6, 2024
0327038
Rename some things
djyau Sep 6, 2024
c7fbb27
Add tests for ConsistencyRequest model
djyau Sep 6, 2024
c8ff829
Add newline
djyau Sep 6, 2024
f57b84d
Fix broken test
djyau Sep 6, 2024
86f6d8a
Make request context a final variable in test
djyau Sep 6, 2024
916535f
Get test working using correct expectations
djyau Sep 6, 2024
119ba23
Add a couple of tests for AwaitReplicationCallable
djyau Sep 6, 2024
c16491c
Use RequestContextNoAP class
djyau Sep 9, 2024
09a230f
Make ConsistencyRequest model an AutoValue
djyau Sep 9, 2024
4aa93f2
Fix license year, fix some formatting
djyau Sep 9, 2024
1da2dc7
Run auto formatter
djyau Sep 9, 2024
beadfb0
Rename new RequestContext to TableAdminRequestContext, re run auto fo…
djyau Sep 9, 2024
f774895
🦉 Updates from OwlBot post-processor
gcf-owl-bot[bot] Sep 9, 2024
e263edd
Add license header to ConsistencyRequestTest
djyau Sep 10, 2024
5dbc61a
Merge branch 'feature-await-data-boost-2' of https://github.com/djyau…
djyau Sep 10, 2024
f628eb6
Add EnhancedBigtableTableAdminStub to clirr-ignored-differences
djyau Sep 11, 2024
3614dca
Fix IT tests, skip data boost one for now until we run it concurrently
djyau Sep 12, 2024
1240b3c
Run autoformatter
djyau Sep 13, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Get test working using correct expectations
Change-Id: Ie34d5171bd7a472fc695d603849e260054aedfbd
  • Loading branch information
djyau committed Sep 6, 2024
commit 916535ff5b8abecf8958caa66556cc36d15a6ec2
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,12 @@
import com.google.bigtable.admin.v2.CheckConsistencyResponse;
import com.google.bigtable.admin.v2.GenerateConsistencyTokenRequest;
import com.google.bigtable.admin.v2.GenerateConsistencyTokenResponse;
import com.google.bigtable.admin.v2.StandardReadRemoteWrites;
import com.google.bigtable.admin.v2.TableName;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.TimeUnit;

import com.google.cloud.bigtable.admin.v2.models.ConsistencyRequest;
import com.google.cloud.bigtable.data.v2.internal.RequestContext;
import org.junit.Before;
import org.junit.Rule;
Expand All @@ -48,7 +51,7 @@
import org.threeten.bp.Duration;

@RunWith(JUnit4.class)
public class AwaitReplicationCallableTest {
public class AwaitConsistencyCallableTest {
@Rule public MockitoRule mockitoRule = MockitoJUnit.rule().strictness(Strictness.WARN);

private static final String PROJECT_ID = "my-project";
Expand All @@ -68,6 +71,8 @@ public class AwaitReplicationCallableTest {

private AwaitReplicationCallable callable;

private AwaitConsistencyCallable awaitConsistencyCallable;

@Before
public void setUp() {
ClientContext clientContext =
Expand All @@ -86,8 +91,8 @@ public void setUp() {
.setRpcTimeoutMultiplier(1.0)
.build();

AwaitConsistencyCallable awaitConsistencyCallable = AwaitConsistencyCallable.create(
mockGenerateConsistencyTokenCallable, mockCheckConsistencyCallable, clientContext, retrySettings, REQUEST_CONTEXT);
awaitConsistencyCallable = AwaitConsistencyCallable.create(mockGenerateConsistencyTokenCallable,
mockCheckConsistencyCallable, clientContext, retrySettings, REQUEST_CONTEXT);
callable =
AwaitReplicationCallable.create(awaitConsistencyCallable);
}
Expand Down Expand Up @@ -128,14 +133,16 @@ public void testCheckFailure() throws Exception {
CheckConsistencyRequest.newBuilder()
.setName(TABLE_NAME.toString())
.setConsistencyToken("fake-token")
.setStandardReadRemoteWrites(StandardReadRemoteWrites.newBuilder().build())
.build();

FakeApiException expectedError = new FakeApiException("fake", null, Code.INTERNAL, false);

Mockito.when(mockCheckConsistencyCallable.futureCall(expectedRequest2, CALL_CONTEXT))
.thenReturn(ApiFutures.<CheckConsistencyResponse>immediateFailedFuture(expectedError));

ApiFuture<Void> future = callable.futureCall(TABLE_NAME, CALL_CONTEXT);
ConsistencyRequest consistencyRequest = ConsistencyRequest.getStandardConsistencyRequest(TABLE_ID);
ApiFuture<Void> future = awaitConsistencyCallable.futureCall(consistencyRequest, CALL_CONTEXT);

Throwable actualError = null;

Expand Down Expand Up @@ -163,14 +170,16 @@ public void testImmediatelyConsistent() throws Exception {
CheckConsistencyRequest.newBuilder()
.setName(TABLE_NAME.toString())
.setConsistencyToken("fake-token")
.setStandardReadRemoteWrites(StandardReadRemoteWrites.newBuilder().build())
.build();
CheckConsistencyResponse expectedResponse2 =
CheckConsistencyResponse.newBuilder().setConsistent(true).build();

Mockito.when(mockCheckConsistencyCallable.futureCall(expectedRequest2, CALL_CONTEXT))
.thenReturn(ApiFutures.immediateFuture(expectedResponse2));

ApiFuture<Void> consistentFuture = callable.futureCall(TABLE_NAME, CALL_CONTEXT);
ConsistencyRequest consistencyRequest = ConsistencyRequest.getStandardConsistencyRequest(TABLE_ID);
ApiFuture<Void> consistentFuture = awaitConsistencyCallable.futureCall(consistencyRequest, CALL_CONTEXT);

consistentFuture.get(1, TimeUnit.MILLISECONDS);
}
Expand All @@ -190,6 +199,7 @@ public void testPolling() throws Exception {
CheckConsistencyRequest.newBuilder()
.setName(TABLE_NAME.toString())
.setConsistencyToken("fake-token")
.setStandardReadRemoteWrites(StandardReadRemoteWrites.newBuilder().build())
.build();

CheckConsistencyResponse expectedResponse2 =
Expand All @@ -202,7 +212,8 @@ public void testPolling() throws Exception {
.thenReturn(ApiFutures.immediateFuture(expectedResponse2))
.thenReturn(ApiFutures.immediateFuture(expectedResponse3));

ApiFuture<Void> consistentFuture = callable.futureCall(TABLE_NAME, CALL_CONTEXT);
ConsistencyRequest consistencyRequest = ConsistencyRequest.getStandardConsistencyRequest(TABLE_ID);
ApiFuture<Void> consistentFuture = awaitConsistencyCallable.futureCall(consistencyRequest, CALL_CONTEXT);

consistentFuture.get(1, TimeUnit.SECONDS);
}
Expand All @@ -222,6 +233,7 @@ public void testPollingTimeout() throws Exception {
CheckConsistencyRequest.newBuilder()
.setName(TABLE_NAME.toString())
.setConsistencyToken("fake-token")
.setStandardReadRemoteWrites(StandardReadRemoteWrites.newBuilder().build())
.build();

CheckConsistencyResponse expectedResponse2 =
Expand All @@ -230,7 +242,8 @@ public void testPollingTimeout() throws Exception {
Mockito.when(mockCheckConsistencyCallable.futureCall(expectedRequest2, CALL_CONTEXT))
.thenReturn(ApiFutures.immediateFuture(expectedResponse2));

ApiFuture<Void> consistentFuture = callable.futureCall(TABLE_NAME, CALL_CONTEXT);
ConsistencyRequest consistencyRequest = ConsistencyRequest.getStandardConsistencyRequest(TABLE_ID);
ApiFuture<Void> consistentFuture = awaitConsistencyCallable.futureCall(consistencyRequest, CALL_CONTEXT);

Throwable actualError = null;
try {
Expand Down