Skip to content

Commit

Permalink
test: add test to ensure that feature flags are sent during a ping an…
Browse files Browse the repository at this point in the history
…d warm rpc (#2425)


Change-Id: I7d8ac74eae66d34de453b0cd799f45474d6ff0f7

Thank you for opening a Pull Request! Before submitting your PR, there are a few things you can do to make sure it goes smoothly:
- [ ] Make sure to open an issue as a [bug/issue](https://togithub.com/googleapis/java-bigtable/issues/new/choose) before writing your code!  That way we can discuss the change, evaluate designs, and agree on the general idea
- [ ] Ensure the tests and linter pass
- [ ] Code coverage does not decrease (if any source code was changed)
- [ ] Appropriate docs were updated (if necessary)
- [ ] Rollback plan is reviewed and LGTMed
- [ ] All new data plane features have a completed end to end testing plan

Fixes #<issue_number_goes_here> ☕️

If you write sample code, please follow the [samples format](
https://togithub.com/GoogleCloudPlatform/java-docs-samples/blob/main/SAMPLE_FORMAT.md).
  • Loading branch information
igorbernstein2 authored Dec 3, 2024
1 parent 7b6e3be commit e1c7804
Showing 1 changed file with 23 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@
import com.google.cloud.bigtable.data.v2.stub.metrics.NoopMetricsProvider;
import com.google.cloud.bigtable.data.v2.stub.sql.ExecuteQueryCallable;
import com.google.cloud.bigtable.data.v2.stub.sql.SqlServerStream;
import com.google.common.base.Preconditions;
import com.google.common.collect.ImmutableMap;
import com.google.common.collect.Queues;
import com.google.common.io.BaseEncoding;
Expand Down Expand Up @@ -285,6 +286,28 @@ public void testFeatureFlags() throws InterruptedException, IOException, Executi
assertThat(featureFlags.getLastScannedRowResponses()).isTrue();
}

@Test
public void testPingAndWarmFeatureFlags()
throws InterruptedException, IOException, ExecutionException {
EnhancedBigtableStubSettings settings =
defaultSettings.toBuilder().setRefreshingChannel(true).build();
try (EnhancedBigtableStub ignored = EnhancedBigtableStub.create(settings)) {
Preconditions.checkState(
!fakeDataService.pingRequests.isEmpty(), "Ping request was not sent during setup");
Metadata metadata = metadataInterceptor.headers.take();

String encodedFeatureFlags =
metadata.get(Key.of("bigtable-features", Metadata.ASCII_STRING_MARSHALLER));
FeatureFlags featureFlags =
FeatureFlags.parseFrom(BaseEncoding.base64Url().decode(encodedFeatureFlags));

assertThat(featureFlags.getReverseScans()).isTrue();
assertThat(featureFlags.getLastScannedRowResponses()).isTrue();
assertThat(featureFlags.getRoutingCookie()).isTrue();
assertThat(featureFlags.getRetryInfo()).isTrue();
}
}

@Test
public void testCheckAndMutateRequestResponseConversion()
throws ExecutionException, InterruptedException {
Expand Down

0 comments on commit e1c7804

Please sign in to comment.