Skip to content

Commit a4a524d

Browse files
committed
fix flaky test
1 parent b392e3c commit a4a524d

1 file changed

Lines changed: 13 additions & 7 deletions

File tree

spawn-docker-jdk/src/test/java/build/spawn/docker/jdk/SessionTests.java

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -636,10 +636,10 @@ void shouldCopyAFileToAContainer()
636636

637637
try (var session = createSession()) {
638638
final var image = session.images()
639-
.get(RABBITMQ_IMAGE)
639+
.get(ALPINE_IMAGE)
640640
.orElseThrow(() -> new AssertionError("Failed to get the required image"));
641641

642-
try (var container = image.start()) {
642+
try (var container = image.start(Command.of("sleep", "60"))) {
643643

644644
Eventually.assertThat(container.onStart())
645645
.isCompleted();
@@ -650,13 +650,19 @@ void shouldCopyAFileToAContainer()
650650
assertThat(container.id())
651651
.isNotNull();
652652

653-
// create a /tmp/test folder in the container
654-
Eventually.assertThat(container
655-
.createExecutable("mkdir", "/tmp/test")
656-
.execute()
657-
.onExit())
653+
// create a /tmp/test folder in the container; withTerminal(true) ensures Detach:false so
654+
// onExit() tracks actual process completion rather than just exec launch
655+
final var mkdirExecution = container
656+
.createExecutable("mkdir", "/tmp/test")
657+
.withTerminal(true)
658+
.execute();
659+
660+
Eventually.assertThat(mkdirExecution.onExit())
658661
.isCompleted();
659662

663+
assertThat(mkdirExecution.exitValue().getAsInt())
664+
.isEqualTo(0);
665+
660666
// establish a temporary folder and a temporary file in the folder, tar the folder and send it to the
661667

662668
// Create temp dir and a file inside it

0 commit comments

Comments
 (0)