From 59f11a34f77f6b1fbfa59d992e71028582590b9c Mon Sep 17 00:00:00 2001 From: Tobias Gesellchen Date: Thu, 29 Aug 2024 00:24:18 +0200 Subject: [PATCH] Override the default WaitStrategy (HostPortWaitStrategy), which doesn't work on Windows, yet. See the InternalCommandPortListeningCheck. --- .../utility/ResourceReaperTest.java | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/core/src/test/java/org/testcontainers/utility/ResourceReaperTest.java b/core/src/test/java/org/testcontainers/utility/ResourceReaperTest.java index dec7115ca95..dadc7198c62 100644 --- a/core/src/test/java/org/testcontainers/utility/ResourceReaperTest.java +++ b/core/src/test/java/org/testcontainers/utility/ResourceReaperTest.java @@ -8,6 +8,7 @@ import org.junit.Test; import org.testcontainers.DockerClientFactory; import org.testcontainers.containers.GenericContainer; +import org.testcontainers.containers.wait.strategy.AbstractWaitStrategy; import org.zeroturnaround.exec.ProcessExecutor; import org.zeroturnaround.exec.ProcessResult; @@ -105,7 +106,22 @@ public static void main(String[] args) { GenericContainer container = new GenericContainer<>("testcontainers/helloworld:sha-141af7909907e04b124e691d3cd6fc7c32da2207") .withNetwork(org.testcontainers.containers.Network.newNetwork()) - .withExposedPorts(8080); + .withExposedPorts(8080) + + // Override the default WaitStrategy (HostPortWaitStrategy), + // which doesn't work on Windows, yet. + // See the InternalCommandPortListeningCheck. + .waitingFor(new AbstractWaitStrategy(){ + + @Override + protected void waitUntilReady() { + try { + Thread.sleep(1000); + } catch (InterruptedException e) { + throw new RuntimeException(e); + } + } + }); container.start(); }