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
… also sync the test proto to its latest version
  • Loading branch information
liujiongxin committed Oct 25, 2023
1 parent 0830fa5 commit 675fe02
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 675fe02

Please sign in to comment.