Skip to content

Commit 05ae627

Browse files
authored
Merge pull request #2821 from DataDog/glopes/fix-appsec-int-tests
Fix appsec integration tests
2 parents fca0ec2 + 6397d1a commit 05ae627

2 files changed

Lines changed: 15 additions & 4 deletions

File tree

appsec/tests/integration/build.gradle

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,9 @@ def buildRunInDockerTask = { Map options ->
157157
volumes['php-tracer-cargo-cache'] = [
158158
mountPoint: '/root/.cargo/registry',
159159
]
160+
volumes['php-tracer-cargo-cache-git'] = [
161+
mountPoint: '/root/.cargo/git',
162+
]
160163
}
161164

162165
def composerDlTask
@@ -443,6 +446,7 @@ task loadCaches(type: Exec) {
443446

444447
dependsOn downloadCaches
445448
dependsOn 'createVolume-php-tracer-cargo-cache'
449+
dependsOn 'createVolume-php-tracer-cargo-cache-git'
446450
dependsOn 'createVolume-php-appsec-hunter-cache'
447451
}
448452

appsec/tests/integration/src/test/groovy/com/datadog/appsec/php/integration/RoadRunnerTests.groovy

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ import com.datadog.appsec.php.model.Span
88
import org.junit.jupiter.api.BeforeAll
99
import org.junit.jupiter.api.Test
1010
import org.junit.jupiter.api.condition.EnabledIf
11-
import org.testcontainers.containers.wait.strategy.HostPortWaitStrategy
1211
import org.testcontainers.containers.wait.strategy.WaitStrategy
1312
import org.testcontainers.containers.wait.strategy.WaitStrategyTarget
1413
import org.testcontainers.junit.jupiter.Container
@@ -23,7 +22,6 @@ import static com.datadog.appsec.php.integration.TestParams.getVariant
2322
import static com.datadog.appsec.php.integration.TestParams.phpVersionAtLeast
2423
import static com.datadog.appsec.php.test.JsonMatcher.matchesJson
2524
import static java.net.http.HttpResponse.BodyHandlers.ofString
26-
import static java.time.temporal.ChronoUnit.SECONDS
2725
import 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

Comments
 (0)