Skip to content

Commit 20340db

Browse files
author
Dhriti Chopra
committed
Configure detached docker mode and 10min failsafe timeout
1 parent fb67722 commit 20340db

1 file changed

Lines changed: 8 additions & 23 deletions

File tree

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

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

Lines changed: 8 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -254,7 +254,7 @@ public void start() {
254254
ImmutableList.of(
255255
"docker",
256256
"run",
257-
"-i",
257+
"-d",
258258
"--rm",
259259
"--publish",
260260
port + ":9000",
@@ -325,28 +325,13 @@ public void stop() {
325325
return;
326326
}
327327
try {
328-
process.destroy();
329-
process.waitFor(2, TimeUnit.SECONDS);
330-
boolean attemptForceStopContainer = false;
331-
try {
332-
int processExitValue = process.exitValue();
333-
if (processExitValue != 0) {
334-
attemptForceStopContainer = true;
335-
}
336-
LOGGER.warn("Container exit value = {}", processExitValue);
337-
} catch (IllegalThreadStateException e) {
338-
attemptForceStopContainer = true;
339-
}
340-
341-
if (attemptForceStopContainer) {
342-
LOGGER.warn("Container did not gracefully exit, attempting to explicitly stop it.");
343-
ImmutableList<String> command = ImmutableList.of("docker", "kill", containerName);
344-
LOGGER.warn(command.toString());
345-
Process shutdownProcess = new ProcessBuilder(command).start();
346-
shutdownProcess.waitFor(5, TimeUnit.SECONDS);
347-
int shutdownProcessExitValue = shutdownProcess.exitValue();
348-
LOGGER.warn("Container exit value = {}", shutdownProcessExitValue);
349-
}
328+
LOGGER.warn("Stopping container: {}", containerName);
329+
ImmutableList<String> killCommand = ImmutableList.of("docker", "kill", containerName);
330+
LOGGER.warn(killCommand.toString());
331+
Process shutdownProcess = new ProcessBuilder(killCommand).start();
332+
shutdownProcess.waitFor(5, TimeUnit.SECONDS);
333+
int shutdownProcessExitValue = shutdownProcess.exitValue();
334+
LOGGER.warn("Container exit value = {}", shutdownProcessExitValue);
350335

351336
// wait for the server to shutdown
352337
runWithRetries(

0 commit comments

Comments
 (0)