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

test(fix): update the test proxy to allow enabling optional features,… #1976

Merged
merged 1 commit into from
Oct 26, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
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
Loading