@@ -8,7 +8,6 @@ import com.datadog.appsec.php.model.Span
88import org.junit.jupiter.api.BeforeAll
99import org.junit.jupiter.api.Test
1010import org.junit.jupiter.api.condition.EnabledIf
11- import org.testcontainers.containers.wait.strategy.HostPortWaitStrategy
1211import org.testcontainers.containers.wait.strategy.WaitStrategy
1312import org.testcontainers.containers.wait.strategy.WaitStrategyTarget
1413import org.testcontainers.junit.jupiter.Container
@@ -23,7 +22,6 @@ import static com.datadog.appsec.php.integration.TestParams.getVariant
2322import static com.datadog.appsec.php.integration.TestParams.phpVersionAtLeast
2423import static com.datadog.appsec.php.test.JsonMatcher.matchesJson
2524import static java.net.http.HttpResponse.BodyHandlers.ofString
26- import static java.time.temporal.ChronoUnit.SECONDS
2725import static org.hamcrest.MatcherAssert.assertThat
2826
2927@Testcontainers
@@ -45,7 +43,9 @@ class RoadRunnerTests {
4543 phpVariant : variant,
4644 www : ' roadrunner' ,
4745 ). with {
48- // we only start listening on http after run.sh has finished
46+ // we only start listening on http after run.sh has finished,
47+ // so mark immediately the container as ready. We instead check for liveliness
48+ // in beforeAll()
4949 setWaitStrategy(new WaitStrategy () {
5050 @Override
5151 void waitUntilReady (WaitStrategyTarget waitStrategyTarget ) {
@@ -62,7 +62,14 @@ class RoadRunnerTests {
6262
6363 @BeforeAll
6464 static void beforeAll () {
65- new HostPortWaitStrategy (). withStartupTimeout(Duration . of(300 , SECONDS ) ). waitUntilReady(CONTAINER )
65+ // wait until roadrunner is running
66+ long deadline = System . currentTimeMillis() + 300_000
67+ while (CONTAINER . execInContainer(' grep' , ' http server was started' , ' /tmp/logs/rr.log' ). exitCode != 0 ) {
68+ if (System . currentTimeMillis() > deadline) {
69+ throw new RuntimeException (' Roadrunner did not start on time (see output of run.sh)' )
70+ }
71+ Thread . sleep(500 )
72+ }
6673 }
6774
6875 @Test
0 commit comments