Skip to content

Commit caeda87

Browse files
committed
Use dev services instead of docker-maven-plugin for Postgresql
1 parent 9e380b4 commit caeda87

File tree

17 files changed

+118
-502
lines changed

17 files changed

+118
-502
lines changed

integration-tests/hibernate-orm-compatibility-5.6/postgresql/pom.xml

Lines changed: 0 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414
<name>Quarkus - Integration Tests - Hibernate ORM - Compatibility with databases meant for ORM 5.6 - PostgreSQL</name>
1515

1616
<properties>
17-
<postgres.url>jdbc:postgresql://localhost:5431/hibernate_orm_test</postgres.url>
1817
<!-- We test features in Hibernate ORM that are timezone-sensitive, e.g. ZoneOffsetDateTime normalization -->
1918
<surefire.argLine.additional>-Duser.timezone=Europe/Paris</surefire.argLine.additional>
2019
</properties>
@@ -199,57 +198,6 @@
199198
</activation>
200199
<build>
201200
<plugins>
202-
<plugin>
203-
<groupId>io.fabric8</groupId>
204-
<artifactId>docker-maven-plugin</artifactId>
205-
<configuration>
206-
<images>
207-
<image>
208-
<name>${postgres.image}</name>
209-
<alias>postgresql</alias>
210-
<run>
211-
<env>
212-
<POSTGRES_USER>hibernate_orm_test</POSTGRES_USER>
213-
<POSTGRES_PASSWORD>hibernate_orm_test</POSTGRES_PASSWORD>
214-
<POSTGRES_DB>hibernate_orm_test</POSTGRES_DB>
215-
</env>
216-
<ports>
217-
<port>5431:5432</port>
218-
</ports>
219-
<wait>
220-
<!-- For some reason, Postgres will tell us it's ready *twice*,
221-
and that's the truth the second time only.
222-
See https://github.com/fabric8io/docker-maven-plugin/issues/628
223-
See also how the condition is configured in testcontainers:
224-
https://github.com/testcontainers/testcontainers-java/blob/c64aab9fd5e3a452ee0faf793560327eb4da9841/modules/postgresql/src/main/java/org/testcontainers/containers/PostgreSQLContainer.java#L52-L55 -->
225-
<time>20000</time>
226-
<log>(?s)ready to accept connections.*ready to accept connections</log>
227-
</wait>
228-
</run>
229-
</image>
230-
</images>
231-
<!--Stops all postgres images currently running, not just those we just started.
232-
Useful to stop processes still running from a previously failed integration test run -->
233-
<allContainers>true</allContainers>
234-
</configuration>
235-
<executions>
236-
<execution>
237-
<id>docker-start</id>
238-
<phase>compile</phase>
239-
<goals>
240-
<goal>stop</goal>
241-
<goal>start</goal>
242-
</goals>
243-
</execution>
244-
<execution>
245-
<id>docker-stop</id>
246-
<phase>post-integration-test</phase>
247-
<goals>
248-
<goal>stop</goal>
249-
</goals>
250-
</execution>
251-
</executions>
252-
</plugin>
253201
<plugin>
254202
<groupId>org.codehaus.mojo</groupId>
255203
<artifactId>exec-maven-plugin</artifactId>

integration-tests/hibernate-orm-compatibility-5.6/postgresql/src/main/resources/application.properties

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,3 @@
1-
quarkus.datasource.username=hibernate_orm_test
2-
quarkus.datasource.password=hibernate_orm_test
3-
quarkus.datasource.jdbc.url=${postgres.url}
41
quarkus.datasource.jdbc.max-size=8
52

63
# On startup, restore the dump of a database meant for ORM 5.6

integration-tests/jpa-postgresql-withxml/pom.xml

Lines changed: 0 additions & 84 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,6 @@
1313
<name>Quarkus - Integration Tests - JPA - PostgreSQL with XML</name>
1414
<description>Module that contains JPA related tests running with the PostgreSQL database</description>
1515

