From cf5c0e888b3d443d65f316b1ea15a70d42ca0cc4 Mon Sep 17 00:00:00 2001 From: Holly Cummins Date: Mon, 17 Nov 2025 20:57:54 +0000 Subject: [PATCH 1/2] Use dev services instead of docker-maven-plugin for Postgresql --- .../jpa-postgresql-withxml/pom.xml | 84 -------------- .../src/main/resources/application.properties | 3 - integration-tests/jpa-postgresql/README.md | 8 +- integration-tests/jpa-postgresql/pom.xml | 106 ++++-------------- .../src/main/resources/application.properties | 3 - .../it/jpa/postgresql/ConfigOverrideTest.java | 43 +++++++ .../OverrideJdbcUrlBuildTimeConfigSource.java | 12 +- .../PostgresTestResourceLifecycleManager.java | 35 ++++++ integration-tests/main/pom.xml | 90 --------------- .../reactive-pg-client/README.md | 6 +- integration-tests/reactive-pg-client/pom.xml | 84 -------------- .../src/main/resources/application.properties | 4 - .../test/resources/application-tl.properties | 3 - .../smallrye-jwt-oidc-webapp/pom.xml | 79 ------------- .../src/main/resources/application.properties | 5 - 15 files changed, 118 insertions(+), 447 deletions(-) create mode 100644 integration-tests/jpa-postgresql/src/test/java/io/quarkus/it/jpa/postgresql/ConfigOverrideTest.java create mode 100644 integration-tests/jpa-postgresql/src/test/java/io/quarkus/it/jpa/postgresql/PostgresTestResourceLifecycleManager.java diff --git a/integration-tests/jpa-postgresql-withxml/pom.xml b/integration-tests/jpa-postgresql-withxml/pom.xml index f6337ae915ebb..b04d05c2909ab 100644 --- a/integration-tests/jpa-postgresql-withxml/pom.xml +++ b/integration-tests/jpa-postgresql-withxml/pom.xml @@ -13,10 +13,6 @@ Quarkus - Integration Tests - JPA - PostgreSQL with XML Module that contains JPA related tests running with the PostgreSQL database - - jdbc:postgresql://localhost:5431/hibernate_orm_test - - io.quarkus @@ -161,86 +157,6 @@ - - - docker-postgresql - - - start-containers - - - - - - io.fabric8 - docker-maven-plugin - - - - ${postgres.image} - postgresql - - - hibernate_orm_test - hibernate_orm_test - hibernate_orm_test - - - 5431:5432 - - - - - (?s)ready to accept connections.*ready to accept connections - - - - - - true - - - - docker-start - compile - - stop - start - - - - docker-stop - post-integration-test - - stop - - - - - - org.codehaus.mojo - exec-maven-plugin - - - docker-prune - generate-resources - - exec - - - ${docker-prune.location} - - - - - - - diff --git a/integration-tests/jpa-postgresql-withxml/src/main/resources/application.properties b/integration-tests/jpa-postgresql-withxml/src/main/resources/application.properties index cf1ca6dd837ee..71f102ed64eb7 100644 --- a/integration-tests/jpa-postgresql-withxml/src/main/resources/application.properties +++ b/integration-tests/jpa-postgresql-withxml/src/main/resources/application.properties @@ -1,6 +1,3 @@ -quarkus.datasource.username=hibernate_orm_test -quarkus.datasource.password=hibernate_orm_test -quarkus.datasource.jdbc.url=${postgres.url} quarkus.datasource.jdbc.max-size=8 quarkus.hibernate-orm.packages=io.quarkus.it.jpa.postgresql.defaultpu diff --git a/integration-tests/jpa-postgresql/README.md b/integration-tests/jpa-postgresql/README.md index 9ebd2900d52fe..43f394124aad4 100644 --- a/integration-tests/jpa-postgresql/README.md +++ b/integration-tests/jpa-postgresql/README.md @@ -4,7 +4,7 @@ By default, the tests of this module are disabled. -To run the tests in a standard JVM with PostgreSQL started as a Docker container, you can run the following command: +To run the tests in a standard JVM with PostgreSQL started as a Dev Service, you can run the following command: ``` mvn clean install -Dtest-containers -Dstart-containers @@ -16,12 +16,12 @@ Additionally, you can generate a native image and run the tests for this native mvn clean install -Dtest-containers -Dstart-containers -Dnative ``` -If you don't want to run PostgreSQL as a Docker container, you can start your own PostgreSQL server. It needs to listen on the default port and have a database called `hibernate_orm_test` accessible to the user `hibernate_orm_test` with the password `hibernate_orm_test`. +If you don't want to run PostgreSQL as a Dev Service, you can start your own PostgreSQL server. It needs to listen on the default port and have a database called `hibernate_orm_test` accessible to the user `hibernate_orm_test` with the password `hibernate_orm_test`. You can then run the tests as follows (either with `-Dnative` or not): ``` -mvn clean install -Dtest-containers +mvn clean install -Dtest-containers -Dpostgres.url=jdbc:postgresql://... ``` -If you have specific requirements, you can define a specific connection URL with `-Dpostgres.url=jdbc:postgresql://...`. +If you have specific requirements, you can also define a specific connection URL with `-Dpostgres.url=jdbc:postgresql://...`. diff --git a/integration-tests/jpa-postgresql/pom.xml b/integration-tests/jpa-postgresql/pom.xml index 15ad23679a3f8..17282a4a7b807 100644 --- a/integration-tests/jpa-postgresql/pom.xml +++ b/integration-tests/jpa-postgresql/pom.xml @@ -13,10 +13,6 @@ Quarkus - Integration Tests - JPA - PostgreSQL Module that contains JPA related tests running with the PostgreSQL database - - jdbc:postgresql://localhost:5431/hibernate_orm_test - - io.quarkus @@ -46,6 +42,28 @@ quarkus-junit5-internal test + + + + + + + org.testcontainers + postgresql + + + junit + junit + + + test + + + + junit + junit + ${junit4.version} + io.rest-assured rest-assured @@ -171,86 +189,6 @@ - - - docker-postgresql - - - start-containers - - - - - - io.fabric8 - docker-maven-plugin - - - - ${postgres.image} - postgresql - - - hibernate_orm_test - hibernate_orm_test - hibernate_orm_test - - - 5431:5432 - - - - - (?s)ready to accept connections.*ready to accept connections - - - - - - true - - - - docker-start - compile - - stop - start - - - - docker-stop - post-integration-test - - stop - - - - - - org.codehaus.mojo - exec-maven-plugin - - - docker-prune - generate-resources - - exec - - - ${docker-prune.location} - - - - - - - diff --git a/integration-tests/jpa-postgresql/src/main/resources/application.properties b/integration-tests/jpa-postgresql/src/main/resources/application.properties index acf94a1a9d6e4..31608a21a8d6b 100644 --- a/integration-tests/jpa-postgresql/src/main/resources/application.properties +++ b/integration-tests/jpa-postgresql/src/main/resources/application.properties @@ -1,6 +1,3 @@ -quarkus.datasource.username=hibernate_orm_test -quarkus.datasource.password=hibernate_orm_test -quarkus.datasource.jdbc.url=${postgres.url} quarkus.datasource.jdbc.max-size=8 quarkus.hibernate-orm.packages=io.quarkus.it.jpa.postgresql.defaultpu diff --git a/integration-tests/jpa-postgresql/src/test/java/io/quarkus/it/jpa/postgresql/ConfigOverrideTest.java b/integration-tests/jpa-postgresql/src/test/java/io/quarkus/it/jpa/postgresql/ConfigOverrideTest.java new file mode 100644 index 0000000000000..3288ee04d9f7a --- /dev/null +++ b/integration-tests/jpa-postgresql/src/test/java/io/quarkus/it/jpa/postgresql/ConfigOverrideTest.java @@ -0,0 +1,43 @@ +package io.quarkus.it.jpa.postgresql; + +import static org.hamcrest.Matchers.is; + +import java.util.Collections; +import java.util.List; +import java.util.Map; + +import org.junit.jupiter.api.Test; + +import io.quarkus.test.junit.QuarkusTest; +import io.quarkus.test.junit.QuarkusTestProfile; +import io.quarkus.test.junit.TestProfile; +import io.restassured.RestAssured; + +/* Exercises OverrideJdbcUrlBuildTimeConfigSource, which cannot coexist with dev services. */ +@TestProfile(ConfigOverrideTest.Profile.class) +@QuarkusTest +public class ConfigOverrideTest { + + @Test + public void base() { + RestAssured.when().get("/jpa/testfunctionality/base").then().body(is("OK")); + } + + public static class Profile implements QuarkusTestProfile { + @Override + public Map getConfigOverrides() { + // Disable dev services so we know we're connecting to the right database + return Map.of("quarkus.devservices.enabled", "false"); + } + + @Override + public String getConfigProfile() { + return "someotherprofile"; + } + + @Override + public List testResources() { + return Collections.singletonList(new TestResourceEntry(PostgresTestResourceLifecycleManager.class)); + } + } +} diff --git a/integration-tests/jpa-postgresql/src/test/java/io/quarkus/it/jpa/postgresql/OverrideJdbcUrlBuildTimeConfigSource.java b/integration-tests/jpa-postgresql/src/test/java/io/quarkus/it/jpa/postgresql/OverrideJdbcUrlBuildTimeConfigSource.java index 464fde7db28d3..3983633bb2c31 100644 --- a/integration-tests/jpa-postgresql/src/test/java/io/quarkus/it/jpa/postgresql/OverrideJdbcUrlBuildTimeConfigSource.java +++ b/integration-tests/jpa-postgresql/src/test/java/io/quarkus/it/jpa/postgresql/OverrideJdbcUrlBuildTimeConfigSource.java @@ -7,6 +7,7 @@ import org.eclipse.microprofile.config.ConfigProvider; import org.eclipse.microprofile.config.spi.ConfigSource; +import io.quarkus.runtime.configuration.ConfigUtils; import io.smallrye.config.Priorities; import io.smallrye.config.common.MapBackedConfigSource; @@ -23,6 +24,12 @@ public String getValue(final String propertyName) { return super.getValue(propertyName); } + boolean someotherprofile = ConfigUtils.isProfileActive("someotherprofile"); + // This config source should only kick in when the custom profile is active, or dev services get disabled for all tests + if (!someotherprofile) { + return super.getValue(propertyName); + } + boolean isBuildTime = false; for (ConfigSource configSource : ConfigProvider.getConfig().getConfigSources()) { if (configSource.getName().equals("PropertiesConfigSource[source=Build system]")) { @@ -31,10 +38,13 @@ public String getValue(final String propertyName) { } } + // Originally, the JDBC Extension queried the JDBC URL value at build time to either start or skip the DevService. In cases where the URL was an expansion, this would fail if the expansion is not available at build time. In the original issue, the JDBC URL was set as an expansion in Vault, only available at runtime. + // To simulate the original issue, the source sets quarkus.datasource.jdbc.url at build time, and sets it to an 'impossible' expansion. if (isBuildTime) { - return "${postgres.url}"; + return "${arbitrary.unavailable.value}"; } + // To keep things working, we can then either return nothing at runtime so that we default to the normal application config, or return valid config at runtime. return super.getValue(propertyName); } } diff --git a/integration-tests/jpa-postgresql/src/test/java/io/quarkus/it/jpa/postgresql/PostgresTestResourceLifecycleManager.java b/integration-tests/jpa-postgresql/src/test/java/io/quarkus/it/jpa/postgresql/PostgresTestResourceLifecycleManager.java new file mode 100644 index 0000000000000..52cd564311890 --- /dev/null +++ b/integration-tests/jpa-postgresql/src/test/java/io/quarkus/it/jpa/postgresql/PostgresTestResourceLifecycleManager.java @@ -0,0 +1,35 @@ +package io.quarkus.it.jpa.postgresql; + +import java.util.Map; + +import org.testcontainers.containers.PostgreSQLContainer; + +import io.quarkus.test.common.QuarkusTestResourceLifecycleManager; + +public class PostgresTestResourceLifecycleManager implements QuarkusTestResourceLifecycleManager { + + private static PostgreSQLContainer postgres; + + @SuppressWarnings("resource") + @Override + public Map start() { + postgres = new PostgreSQLContainer<>("postgres:14") // the exact value doesn't really matter here + .withDatabaseName("testdb") + .withUsername("test") + .withPassword("test"); + + postgres.start(); + + return Map.of("quarkus.datasource.jdbc.url", postgres.getJdbcUrl(), "quarkus.datasource.username", "test", + "quarkus.datasource.password", "test"); + } + + @Override + public void stop() { + + if (postgres != null) { + postgres.stop(); + } + } + +} diff --git a/integration-tests/main/pom.xml b/integration-tests/main/pom.xml index 2cee35253dd05..da293a8fa667f 100644 --- a/integration-tests/main/pom.xml +++ b/integration-tests/main/pom.xml @@ -545,14 +545,6 @@ test-containers - - postgresql - ${postgres.url} - hibernate_orm_test - hibernate_orm_test - - org.hibernate.dialect.PostgreSQLDialect - io.quarkus @@ -603,88 +595,6 @@ - - docker-postgresql - - - start-containers - - - - jdbc:postgresql://localhost:5431/hibernate_orm_test - - - - - io.fabric8 - docker-maven-plugin - - - - ${postgres.image} - postgresql - - - hibernate_orm_test - hibernate_orm_test - hibernate_orm_test - - - 5431:5432 - - - - - (?s)ready to accept connections.*ready to accept connections - - - - - - true - - - - docker-start - compile - - stop - start - - - - docker-stop - post-integration-test - - stop - - - - - - org.codehaus.mojo - exec-maven-plugin - - - docker-prune - generate-resources - - exec - - - ${docker-prune.location} - - - - - - - diff --git a/integration-tests/reactive-pg-client/README.md b/integration-tests/reactive-pg-client/README.md index 4e4b2c758d696..a2656e5f874c4 100644 --- a/integration-tests/reactive-pg-client/README.md +++ b/integration-tests/reactive-pg-client/README.md @@ -4,7 +4,7 @@ By default, the tests of this module are disabled. -To run the tests in a standard JVM with PostgreSQL started as a Docker container, you can run the following command: +To run the tests in a standard JVM with PostgreSQL started as a Dev Service, you can run the following command: ``` mvn clean install -Dtest-containers -Dstart-containers @@ -16,7 +16,7 @@ Additionally, you can generate a native image and run the tests for this native mvn clean install -Dtest-containers -Dstart-containers -Dnative ``` -If you don't want to run PostgreSQL as a Docker container, you can start your own PostgreSQL server. It needs to listen on port 5431 and have a database called `hibernate_orm_test` accessible to the user `hibernate_orm_test` with the password `hibernate_orm_test`. +If you don't want to run PostgreSQL as a Dev Service, you can start your own PostgreSQL server. You can then run the tests as follows (either with `-Dnative` or not): @@ -24,4 +24,4 @@ You can then run the tests as follows (either with `-Dnative` or not): mvn clean install -Dtest-containers ``` -If you have specific requirements, you can define a specific connection URL with `-Dreactive-postgres.url=vertx-reactive:postgresql://:5431/hibernate_orm_test`. +You will need to pass in properties with the details of the external service. For example, you can define a specific connection URL with `-Dreactive-postgres.url=vertx-reactive:postgresql://:5431/hibernate_orm_test`. diff --git a/integration-tests/reactive-pg-client/pom.xml b/integration-tests/reactive-pg-client/pom.xml index a18e0514a87ad..14e8880b3ba0c 100644 --- a/integration-tests/reactive-pg-client/pom.xml +++ b/integration-tests/reactive-pg-client/pom.xml @@ -14,10 +14,6 @@ Quarkus - Integration Tests - Reactive Pg Client - - vertx-reactive:postgresql://:5431/hibernate_orm_test - - io.quarkus @@ -154,86 +150,6 @@ - - - docker-postgresql - - - start-containers - - - - - - io.fabric8 - docker-maven-plugin - - - - ${postgres.image} - postgresql - - - hibernate_orm_test - hibernate_orm_test - hibernate_orm_test - - - 5431:5432 - - - - - (?s)ready to accept connections.*ready to accept connections - - - - - - true - - - - docker-start - compile - - stop - start - - - - docker-stop - post-integration-test - - stop - - - - - - org.codehaus.mojo - exec-maven-plugin - - - docker-prune - generate-resources - - exec - - - ${docker-prune.location} - - - - - - - diff --git a/integration-tests/reactive-pg-client/src/main/resources/application.properties b/integration-tests/reactive-pg-client/src/main/resources/application.properties index d852d3611c719..e69de29bb2d1d 100644 --- a/integration-tests/reactive-pg-client/src/main/resources/application.properties +++ b/integration-tests/reactive-pg-client/src/main/resources/application.properties @@ -1,4 +0,0 @@ -quarkus.datasource.db-kind=postgresql -quarkus.datasource.username=hibernate_orm_test -quarkus.datasource.password=hibernate_orm_test -quarkus.datasource.reactive.url=${reactive-postgres.url} diff --git a/integration-tests/reactive-pg-client/src/test/resources/application-tl.properties b/integration-tests/reactive-pg-client/src/test/resources/application-tl.properties index 54e42ebfd6ceb..f5d67b55e7f83 100644 --- a/integration-tests/reactive-pg-client/src/test/resources/application-tl.properties +++ b/integration-tests/reactive-pg-client/src/test/resources/application-tl.properties @@ -1,6 +1,3 @@ quarkus.datasource.db-kind=postgresql -quarkus.datasource.username=hibernate_orm_test -quarkus.datasource.password=hibernate_orm_test -quarkus.datasource.reactive.url=${reactive-postgres.url} quarkus.datasource.reactive.thread-local=true quarkus.log.category."io.quarkus.reactive.datasource".level=DEBUG diff --git a/integration-tests/smallrye-jwt-oidc-webapp/pom.xml b/integration-tests/smallrye-jwt-oidc-webapp/pom.xml index 1f41378df897c..3f25b0aebb88b 100644 --- a/integration-tests/smallrye-jwt-oidc-webapp/pom.xml +++ b/integration-tests/smallrye-jwt-oidc-webapp/pom.xml @@ -16,7 +16,6 @@ http://localhost:8180 - vertx-reactive:postgresql://:5431/oidc_db_token_state_manager_test @@ -214,84 +213,6 @@ - - - docker-keycloak - - - start-containers - - - - - - io.fabric8 - docker-maven-plugin - - - - ${postgres.image} - postgresql-db - - - oidc_db_token_state_manager_test_user - oidc_db_token_state_manager_test_pwd - oidc_db_token_state_manager_test - - - 5431:5432 - - - - - (?s)ready to accept connections.*ready to accept connections - - - - - true - - - - docker-start - compile - - stop - start - - - - docker-stop - post-integration-test - - stop - - - - - - org.codehaus.mojo - exec-maven-plugin - - - docker-prune - generate-resources - - exec - - - ${docker-prune.location} - - - - - - - diff --git a/integration-tests/smallrye-jwt-oidc-webapp/src/main/resources/application.properties b/integration-tests/smallrye-jwt-oidc-webapp/src/main/resources/application.properties index 5f911b150da87..87a959b5ee056 100644 --- a/integration-tests/smallrye-jwt-oidc-webapp/src/main/resources/application.properties +++ b/integration-tests/smallrye-jwt-oidc-webapp/src/main/resources/application.properties @@ -10,9 +10,4 @@ quarkus.oidc.application-type=web-app quarkus.keycloak.devservices.create-realm=false quarkus.keycloak.devservices.port=8180 -quarkus.datasource.db-kind=postgresql -quarkus.datasource.username=oidc_db_token_state_manager_test_user -quarkus.datasource.password=oidc_db_token_state_manager_test_pwd -quarkus.datasource.reactive.url=${reactive-postgres.url} - quarkus.log.category."org.htmlunit.css".level=FATAL From 3bb7ab356bd25839e152b43764a51834b24547f6 Mon Sep 17 00:00:00 2001 From: Holly Cummins Date: Fri, 21 Nov 2025 19:41:44 +0000 Subject: [PATCH 2/2] Tidy readmes and POMs --- integration-tests/jpa-postgresql/README.md | 4 ++-- integration-tests/jpa-postgresql/pom.xml | 5 ----- integration-tests/reactive-pg-client/README.md | 2 +- 3 files changed, 3 insertions(+), 8 deletions(-) diff --git a/integration-tests/jpa-postgresql/README.md b/integration-tests/jpa-postgresql/README.md index 43f394124aad4..d13b6d533b86d 100644 --- a/integration-tests/jpa-postgresql/README.md +++ b/integration-tests/jpa-postgresql/README.md @@ -21,7 +21,7 @@ If you don't want to run PostgreSQL as a Dev Service, you can start your own Pos You can then run the tests as follows (either with `-Dnative` or not): ``` -mvn clean install -Dtest-containers -Dpostgres.url=jdbc:postgresql://... +mvn clean install -Dtest-containers -Dquarkus.datasource.jdbc.url=jdbc:postgresql://... ``` -If you have specific requirements, you can also define a specific connection URL with `-Dpostgres.url=jdbc:postgresql://...`. +If you have specific requirements, you can also define a specific connection URL with `-Dquarkus.datasource.jdbc.url=jdbc:postgresql://...`. diff --git a/integration-tests/jpa-postgresql/pom.xml b/integration-tests/jpa-postgresql/pom.xml index 17282a4a7b807..ab4ff248cd472 100644 --- a/integration-tests/jpa-postgresql/pom.xml +++ b/integration-tests/jpa-postgresql/pom.xml @@ -42,11 +42,6 @@ quarkus-junit5-internal test - - - - - org.testcontainers postgresql diff --git a/integration-tests/reactive-pg-client/README.md b/integration-tests/reactive-pg-client/README.md index a2656e5f874c4..3375fbb077bf8 100644 --- a/integration-tests/reactive-pg-client/README.md +++ b/integration-tests/reactive-pg-client/README.md @@ -24,4 +24,4 @@ You can then run the tests as follows (either with `-Dnative` or not): mvn clean install -Dtest-containers ``` -You will need to pass in properties with the details of the external service. For example, you can define a specific connection URL with `-Dreactive-postgres.url=vertx-reactive:postgresql://:5431/hibernate_orm_test`. +You will need to pass in properties with the details of the external service. For example, you can define a specific connection URL with `-Dquarkus.datasource.reactive.url=vertx-reactive:postgresql://:5431/hibernate_orm_test`.