@@ -103,6 +103,8 @@ public class DockerComposeContainer<SELF extends DockerComposeContainer<SELF>>
103103
104104 private final Map <String , WaitAllStrategy > waitStrategyMap = new ConcurrentHashMap <>();
105105
106+ private Duration startupTimeout = Duration .ofMinutes (30 );
107+
106108 private final SocatContainer ambassadorContainer = new SocatContainer ();
107109
108110 private final Map <String , List <Consumer <OutputFrame >>> logConsumers = new ConcurrentHashMap <>();
@@ -433,14 +435,14 @@ private String getServiceInstanceName(String serviceName) {
433435 /*
434436 * can have multiple wait strategies for a single container, e.g. if waiting on several ports
435437 * if no wait strategy is defined, the WaitAllStrategy will return immediately.
436- * The WaitAllStrategy uses an long timeout, because timeouts should be handled by the inner strategies.
438+ * The WaitAllStrategy uses the startup timeout for everything as a global maximum, but we expect timeouts to be handled by the inner strategies.
437439 */
438440 private void addWaitStrategy (String serviceInstanceName , @ NonNull WaitStrategy waitStrategy ) {
439441 final WaitAllStrategy waitAllStrategy = waitStrategyMap .computeIfAbsent (
440442 serviceInstanceName ,
441443 __ -> {
442444 return new WaitAllStrategy (WaitAllStrategy .Mode .WITH_MAXIMUM_OUTER_TIMEOUT )
443- .withStartupTimeout (Duration . ofMinutes ( 30 ) );
445+ .withStartupTimeout (startupTimeout );
444446 }
445447 );
446448 waitAllStrategy .withStrategy (waitStrategy );
@@ -598,6 +600,16 @@ public SELF withRemoveImages(RemoveImages removeImages) {
598600 return self ();
599601 }
600602
603+ /**
604+ * Set the maximum startup timeout all the waits set are bounded to.
605+ *
606+ * @return this instance. for chaining
607+ */
608+ public SELF withStartupTimeout (Duration startupTimeout ) {
609+ this .startupTimeout = startupTimeout ;
610+ return self ();
611+ }
612+
601613 public Optional <ContainerState > getContainerByServiceName (String serviceName ) {
602614 return Optional .ofNullable (serviceInstanceMap .get (serviceName ));
603615 }
0 commit comments