16-
<properties>
17-
<postgres.url>jdbc:postgresql://localhost:5431/hibernate_orm_test</postgres.url>
18-
</properties>
19-
2016
<dependencies>
2117
<dependency>
2218
<groupId>io.quarkus</groupId>
@@ -161,86 +157,6 @@
161157
</plugins>
162158
</build>
163159
</profile>
164-
165-
<profile>
166-
<id>docker-postgresql</id>
167-
<activation>
168-
<property>
169-
<name>start-containers</name>
170-
</property>
171-
</activation>
172-
<build>
173-
<plugins>
174-
<plugin>
175-
<groupId>io.fabric8</groupId>
176-
<artifactId>docker-maven-plugin</artifactId>
177-
<configuration>
178-
<images>
179-
<image>
180-
<name>${postgres.image}</name>
181-
<alias>postgresql</alias>
182-
<run>
183-
<env>
184-
<POSTGRES_USER>hibernate_orm_test</POSTGRES_USER>
185-
<POSTGRES_PASSWORD>hibernate_orm_test</POSTGRES_PASSWORD>
186-
<POSTGRES_DB>hibernate_orm_test</POSTGRES_DB>
187-
</env>
188-
<ports>
189-
<port>5431:5432</port>
190-
</ports>
191-
<wait>
192-
<!-- For some reason, Postgres will tell us it's ready *twice*,
193-
and that's the truth the second time only.
194-
See https://github.com/fabric8io/docker-maven-plugin/issues/628
195-
See also how the condition is configured in testcontainers:
196-
https://github.com/testcontainers/testcontainers-java/blob/c64aab9fd5e3a452ee0faf793560327eb4da9841/modules/postgresql/src/main/java/org/testcontainers/containers/PostgreSQLContainer.java#L52-L55 -->
197-
<time>20000</time>
198-
<log>(?s)ready to accept connections.*ready to accept connections</log>
199-
</wait>
200-
</run>
201-
</image>
202-
</images>
203-
<!--Stops all postgres images currently running, not just those we just started.
204-
Useful to stop processes still running from a previously failed integration test run -->
205-
<allContainers>true</allContainers>
206-
</configuration>
207-
<executions>
208-
<execution>
209-
<id>docker-start</id>
210-
<phase>compile</phase>
211-
<goals>
212-
<goal>stop</goal>
213-
<goal>start</goal>
214-
</goals>
215-
</execution>
216-
<execution>
217-
<id>docker-stop</id>
218-
<phase>post-integration-test</phase>
219-
<goals>
220-
<goal>stop</goal>
221-
</goals>
222-
</execution>
223-
</executions>
224-
</plugin>
225-
<plugin>
226-
<groupId>org.codehaus.mojo</groupId>
227-
<artifactId>exec-maven-plugin</artifactId>
228-
<executions>
229-
<execution>
230-
<id>docker-prune</id>
231-
<phase>generate-resources</phase>
232-
<goals>
233-
<goal>exec</goal>
234-
</goals>
235-
<configuration>
236-
<executable>${docker-prune.location}</executable>
237-
</configuration>
238-
</execution>
239-
</executions>
240-
</plugin>
241-
</plugins>
242-
</build>
243-
</profile>
244160
</profiles>
245161

246162

integration-tests/jpa-postgresql-withxml/src/main/resources/application.properties

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,3 @@
1-
quarkus.datasource.username=hibernate_orm_test
2-
quarkus.datasource.password=hibernate_orm_test
3-
quarkus.datasource.jdbc.url=${postgres.url}
41
quarkus.datasource.jdbc.max-size=8
52

63
quarkus.hibernate-orm.packages=io.quarkus.it.jpa.postgresql.defaultpu

integration-tests/jpa-postgresql/README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
By default, the tests of this module are disabled.
66

7-
To run the tests in a standard JVM with PostgreSQL started as a Docker container, you can run the following command:
7+
To run the tests in a standard JVM with PostgreSQL started as a Dev Service, you can run the following command:
88

99
```
1010
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
1616
mvn clean install -Dtest-containers -Dstart-containers -Dnative
1717
```
1818

19-
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`.
19+
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`.
2020

2121
You can then run the tests as follows (either with `-Dnative` or not):
2222

2323
```
24-
mvn clean install -Dtest-containers
24+
mvn clean install -Dtest-containers -Dpostgres.url=jdbc:postgresql://...
2525
```
2626

27-
If you have specific requirements, you can define a specific connection URL with `-Dpostgres.url=jdbc:postgresql://...`.
27+
If you have specific requirements, you can also define a specific connection URL with `-Dpostgres.url=jdbc:postgresql://...`.

integration-tests/jpa-postgresql/pom.xml

Lines changed: 22 additions & 84 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,6 @@
1313
<name>Quarkus - Integration Tests - JPA - PostgreSQL</name>
1414
<description>Module that contains JPA related tests running with the PostgreSQL database</description>
1515

