Skip to content

Commit 055c00f

Browse files
olavloitekolea2
authored andcommitted
---
yaml --- r: 23751 b: refs/heads/autosynth-firestore c: 7a9f3fe h: refs/heads/master i: 23749: 5f7f83d 23747: f795e25 23743: 03c2929
1 parent 87c2ae8 commit 055c00f

2 files changed

Lines changed: 13 additions & 1 deletion

File tree

  • branches/autosynth-firestore/google-cloud-clients/google-cloud-spanner/src/test/java/com/google/cloud/spanner

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ refs/heads/autosynth-containeranalysis: af5b804492292b43372c9fe00386696136ccae89
130130
refs/heads/autosynth-datastore: d0fc1187000c7a50d8bddd89c3b7cdf1187ecb96
131131
refs/heads/autosynth-dialogflow: cb1ceeb3ec1a132d3096fc88d44b930a52130e18
132132
refs/heads/autosynth-errorreporting: 3f176c20b55dfaaa8fc32f28d82b31784b93e636
133-
refs/heads/autosynth-firestore: e706ba1d72589cb73ca3cdb6fcdf039b42698da6
133+
refs/heads/autosynth-firestore: 7a9f3fe52a3838ad3b743f8c5664e2f27f8d7b5c
134134
refs/heads/autosynth-iot: f03bdd338a9056ca3b7ea6d9ca901649ba9aab78
135135
refs/heads/autosynth-kms: 2828edfe3d2c53dd6e71912eae8a53c87bf40c87
136136
refs/heads/autosynth-language: c3d990dd34d81e7e935041e7147fb9dd27f8a557

branches/autosynth-firestore/google-cloud-clients/google-cloud-spanner/src/test/java/com/google/cloud/spanner/GceTestEnvConfig.java

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818

1919
import static com.google.common.base.Preconditions.checkState;
2020

21+
import com.google.auth.oauth2.GoogleCredentials;
2122
import com.google.cloud.spanner.spi.v1.SpannerInterceptorProvider;
2223
import io.grpc.CallOptions;
2324
import io.grpc.Channel;
@@ -28,13 +29,16 @@
2829
import io.grpc.Metadata;
2930
import io.grpc.MethodDescriptor;
3031
import io.grpc.Status;
32+
import java.io.FileInputStream;
33+
import java.io.IOException;
3134
import java.util.Random;
3235
import java.util.concurrent.atomic.AtomicBoolean;
3336

3437
/** Configure TestEnv based on configuration provided. */
3538
public class GceTestEnvConfig implements TestEnvConfig {
3639
public static final String GCE_PROJECT_ID = "spanner.gce.config.project_id";
3740
public static final String GCE_SERVER_URL = "spanner.gce.config.server_url";
41+
public static final String GCE_CREDENTIALS_FILE = "spanner.gce.config.credentials_file";
3842
public static final String GCE_STREAM_BROKEN_PROBABILITY =
3943
"spanner.gce.config.stream_broken_probability";
4044

@@ -43,6 +47,7 @@ public class GceTestEnvConfig implements TestEnvConfig {
4347
public GceTestEnvConfig() {
4448
String projectId = System.getProperty(GCE_PROJECT_ID, "");
4549
String serverUrl = System.getProperty(GCE_SERVER_URL, "");
50+
String credentialsFile = System.getProperty(GCE_CREDENTIALS_FILE, "");
4651
double errorProbability =
4752
Double.parseDouble(System.getProperty(GCE_STREAM_BROKEN_PROBABILITY, "0.0"));
4853
checkState(errorProbability <= 1.0);
@@ -53,6 +58,13 @@ public GceTestEnvConfig() {
5358
if (!serverUrl.isEmpty()) {
5459
builder.setHost(serverUrl);
5560
}
61+
if (!credentialsFile.isEmpty()) {
62+
try {
63+
builder.setCredentials(GoogleCredentials.fromStream(new FileInputStream(credentialsFile)));
64+
} catch (IOException e) {
65+
throw new RuntimeException(e);
66+
}
67+
}
5668
options =
5769
builder
5870
.setInterceptorProvider(

0 commit comments

Comments
 (0)