Skip to content

Commit 96eb6f2

Browse files
committed
Start the Hibernate Panache tests with docker postgres
This allows supporting ORM and HR at the same time
1 parent 3933049 commit 96eb6f2

File tree

2 files changed

+136
-3
lines changed

2 files changed

+136
-3
lines changed

extensions/panache/hibernate-panache/deployment/pom.xml

Lines changed: 130 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,12 @@
1111

1212
<artifactId>quarkus-hibernate-panache-deployment</artifactId>
1313
<name>Quarkus - Hibernate with Panache - Deployment</name>
14+
15+
<properties>
16+
<postgres.reactive.url>vertx-reactive:postgresql://localhost:5431/hibernate_orm_test</postgres.reactive.url>
17+
<postgres.blocking.url>jdbc:postgresql://localhost:5431/hibernate_orm_test</postgres.blocking.url>
18+
</properties>
19+
1420
<dependencies>
1521
<dependency>
1622
<groupId>io.quarkus</groupId>
@@ -47,14 +53,24 @@
4753
</dependency>
4854

4955
<!-- test dependencies -->
56+
<dependency>
57+
<groupId>io.quarkus</groupId>
58+
<artifactId>quarkus-test-vertx</artifactId>
59+
<scope>test</scope>
60+
</dependency>
5061
<dependency>
5162
<groupId>io.quarkus</groupId>
5263
<artifactId>quarkus-junit5-internal</artifactId>
5364
<scope>test</scope>
5465
</dependency>
5566
<dependency>
5667
<groupId>io.quarkus</groupId>
57-
<artifactId>quarkus-jdbc-h2-deployment</artifactId>
68+
<artifactId>quarkus-jdbc-postgresql-deployment</artifactId>
69+
<scope>test</scope>
70+
</dependency>
71+
<dependency>
72+
<groupId>io.quarkus</groupId>
73+
<artifactId>quarkus-reactive-pg-client-deployment</artifactId>
5874
<scope>test</scope>
5975
</dependency>
6076
<dependency>
@@ -65,6 +81,12 @@
6581
</dependencies>
6682

6783
<build>
84+
<testResources>
85+
<testResource>
86+
<directory>src/test/resources</directory>
87+
<filtering>true</filtering>
88+
</testResource>
89+
</testResources>
6890
<plugins>
6991
<plugin>
7092
<artifactId>maven-compiler-plugin</artifactId>
@@ -94,7 +116,114 @@
94116
</execution>
95117
</executions>
96118
</plugin>
119+
<plugin>
120+
<artifactId>maven-surefire-plugin</artifactId>
121+
<configuration>
122+
<skip>true</skip>
123+
</configuration>
124+
</plugin>
97125
</plugins>
98126
</build>
99127

128+
<profiles>
129+
<profile>
130+
<id>test-postgresql</id>
131+
<activation>
132+
<property>
133+
<name>test-containers</name>
134+
</property>
135+
</activation>
136+
<build>
137+
<plugins>
138+
<plugin>
139+
<artifactId>maven-surefire-plugin</artifactId>
140+
<configuration>
141+
<skip>false</skip>
142+
</configuration>
143+
</plugin>
144+
</plugins>
145+
</build>
146+
</profile>
147+
148+
<profile>
149+
<id>docker-postgresql</id>
150+
<activation>
151+
<property>
152+
<name>start-containers</name>
153+
</property>
154+
</activation>
155+
<build>
156+
<plugins>
157+
<plugin>
158+
<groupId>io.fabric8</groupId>
159+
<artifactId>docker-maven-plugin</artifactId>
160+
<configuration>
161+
<images>
162+
<image>
163+
<name>${postgres.image}</name>
164+
<alias>postgresql</alias>
165+
<run>
166+
<env>
167+
<POSTGRES_USER>hibernate_orm_test</POSTGRES_USER>
168+
<POSTGRES_PASSWORD>hibernate_orm_test</POSTGRES_PASSWORD>
169+
<POSTGRES_DB>hibernate_orm_test</POSTGRES_DB>
170+
</env>
171+
<ports>
172+
<port>5431:5432</port>
173+
</ports>
174+
<wait>
175+
<!-- For some reason, Postgres will tell us it's ready *twice*,
176+
and that's the truth the second time only.
177+
See https://github.com/fabric8io/docker-maven-plugin/issues/628
178+
See also how the condition is configured in testcontainers:
179+
https://github.com/testcontainers/testcontainers-java/blob/c64aab9fd5e3a452ee0faf793560327eb4da9841/modules/postgresql/src/main/java/org/testcontainers/containers/PostgreSQLContainer.java#L52-L55 -->
180+
<time>20000</time>
181+
<log>(?s)ready to accept connections.*ready to accept connections</log>
182+
</wait>
183+
</run>
184+
</image>
185+
</images>
186+
<!--Stops all postgres images currently running, not just those we just started.
187+
Useful to stop processes still running from a previously failed integration test run -->
188+
<allContainers>true</allContainers>
189+
</configuration>
190+
<executions>
191+
<execution>
192+
<id>docker-start</id>
193+
<phase>process-test-classes</phase>
194+
<goals>
195+
<goal>stop</goal>
196+
<goal>start</goal>
197+
</goals>
198+
</execution>
199+
<execution>
200+
<id>docker-stop</id>
201+
<phase>post-integration-test</phase>
202+
<goals>
203+
<goal>stop</goal>
204+
</goals>
205+
</execution>
206+
</executions>
207+
</plugin>
208+
<plugin>
209+
<groupId>org.codehaus.mojo</groupId>
210+
<artifactId>exec-maven-plugin</artifactId>
211+
<executions>
212+
<execution>
213+
<id>docker-prune</id>
214+
<phase>generate-resources</phase>
215+
<goals>
216+
<goal>exec</goal>
217+
</goals>
218+
<configuration>
219+
<executable>${docker-prune.location}</executable>
220+
</configuration>
221+
</execution>
222+
</executions>
223+
</plugin>
224+
</plugins>
225+
</build>
226+
</profile>
227+
</profiles>
228+
100229
</project>
Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
1-
quarkus.datasource.db-kind=h2
2-
quarkus.datasource.jdbc.url=jdbc:h2:mem:test
1+
quarkus.datasource.reactive.url=${postgres.reactive.url}
2+
quarkus.datasource.jdbc.url=${postgres.blocking.url}
33

4+
quarkus.datasource.db-kind=postgresql
5+
quarkus.datasource.username=hibernate_orm_test
6+
quarkus.datasource.password=hibernate_orm_test
7+
quarkus.datasource.reactive=true
48
#quarkus.hibernate-orm.log.sql=true
59
quarkus.hibernate-orm.database.generation=drop-and-create

0 commit comments

Comments
 (0)