16-
<properties>
17-
<postgres.url>jdbc:postgresql://localhost:5431/hibernate_orm_test</postgres.url>
18-
</properties>
19-
2016
<dependencies>
2117
<dependency>
2218
<groupId>io.quarkus</groupId>
@@ -46,6 +42,28 @@
4642
<artifactId>quarkus-junit5-internal</artifactId>
4743
<scope>test</scope>
4844
</dependency>
45+
<!-- <dependency>-->
46+
<!-- <groupId>org.junit.platform</groupId>-->
47+
<!-- <artifactId>junit-platform-suite</artifactId>-->
48+
<!-- <scope>test</scope>-->
49+
<!-- </dependency>-->
50+
<dependency>
51+
<groupId>org.testcontainers</groupId>
52+
<artifactId>postgresql</artifactId>
53+
<exclusions>
54+
<exclusion>
55+
<groupId>junit</groupId>
56+
<artifactId>junit</artifactId>
57+
</exclusion>
58+
</exclusions>
59+
<scope>test</scope>
60+
</dependency>
61+
<!-- Until we have testcontainers 2, which has https://github.com/testcontainers/testcontainers-java/issues/970, add back JUnit 4 so testcontainers doesn't break everything :( -->
62+
<dependency>
63+
<groupId>junit</groupId>
64+
<artifactId>junit</artifactId>
65+
<version>${junit4.version}</version>
66+
</dependency>
4967
<dependency>
5068
<groupId>io.rest-assured</groupId>
5169
<artifactId>rest-assured</artifactId>
@@ -171,86 +189,6 @@
171189
</plugins>
172190
</build>
173191
</profile>
174-
175-
<profile>
176-
<id>docker-postgresql</id>
177-
<activation>
178-
<property>
179-
<name>start-containers</name>
180-
</property>
181-
</activation>
182-
<build>
183-
<plugins>
184-
<plugin>
185-
<groupId>io.fabric8</groupId>
186-
<artifactId>docker-maven-plugin</artifactId>
187-
<configuration>
188-
<images>
189-
<image>
190-
<name>${postgres.image}</name>
191-
<alias>postgresql</alias>
192-
<run>
193-
<env>
194-
<POSTGRES_USER>hibernate_orm_test</POSTGRES_USER>
195-
<POSTGRES_PASSWORD>hibernate_orm_test</POSTGRES_PASSWORD>
196-
<POSTGRES_DB>hibernate_orm_test</POSTGRES_DB>
197-
</env>
198-
<ports>
199-
<port>5431:5432</port>
200-
</ports>
201-
<wait>
202-
<!-- For some reason, Postgres will tell us it's ready *twice*,
203-
and that's the truth the second time only.
204-
See https://github.com/fabric8io/docker-maven-plugin/issues/628
205-
See also how the condition is configured in testcontainers:
206-
https://github.com/testcontainers/testcontainers-java/blob/c64aab9fd5e3a452ee0faf793560327eb4da9841/modules/postgresql/src/main/java/org/testcontainers/containers/PostgreSQLContainer.java#L52-L55 -->
207-
<time>20000</time>
208-
<log>(?s)ready to accept connections.*ready to accept connections</log>
209-
</wait>
210-
</run>
211-
</image>
212-
</images>
213-
<!--Stops all postgres images currently running, not just those we just started.
214-
Useful to stop processes still running from a previously failed integration test run -->
215-
<allContainers>true</allContainers>
216-
</configuration>
217-
<executions>
218-
<execution>
219-
<id>docker-start</id>
220-
<phase>compile</phase>
221-
<goals>
222-
<goal>stop</goal>
223-
<goal>start</goal>
224-
</goals>
225-
</execution>
226-
<execution>
227-
<id>docker-stop</id>
228-
<phase>post-integration-test</phase>
229-
<goals>
230-
<goal>stop</goal>
231-
</goals>
232-
</execution>
233-
</executions>
234-
</plugin>
235-
<plugin>
236-
<groupId>org.codehaus.mojo</groupId>
237-
<artifactId>exec-maven-plugin</artifactId>
238-
<executions>
239-
<execution>
240-
<id>docker-prune</id>
241-
<phase>generate-resources</phase>
242-
<goals>
243-
<goal>exec</goal>
244-
</goals>
245-
<configuration>
246-
<executable>${docker-prune.location}</executable>
247-
</configuration>
248-
</execution>
249-
</executions>
250-
</plugin>
251-
</plugins>
252-
</build>
253-
</profile>
254192
</profiles>
255193

256194

integration-tests/jpa-postgresql/src/main/resources/application.properties

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,3 @@
1-
quarkus.datasource.username=hibernate_orm_test
2-
quarkus.datasource.password=hibernate_orm_test
3-
quarkus.datasource.jdbc.url=${postgres.url}
41
quarkus.datasource.jdbc.max-size=8
52

63
quarkus.hibernate-orm.packages=io.quarkus.it.jpa.postgresql.defaultpu
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
package io.quarkus.it.jpa.postgresql;
2+
3+
import static org.hamcrest.Matchers.is;
4+
5+
import java.util.Collections;
6+
import java.util.List;
7+
import java.util.Map;
8+
9+
import org.junit.jupiter.api.Test;
10+
11+
import io.quarkus.test.junit.QuarkusTest;
12+
import io.quarkus.test.junit.QuarkusTestProfile;
13+
import io.quarkus.test.junit.TestProfile;
14+
import io.restassured.RestAssured;
15+
16+
/* Exercises OverrideJdbcUrlBuildTimeConfigSource, which cannot coexist with dev services. */
17+
@TestProfile(ConfigOverrideTest.Profile.class)
18+
@QuarkusTest
19+
public class ConfigOverrideTest {
20+
21+
@Test
22+
public void base() {
23+
RestAssured.when().get("/jpa/testfunctionality/base").then().body(is("OK"));
24+
}
25+
26+
public static class Profile implements QuarkusTestProfile {
27+
@Override
28+
public Map<String, String> getConfigOverrides() {
29+
// Disable dev services so we know we're connecting to the right database
30+
return Map.of("quarkus.devservices.enabled", "false");
31+
}
32+
33+
@Override
34+
public String getConfigProfile() {
35+
return "someotherprofile";
36+
}
37+
38+
@Override
39+
public List<TestResourceEntry> testResources() {
40+
return Collections.singletonList(new TestResourceEntry(PostgresTestResourceLifecycleManager.class));
41+
}
42+
}
43+
}

0 commit comments

Comments
 (0)