Skip to content

Commit

Permalink
test(fix): update the test proxy to set app profile id and connect to…
Browse files Browse the repository at this point in the history
… emulator correctly (#1529)

This change makes the test proxy work with the hermetic testing that exercises app_profile_id and emulator (https://togithub.com/googleapis/cloud-bigtable-clients-test)
  • Loading branch information
liujiongxin committed Nov 22, 2022
1 parent c5bcc66 commit 524184d
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 9 deletions.
Expand Up @@ -215,7 +215,12 @@ public synchronized void createClient(
return;
}

BigtableDataSettings.Builder settingsBuilder = BigtableDataSettings.newBuilder();
BigtableDataSettings.Builder settingsBuilder =
BigtableDataSettings.newBuilder()
.setProjectId(request.getProjectId())
.setInstanceId(request.getInstanceId())
.setAppProfileId(request.getAppProfileId());

if (request.hasPerOperationTimeout()) {
Duration newTimeout = Duration.ofMillis(Durations.toMillis(request.getPerOperationTimeout()));
settingsBuilder = overrideTimeoutSetting(newTimeout, settingsBuilder);
Expand All @@ -227,13 +232,13 @@ public synchronized void createClient(

// Create and store CbtClient for later use
try {
settingsBuilder
.setProjectId(request.getProjectId())
.setInstanceId(request.getInstanceId())
.stubSettings()
.setEndpoint(request.getDataTarget())
.setTransportChannelProvider(getTransportChannel())
.setCredentialsProvider(getCredentialsProvider());
if (!request.getDataTarget().equals("emulator")) {
settingsBuilder
.stubSettings()
.setEndpoint(request.getDataTarget())
.setTransportChannelProvider(getTransportChannel())
.setCredentialsProvider(getCredentialsProvider());
}
BigtableDataSettings settings = settingsBuilder.build();
BigtableDataClient client = BigtableDataClient.create(settings);
CbtClient cbtClient = CbtClient.create(settings, client);
Expand Down
4 changes: 3 additions & 1 deletion test-proxy/src/main/proto/v2_test_proxy.proto
Expand Up @@ -57,7 +57,9 @@ option go_package = "./testproxypb";
message CreateClientRequest {
string client_id = 1;
// The "host:port" address of the data API endpoint (i.e. the backend being
// proxied to). Example: 127.0.0.1:38543
// proxied to). Example: 127.0.0.1:38543. If you want to connect to a local
// emulator via BIGTABLE_EMULATOR_HOST environment variable, you can use
// "emulator" instead of "host:port" for this field.
string data_target = 2;
// The project for all calls on this client.
string project_id = 3;
Expand Down

0 comments on commit 524184d

Please sign in to comment.