From 054c7f7a19514398649fff114533ad92043b8e8a Mon Sep 17 00:00:00 2001 From: Florian Boulnois Date: Mon, 27 Jan 2025 09:27:27 -0500 Subject: [PATCH] fix: wait for listening ports --- .../org/broadinstitute/consent/http/db/DAOTestHelper.java | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/test/java/org/broadinstitute/consent/http/db/DAOTestHelper.java b/src/test/java/org/broadinstitute/consent/http/db/DAOTestHelper.java index dc8d3bf28..48d01da07 100644 --- a/src/test/java/org/broadinstitute/consent/http/db/DAOTestHelper.java +++ b/src/test/java/org/broadinstitute/consent/http/db/DAOTestHelper.java @@ -12,8 +12,8 @@ import java.util.Random; import java.util.UUID; import org.apache.commons.lang3.RandomStringUtils; -import org.broadinstitute.consent.http.ConsentApplication; import org.broadinstitute.consent.http.AbstractTestHelper; +import org.broadinstitute.consent.http.ConsentApplication; import org.broadinstitute.consent.http.configurations.ConsentConfiguration; import org.broadinstitute.consent.http.enumeration.OrganizationType; import org.broadinstitute.consent.http.enumeration.UserFields; @@ -33,6 +33,7 @@ import org.junit.jupiter.api.AfterEach; import org.junit.jupiter.api.BeforeAll; import org.testcontainers.containers.PostgreSQLContainer; +import org.testcontainers.containers.wait.strategy.Wait; public class DAOTestHelper extends AbstractTestHelper { @@ -74,7 +75,8 @@ public class DAOTestHelper extends AbstractTestHelper { public static void startUp() throws Exception { // Start the database postgresContainer = new PostgreSQLContainer<>(POSTGRES_IMAGE). - withCommand("postgres -c max_connections=" + maxConnections); + withCommand("postgres -c max_connections=" + maxConnections). + waitingFor(Wait.forListeningPorts()); postgresContainer.start(); ConfigOverride driverOverride = ConfigOverride.config("database.driverClass", postgresContainer.getDriverClassName());