Skip to content

Commit 9340407

Browse files
authored
test: fix storage benchwrapper to not require an emulator (googleapis#7143)
* fix: don't force emulation for perf bench * fix: remove dead code * fix: null check
1 parent b8cb233 commit 9340407

2 files changed

Lines changed: 9 additions & 8 deletions

File tree

‎google-cloud-testing/storage-benchwrapper/src/main/java/com/google/cloud/benchwrapper/Main.java‎

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -30,13 +30,6 @@ public static void main(String[] args) throws Exception {
3030
}
3131

3232
String storageEmulatorHost = System.getenv("STORAGE_EMULATOR_HOST");
33-
if (storageEmulatorHost == null || storageEmulatorHost.equals("")) {
34-
// We could use system properties here too, but every other language uses
35-
// an environment variable called STORAGE_EMULATOR_HOST, so the
36-
// consistency is nice to maintain.
37-
System.err.println("Please set STORAGE_EMULATOR_HOST=localhost:8080");
38-
System.exit(1);
39-
}
4033

4134
System.out.println("Server starting up...");
4235

‎google-cloud-testing/storage-benchwrapper/src/main/java/com/google/cloud/benchwrapper/StorageBenchWrapperImpl.java‎

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,10 +32,18 @@ class StorageBenchWrapperImpl extends StorageBenchWrapperImplBase {
3232
private Storage client;
3333

3434
public StorageBenchWrapperImpl(String storageEmulatorHost) {
35-
client = StorageOptions.newBuilder()
35+
if (storageEmulatorHost == null || storageEmulatorHost.isEmpty()){
36+
System.out.println("Initializing client against live service...");
37+
client = StorageOptions.newBuilder()
38+
.build()
39+
.getService();
40+
} else {
41+
System.out.println("Initializing client against emulated service...");
42+
client = StorageOptions.newBuilder()
3643
.setHost("http://" + storageEmulatorHost)
3744
.build()
3845
.getService();
46+
}
3947
}
4048

4149
public void write(ObjectWrite request, StreamObserver<EmptyResponse> responseObserver) {

0 commit comments

Comments
 (0)