Skip to content

Commit

Permalink
test(fix): update the test proxy to allow enabling optional features,… (
Browse files Browse the repository at this point in the history
#1976)

… also sync the test proto to its latest version

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

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
liujiongxin authored Oct 26, 2023
1 parent 0830fa5 commit f251b37
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ public synchronized void createClient(

BigtableDataSettings.Builder settingsBuilder =
BigtableDataSettings.newBuilder()
// disable channel refreshing when creating an emulator
// Disable channel refreshing when not using the real server
.setRefreshingChannel(false)
.setProjectId(request.getProjectId())
.setInstanceId(request.getInstanceId())
Expand All @@ -217,6 +217,19 @@ public synchronized void createClient(
Durations.toString(request.getPerOperationTimeout())));
}

if (request.getOptionalFeatureConfig()
== OptionalFeatureConfig.OPTIONAL_FEATURE_CONFIG_ENABLE_ALL) {
logger.info("Enabling all the optional features");
try {
// Exception will be raised if Application Default Credentials is not found.
BigtableDataSettings.enableBuiltinMetrics();
} catch (IOException e) {
responseObserver.onError(Status.INTERNAL.withDescription(e.getMessage()).asException());
return;
}
settingsBuilder.stubSettings().bulkMutateRowsSettings().setServerInitiatedFlowControl(true);
}

// Create and store CbtClient for later use
try {
if (!request.getDataTarget().equals("emulator")) {
Expand Down
14 changes: 14 additions & 0 deletions test-proxy/src/main/proto/test_proxy.proto
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,16 @@ option go_package = "./testproxypb";
option java_multiple_files = true;
option java_package = "com.google.cloud.bigtable.testproxy";

// A config flag that dictates how the optional features should be enabled
// during the client creation. The optional features customize how the client
// interacts with the server, and are defined in
// https://github.com/googleapis/googleapis/blob/master/google/bigtable/v2/feature_flags.proto
enum OptionalFeatureConfig {
OPTIONAL_FEATURE_CONFIG_DEFAULT = 0;

OPTIONAL_FEATURE_CONFIG_ENABLE_ALL = 1;
}

// Request to test proxy service to create a client object.
message CreateClientRequest {
// A unique ID associated with the client object to be created.
Expand All @@ -52,6 +62,10 @@ message CreateClientRequest {
// the created client. Otherwise, the default timeout from the client library
// will be used. Note that the override applies to all the methods.
google.protobuf.Duration per_operation_timeout = 6;

// Optional config that dictates how the optional features should be enabled
// during the client creation. Please check the enum type's docstring above.
OptionalFeatureConfig optional_feature_config = 7;
}

// Response from test proxy service for CreateClientRequest.
Expand Down

0 comments on commit f251b37

Please sign in to comment.