From 7e63df335ab35ba95c79d7b2f2d9da3d88b78e5d Mon Sep 17 00:00:00 2001 From: ndr_brt Date: Mon, 23 Sep 2024 08:48:01 +0200 Subject: [PATCH] ci: fix postgres flaky tests --- .github/workflows/verify.yaml | 8 -------- .../tractusx/edc/tests/runtimes/PgRuntimeExtension.java | 7 ++++++- 2 files changed, 6 insertions(+), 9 deletions(-) diff --git a/.github/workflows/verify.yaml b/.github/workflows/verify.yaml index 6596f4f0b..16c648237 100644 --- a/.github/workflows/verify.yaml +++ b/.github/workflows/verify.yaml @@ -123,14 +123,6 @@ jobs: postgres-tests: runs-on: ubuntu-latest - services: - postgres: - image: postgres:16.1 - ports: - - 5432:5432 - env: - POSTGRES_PASSWORD: password - steps: - uses: actions/checkout@v4 - uses: ./.github/actions/setup-java diff --git a/edc-tests/edc-controlplane/fixtures/src/testFixtures/java/org/eclipse/tractusx/edc/tests/runtimes/PgRuntimeExtension.java b/edc-tests/edc-controlplane/fixtures/src/testFixtures/java/org/eclipse/tractusx/edc/tests/runtimes/PgRuntimeExtension.java index 6719c0a57..8e0a0186b 100644 --- a/edc-tests/edc-controlplane/fixtures/src/testFixtures/java/org/eclipse/tractusx/edc/tests/runtimes/PgRuntimeExtension.java +++ b/edc-tests/edc-controlplane/fixtures/src/testFixtures/java/org/eclipse/tractusx/edc/tests/runtimes/PgRuntimeExtension.java @@ -19,12 +19,15 @@ package org.eclipse.tractusx.edc.tests.runtimes; +import com.github.dockerjava.api.model.ExposedPort; +import org.eclipse.edc.util.io.Ports; import org.junit.jupiter.api.extension.ExtensionContext; import org.testcontainers.containers.PostgreSQLContainer; import org.testcontainers.containers.wait.strategy.Wait; import java.sql.DriverManager; import java.sql.SQLException; +import java.util.List; import java.util.Map; import static java.lang.String.format; @@ -45,10 +48,12 @@ public PgRuntimeExtension(String moduleName, String runtimeName, String bpn, Map this.dbName = runtimeName.toLowerCase(); postgreSqlContainer = new PostgreSQLContainer<>(POSTGRES_IMAGE_NAME) .withLabel("runtime", dbName) - .withExposedPorts(5432) .withUsername(USER) .withPassword(PASSWORD) .withDatabaseName(dbName); + + postgreSqlContainer.setPortBindings(List.of("%d:5432".formatted(Ports.getFreePort()))); + } @Override