From 7a6dcbba9293a844501dd699e88f7c2e103ad72d Mon Sep 17 00:00:00 2001 From: Martin Ocenas Date: Wed, 20 Nov 2024 13:31:30 +0100 Subject: [PATCH] Retry container launch if failed --- .../services/containers/DockerContainerManagedResource.java | 3 +++ 1 file changed, 3 insertions(+) diff --git a/quarkus-test-containers/src/main/java/io/quarkus/test/services/containers/DockerContainerManagedResource.java b/quarkus-test-containers/src/main/java/io/quarkus/test/services/containers/DockerContainerManagedResource.java index 3c56173a8..622bdd22d 100644 --- a/quarkus-test-containers/src/main/java/io/quarkus/test/services/containers/DockerContainerManagedResource.java +++ b/quarkus-test-containers/src/main/java/io/quarkus/test/services/containers/DockerContainerManagedResource.java @@ -25,6 +25,7 @@ import io.quarkus.test.bootstrap.ManagedResource; import io.quarkus.test.bootstrap.Protocol; import io.quarkus.test.bootstrap.ServiceContext; +import io.quarkus.test.configuration.PropertyLookup; import io.quarkus.test.logging.Log; import io.quarkus.test.logging.LoggingHandler; import io.quarkus.test.logging.TestContainersLoggingHandler; @@ -37,6 +38,7 @@ public abstract class DockerContainerManagedResource implements ManagedResource public static final String DOCKER_INNER_CONTAINER = DockerContainerManagedResource.class.getName() + "_inner"; private static final String DELETE_IMAGE_ON_STOP_PROPERTY = "container.delete.image.on.stop"; private static final String TARGET = "target"; + private static final PropertyLookup CONTAINER_STARTUP_ATTEMPTS = new PropertyLookup("container-startup-attempts", "1"); private final ServiceContext context; @@ -65,6 +67,7 @@ public void start() { innerContainer.withStartupTimeout(context.getOwner().getConfiguration() .getAsDuration(SERVICE_STARTUP_TIMEOUT, SERVICE_STARTUP_TIMEOUT_DEFAULT)); innerContainer.withEnv(resolveProperties()); + innerContainer.withStartupAttempts(CONTAINER_STARTUP_ATTEMPTS.getAsInteger()); loggingHandler = new TestContainersLoggingHandler(context.getOwner(), innerContainer); loggingHandler.startWatching();