Skip to content

Commit c5ef4c5

Browse files
author
Dhriti Chopra
committed
test(storage): support daemonized testbench container with keep-alive for concurrent forks
1 parent 1482328 commit c5ef4c5

2 files changed

Lines changed: 13 additions & 4 deletions

File tree

  • java-storage/google-cloud-storage

java-storage/google-cloud-storage/pom.xml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -460,6 +460,15 @@
460460
</dependency>
461461
</dependencies>
462462
</plugin>
463+
<plugin>
464+
<groupId>org.apache.maven.plugins</groupId>
465+
<artifactId>maven-failsafe-plugin</artifactId>
466+
<configuration>
467+
<systemPropertyVariables>
468+
<testbench.keepAlive>true</testbench.keepAlive>
469+
</systemPropertyVariables>
470+
</configuration>
471+
</plugin>
463472
</plugins>
464473
</build>
465474

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -252,7 +252,7 @@ public void start() {
252252
ImmutableList.of(
253253
"docker",
254254
"run",
255-
"-i",
255+
"-d",
256256
"--rm",
257257
"--publish",
258258
port + ":9000",
@@ -318,14 +318,14 @@ public boolean shouldRetry(
318318

319319
@Override
320320
public void stop() {
321-
if (runningOutsideAlready) {
322-
// if the server was running outside the tests already simply return
321+
if (runningOutsideAlready || Boolean.getBoolean("testbench.keepAlive")) {
322+
// if the server was running outside the tests already, or we want to keep it alive, simply return
323323
return;
324324
}
325325
try {
326326
process.destroy();
327327
process.waitFor(2, TimeUnit.SECONDS);
328-
boolean attemptForceStopContainer = false;
328+
boolean attemptForceStopContainer = true;
329329
try {
330330
int processExitValue = process.exitValue();
331331
if (processExitValue != 0) {

0 commit comments

Comments
 (0)