Skip to content

Commit e149fa5

Browse files
committed
test: update TestBench to be graceful to an instance running outside the test suite
1 parent ea3f11e commit e149fa5

2 files changed

Lines changed: 15 additions & 0 deletions

File tree

google-cloud-storage/src/test/java/com/google/cloud/storage/it/runner/registry/TestBench.java

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,8 @@ public final class TestBench implements ManagedLifecycle {
106106
private Path outPath;
107107
private Path errPath;
108108

109+
private boolean runningOutsideAlready;
110+
109111
private TestBench(
110112
boolean ignorePullError,
111113
String baseUri,
@@ -199,6 +201,14 @@ public Object get() {
199201

200202
@Override
201203
public void start() {
204+
try {
205+
listRetryTests();
206+
LOGGER.info("Using testbench running outside test suite.");
207+
runningOutsideAlready = true;
208+
return;
209+
} catch (IOException ignore) {
210+
// expected when the server isn't running already
211+
}
202212
try {
203213
tempDirectory = Files.createTempDirectory(containerName);
204214
outPath = tempDirectory.resolve("stdout");
@@ -308,6 +318,10 @@ public boolean shouldRetry(
308318

309319
@Override
310320
public void stop() {
321+
if (runningOutsideAlready) {
322+
// if the server was running outside the tests already simply return
323+
return;
324+
}
311325
try {
312326
process.destroy();
313327
process.waitFor(2, TimeUnit.SECONDS);

google-cloud-storage/src/test/resources/logback.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,7 @@
8787
<logger name="com.google.cloud.storage" level="info"/>
8888
<logger name="com.google.cloud.storage.it" level="warn"/>
8989
<logger name="com.google.cloud.storage.it.runner.registry.Zone" level="info"/>
90+
<logger name="com.google.cloud.storage.it.runner.registry.TestBench" level="info"/>
9091

9192
<root level="info">
9293
<appender-ref ref="STDOUT"/>

0 commit comments

Comments
 (0)