Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -1219,6 +1219,10 @@ public SELF withClasspathResourceMapping(
*/
@Override
public SELF withStartupTimeout(Duration startupTimeout) {
if (getWaitStrategy() == DEFAULT_WAIT_STRATEGY) {
// DEFAULT_WAIT_STRATEGY is shared by all containers, so give this container its own instance
waitingFor(Wait.defaultWaitStrategy());
}
getWaitStrategy().withStartupTimeout(startupTimeout);
return self();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -279,6 +279,21 @@ void shouldRespectWaitStrategy() {
}
}

@Test
void shouldNotChangeStartupTimeoutOfOtherContainers() {
// Never started. Only sets a short timeout for itself.
new GenericContainer<>(TestImages.ALPINE_IMAGE).withStartupTimeout(Duration.ofSeconds(2));

// Default wait strategy. The port opens after 5 seconds.
try (
GenericContainer<?> container = new GenericContainer<>(TestImages.ALPINE_IMAGE)
.withExposedPorts(8080)
.withCommand("sh", "-c", "sleep 5; while true; do nc -l -p 8080; done")
) {
container.start();
}
}

@Test
void testStartupAttemptsDoesNotLeaveContainersRunningWhenWrongWaitStrategyIsUsed() {
try (
Expand Down
Loading