Skip to content

Commit 9bfc508

Browse files
authored
Merge pull request quarkusio#33790 from tomas1885/issue-33380
Allow hibernate reactive to coexists with Agroal
2 parents a296ae1 + 2a76b08 commit 9bfc508

File tree

9 files changed

+591
-2
lines changed

9 files changed

+591
-2
lines changed

.github/native-tests.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@
4545
{
4646
"category": "Data7",
4747
"timeout": 85,
48-
"test-modules": "reactive-oracle-client, reactive-mysql-client, reactive-db2-client, hibernate-reactive-db2, hibernate-reactive-mysql, hibernate-reactive-panache, hibernate-reactive-panache-kotlin",
48+
"test-modules": "reactive-oracle-client, reactive-mysql-client, reactive-db2-client, hibernate-reactive-db2, hibernate-reactive-mysql, hibernate-reactive-mysql-agroal, hibernate-reactive-panache, hibernate-reactive-panache-kotlin",
4949
"os-name": "ubuntu-latest"
5050
},
5151
{

extensions/hibernate-orm/deployment/src/main/java/io/quarkus/hibernate/orm/deployment/HibernateOrmProcessor.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -272,7 +272,7 @@ public ImpliedBlockingPersistenceUnitTypeBuildItem defineTypeOfImpliedPU(
272272
List<JdbcDataSourceBuildItem> jdbcDataSourcesBuildItem, //This is from Agroal SPI: safe to use even for Hibernate Reactive
273273
Capabilities capabilities) {
274274
// If we have some blocking datasources defined, we can have an implied PU
275-
if (jdbcDataSourcesBuildItem.size() == 0 && capabilities.isPresent(Capability.HIBERNATE_REACTIVE)) {
275+
if (capabilities.isPresent(Capability.HIBERNATE_REACTIVE)) {
276276
// if we don't have any blocking datasources and Hibernate Reactive is present,
277277
// we don't want a blocking persistence unit
278278
return ImpliedBlockingPersistenceUnitTypeBuildItem.none();
Lines changed: 305 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,305 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<project xmlns="http://maven.apache.org/POM/4.0.0"
3+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
5+
<parent>
6+
<artifactId>quarkus-integration-tests-parent</artifactId>
7+
<groupId>io.quarkus</groupId>
8+
<version>999-SNAPSHOT</version>
9+
</parent>
10+
<modelVersion>4.0.0</modelVersion>
11+
12+
<artifactId>quarkus-integration-test-hibernate-reactive-mysql-agroal</artifactId>
13+
<name>Quarkus - Integration Tests - Hibernate Reactive - MySQL</name>
14+
<description>Hibernate Reactive related tests running with the MySQL database</description>
15+
16+
<properties>
17+
<reactive-mysql.url>vertx-reactive:mysql://localhost:3306/hibernate_orm_test</reactive-mysql.url>
18+
<mysql.jdbc.url>jdbc:mysql://localhost:3306/hibernate_orm_test</mysql.jdbc.url>
19+
</properties>
20+
21+
<dependencies>
22+
<dependency>
23+
<groupId>io.quarkus</groupId>
24+
<artifactId>quarkus-agroal</artifactId>
25+
</dependency>
26+
<dependency>
27+
<groupId>io.quarkus</groupId>
28+
<artifactId>quarkus-jdbc-mysql</artifactId>
29+
</dependency>
30+
<dependency>
31+
<groupId>io.quarkus</groupId>
32+
<artifactId>quarkus-hibernate-reactive</artifactId>
33+
</dependency>
34+
<dependency>
35+
<groupId>io.quarkus</groupId>
36+
<artifactId>quarkus-reactive-mysql-client</artifactId>
37+
</dependency>
38+
<dependency>
39+
<groupId>io.quarkus</groupId>
40+
<artifactId>quarkus-resteasy-reactive-jsonb</artifactId>
41+
</dependency>
42+
43+
<!-- test dependencies -->
44+
<dependency>
45+
<groupId>io.quarkus</groupId>
46+
<artifactId>quarkus-junit5</artifactId>
47+
<scope>test</scope>
48+
</dependency>
49+
<dependency>
50+
<groupId>io.rest-assured</groupId>
51+
<artifactId>rest-assured</artifactId>
52+
<scope>test</scope>
53+
</dependency>
54+
55+
<!-- Minimal test dependencies to *-deployment artifacts for consistent build order -->
56+
<dependency>
57+
<groupId>io.quarkus</groupId>
58+
<artifactId>quarkus-agroal-deployment</artifactId>
59+
<version>${project.version}</version>
60+
<type>pom</type>
61+
<scope>test</scope>
62+
<exclusions>
63+
<exclusion>
64+
<groupId>*</groupId>
65+
<artifactId>*</artifactId>
66+
</exclusion>
67+
</exclusions>
68+
</dependency>
69+
<dependency>
70+
<groupId>io.quarkus</groupId>
71+
<artifactId>quarkus-jdbc-mysql-deployment</artifactId>
72+
<version>${project.version}</version>
73+
<type>pom</type>
74+
<scope>test</scope>
75+
<exclusions>
76+
<exclusion>
77+
<groupId>*</groupId>
78+
<artifactId>*</artifactId>
79+
</exclusion>
80+
</exclusions>
81+
</dependency>
82+
<dependency>
83+
<groupId>io.quarkus</groupId>
84+
<artifactId>quarkus-hibernate-reactive-deployment</artifactId>
85+
<version>${project.version}</version>
86+
<type>pom</type>
87+
<scope>test</scope>
88+
<exclusions>
89+
<exclusion>
90+
<groupId>*</groupId>
91+
<artifactId>*</artifactId>
92+
</exclusion>
93+
</exclusions>
94+
</dependency>
95+
<dependency>
96+
<groupId>io.quarkus</groupId>
97+
<artifactId>quarkus-reactive-mysql-client-deployment</artifactId>
98+
<version>${project.version}</version>
99+
<type>pom</type>
100+
<scope>test</scope>
101+
<exclusions>
102+
<exclusion>
103+
<groupId>*</groupId>
104+
<artifactId>*</artifactId>
105+
</exclusion>
106+
</exclusions>
107+
</dependency>
108+
<dependency>
109+
<groupId>io.quarkus</groupId>
110+
<artifactId>quarkus-resteasy-reactive-jsonb-deployment</artifactId>
111+
<version>${project.version}</version>
112+
<type>pom</type>
113+
<scope>test</scope>
114+
<exclusions>
115+
<exclusion>
116+
<groupId>*</groupId>
117+
<artifactId>*</artifactId>
118+
</exclusion>
119+
</exclusions>
120+
</dependency>
121+
</dependencies>
122+
123+
<build>
124+
<resources>
125+
<resource>
126+
<directory>src/main/resources</directory>
127+
<filtering>true</filtering>
128+
</resource>
129+
</resources>
130+
<plugins>
131+
<plugin>
132+
<artifactId>maven-surefire-plugin</artifactId>
133+
<configuration>
134+
<skip>true</skip>
135+
<systemPropertyVariables>
136+
<org.hibernate.reactive.common.InternalStateAssertions.ENFORCE>true</org.hibernate.reactive.common.InternalStateAssertions.ENFORCE>
137+
</systemPropertyVariables>
138+
</configuration>
139+
</plugin>
140+
<plugin>
141+
<artifactId>maven-failsafe-plugin</artifactId>
142+
<configuration>
143+
<skip>true</skip>
144+
<systemPropertyVariables>
145+
<org.hibernate.reactive.common.InternalStateAssertions.ENFORCE>true</org.hibernate.reactive.common.InternalStateAssertions.ENFORCE>
146+
</systemPropertyVariables>
147+
</configuration>
148+
</plugin>
149+
<plugin>
150+
<groupId>io.quarkus</groupId>
151+
<artifactId>quarkus-maven-plugin</artifactId>
152+
<executions>
153+
<execution>
154+
<goals>
155+
<goal>build</goal>
156+
</goals>
157+
</execution>
158+
</executions>
159+
</plugin>
160+
</plugins>
161+
</build>
162+
163+
<profiles>
164+
<profile>
165+
<id>test-mariadb</id>
166+
<activation>
167+
<property>
168+
<name>test-containers</name>
169+
</property>
170+
</activation>
171+
<build>
172+
<plugins>
173+
<plugin>
174+
<artifactId>maven-surefire-plugin</artifactId>
175+
<configuration>
176+
<skip>false</skip>
177+
</configuration>
178+
</plugin>
179+
<plugin>
180+
<artifactId>maven-failsafe-plugin</artifactId>
181+
<configuration>
182+
<skip>false</skip>
183+
</configuration>
184+
</plugin>
185+
</plugins>
186+
</build>
187+
</profile>
188+
189+
<profile>
190+
<id>docker-mariadb</id>
191+
<activation>
192+
<property>
193+
<name>start-containers</name>
194+
</property>
195+
</activation>
196+
<properties>
197+
<reactive-mysql.url>vertx-reactive:mysql://localhost:3308/hibernate_orm_test</reactive-mysql.url>
198+
<mysql.jdbc.url>jdbc:mysql://localhost:3308/hibernate_orm_test</mysql.jdbc.url>
199+
</properties>
200+
<build>
201+
<plugins>
202+
<plugin>
203+
<groupId>io.fabric8</groupId>
204+
<artifactId>docker-maven-plugin</artifactId>
205+
<configuration>
206+
<images>
207+
<image>
208+
<name>healthcheck-${mariadb.image}</name>
209+
<alias>quarkus-test-mariadb</alias>
210+
<build>
211+
<from>${mariadb.image}</from>
212+
<healthCheck>
213+
<!-- The exact values for these aren't very important, but it is important they are there -->
214+
<interval>5s</interval>
215+
<timeout>3s</timeout>
216+
<startPeriod>5s</startPeriod>
217+
<retries>5</retries>
218+
<!-- We could also use /usr/local/bin/healthcheck.sh but it seemed complicated to get the right level.
219+
Note that mysqladmin ping returns 0 even if the password is wrong so we don't need to pass in a password, but it makes the logs cleaner-->
220+
<cmd>
221+
<shell>mysqladmin ping -h localhost -u root -psecret|| exit 1</shell>
222+
</cmd>
223+
</healthCheck>
224+
</build>
225+
<run>
226+
<network>
227+
<mode>bridge</mode>
228+
</network>
229+
<ports>
230+
<port>3308:3306</port>
231+
</ports>
232+
<env>
233+
<MYSQL_USER>hibernate_orm_test</MYSQL_USER>
234+
<MYSQL_PASSWORD>hibernate_orm_test</MYSQL_PASSWORD>
235+
<MYSQL_DATABASE>hibernate_orm_test</MYSQL_DATABASE>
236+
<MYSQL_RANDOM_ROOT_PASSWORD>true</MYSQL_RANDOM_ROOT_PASSWORD>
237+
</env>
238+
<log>
239+
<prefix>MariaDB:</prefix>
240+
<date>default</date>
241+
<color>cyan</color>
242+
</log>
243+
<!-- Speed things up a bit by not actually flushing writes to disk -->
244+
<tmpfs>/var/lib/mysql</tmpfs>
245+
<wait>
246+
<!-- good docs found at: https://dmp.fabric8.io/#start-wait -->
247+
<time>20000</time>
248+
<healthy>true</healthy>
249+
</wait>
250+
<volumes>
251+
<bind>
252+
<volume>
253+
${project.basedir}/custom-mariadbconfig:/etc/mysql/conf.d${volume.access.modifier}
254+
</volume>
255+
</bind>
256+
</volumes>
257+
</run>
258+
</image>
259+
</images>
260+
<!--Stops all mariadb images currently running, not just those we just started.
261+
Useful to stop processes still running from a previously failed integration test run -->
262+
<allContainers>true</allContainers>
263+
</configuration>
264+
<executions>
265+
<execution>
266+
<id>docker-start</id>
267+
<phase>compile</phase>
268+
<goals>
269+
<goal>stop</goal>
270+
<goal>build</goal>
271+
<goal>start</goal>
272+
</goals>
273+
</execution>
274+
<execution>
275+
<id>docker-stop</id>
276+
<phase>post-integration-test</phase>
277+
<goals>
278+
<goal>stop</goal>
279+
</goals>
280+
</execution>
281+
</executions>
282+
</plugin>
283+
<plugin>
284+
<groupId>org.codehaus.mojo</groupId>
285+
<artifactId>exec-maven-plugin</artifactId>
286+
<executions>
287+
<execution>
288+
<id>docker-prune</id>
289+
<phase>generate-resources</phase>
290+
<goals>
291+
<goal>exec</goal>
292+
</goals>
293+
<configuration>
294+
<executable>${docker-prune.location}</executable>
295+
</configuration>
296+
</execution>
297+
</executions>
298+
</plugin>
299+
</plugins>
300+
</build>
301+
</profile>
302+
</profiles>
303+
304+
305+
</project>
Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
package io.quarkus.it.hibernate.reactive.mysql;
2+
3+
import java.util.Objects;
4+
5+
import jakarta.persistence.Entity;
6+
import jakarta.persistence.Id;
7+
import jakarta.persistence.Table;
8+
9+
@Entity
10+
@Table(name = "Pig")
11+
public class GuineaPig {
12+
13+
@Id
14+
private Integer id;
15+
private String name;
16+
17+
public GuineaPig() {
18+
}
19+
20+
public GuineaPig(Integer id, String name) {
21+
this.id = id;
22+
this.name = name;
23+
}
24+
25+
public Integer getId() {
26+
return id;
27+
}
28+
29+
public void setId(Integer id) {
30+
this.id = id;
31+
}
32+
33+
public String getName() {
34+
return name;
35+
}
36+
37+
public void setName(String name) {
38+
this.name = name;
39+
}
40+
41+
@Override
42+
public String toString() {
43+
return id + ": " + name;
44+
}
45+
46+
@Override
47+
public boolean equals(Object o) {
48+
if (this == o) {
49+
return true;
50+
}
51+
if (o == null || getClass() != o.getClass()) {
52+
return false;
53+
}
54+
GuineaPig guineaPig = (GuineaPig) o;
55+
return Objects.equals(name, guineaPig.name);
56+
}
57+
58+
@Override
59+
public int hashCode() {
60+
return Objects.hash(name);
61+
}
62+
}

0 commit comments

Comments
 (0)