mirror of
https://github.com/spring-projects/spring-boot.git
synced 2026-09-17 12:09:16 +00:00
Polish "Improve Docker Compose ProcessRunner's handling of failure cases"
See gh-50963 Signed-off-by: Andy Wilkinson <andy.wilkinson@broadcom.com>
This commit is contained in:
+3
-5
@@ -17,10 +17,12 @@
|
|||||||
package org.springframework.boot.docker.compose.core;
|
package org.springframework.boot.docker.compose.core;
|
||||||
|
|
||||||
import java.nio.file.Files;
|
import java.nio.file.Files;
|
||||||
|
import java.nio.file.LinkOption;
|
||||||
import java.nio.file.Path;
|
import java.nio.file.Path;
|
||||||
import java.time.Duration;
|
import java.time.Duration;
|
||||||
import java.util.concurrent.atomic.AtomicReference;
|
import java.util.concurrent.atomic.AtomicReference;
|
||||||
|
|
||||||
|
import org.awaitility.Awaitility;
|
||||||
import org.junit.jupiter.api.Nested;
|
import org.junit.jupiter.api.Nested;
|
||||||
import org.junit.jupiter.api.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
import org.junit.jupiter.api.condition.DisabledOnOs;
|
import org.junit.jupiter.api.condition.DisabledOnOs;
|
||||||
@@ -75,11 +77,7 @@ class ProcessRunnerTests {
|
|||||||
}
|
}
|
||||||
}, "process-runner-interrupt-test");
|
}, "process-runner-interrupt-test");
|
||||||
runner.start();
|
runner.start();
|
||||||
long deadline = System.currentTimeMillis() + 5000;
|
Awaitility.await().until(() -> Files.exists(pidFile, LinkOption.NOFOLLOW_LINKS));
|
||||||
while (!Files.exists(pidFile) && System.currentTimeMillis() < deadline) {
|
|
||||||
Thread.sleep(50);
|
|
||||||
}
|
|
||||||
assertThat(pidFile).exists();
|
|
||||||
long pid = Long.parseLong(Files.readString(pidFile).trim());
|
long pid = Long.parseLong(Files.readString(pidFile).trim());
|
||||||
assertThat(ProcessHandle.of(pid)).isPresent().get().matches(ProcessHandle::isAlive);
|
assertThat(ProcessHandle.of(pid)).isPresent().get().matches(ProcessHandle::isAlive);
|
||||||
runner.interrupt();
|
runner.interrupt();
|
||||||
|
|||||||
Reference in New Issue
Block a user