Skip to content

Commit

Permalink
Merge pull request #33790 from tomas1885/issue-33380
Browse files Browse the repository at this point in the history
Allow hibernate reactive to coexists with Agroal
  • Loading branch information
yrodiere authored Sep 11, 2023
2 parents a296ae1 + 2a76b08 commit 9bfc508
Show file tree
Hide file tree
Showing 9 changed files with 591 additions and 2 deletions.
2 changes: 1 addition & 1 deletion .github/native-tests.json
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
{
"category": "Data7",
"timeout": 85,
"test-modules": "reactive-oracle-client, reactive-mysql-client, reactive-db2-client, hibernate-reactive-db2, hibernate-reactive-mysql, hibernate-reactive-panache, hibernate-reactive-panache-kotlin",
"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",
"os-name": "ubuntu-latest"
},
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -272,7 +272,7 @@ public ImpliedBlockingPersistenceUnitTypeBuildItem defineTypeOfImpliedPU(
List<JdbcDataSourceBuildItem> jdbcDataSourcesBuildItem, //This is from Agroal SPI: safe to use even for Hibernate Reactive
Capabilities capabilities) {
// If we have some blocking datasources defined, we can have an implied PU
if (jdbcDataSourcesBuildItem.size() == 0 && capabilities.isPresent(Capability.HIBERNATE_REACTIVE)) {
if (capabilities.isPresent(Capability.HIBERNATE_REACTIVE)) {
// if we don't have any blocking datasources and Hibernate Reactive is present,
// we don't want a blocking persistence unit
return ImpliedBlockingPersistenceUnitTypeBuildItem.none();
Expand Down
305 changes: 305 additions & 0 deletions integration-tests/hibernate-reactive-mysql-agroal/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,305 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent>
<artifactId>quarkus-integration-tests-parent</artifactId>
<groupId>io.quarkus</groupId>
<version>999-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>

<artifactId>quarkus-integration-test-hibernate-reactive-mysql-agroal</artifactId>
<name>Quarkus - Integration Tests - Hibernate Reactive - MySQL</name>
<description>Hibernate Reactive related tests running with the MySQL database</description>

<properties>
<reactive-mysql.url>vertx-reactive:mysql://localhost:3306/hibernate_orm_test</reactive-mysql.url>
<mysql.jdbc.url>jdbc:mysql://localhost:3306/hibernate_orm_test</mysql.jdbc.url>
</properties>

<dependencies>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-agroal</artifactId>
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-jdbc-mysql</artifactId>
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-hibernate-reactive</artifactId>
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-reactive-mysql-client</artifactId>
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-resteasy-reactive-jsonb</artifactId>
</dependency>

<!-- test dependencies -->
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-junit5</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>io.rest-assured</groupId>
<artifactId>rest-assured</artifactId>
<scope>test</scope>
</dependency>

<!-- Minimal test dependencies to *-deployment artifacts for consistent build order -->
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-agroal-deployment</artifactId>
<version>${project.version}</version>
<type>pom</type>
<scope>test</scope>
<exclusions>
<exclusion>
<groupId>*</groupId>
<artifactId>*</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-jdbc-mysql-deployment</artifactId>
<version>${project.version}</version>
<type>pom</type>
<scope>test</scope>
<exclusions>
<exclusion>
<groupId>*</groupId>
<artifactId>*</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-hibernate-reactive-deployment</artifactId>
<version>${project.version}</version>
<type>pom</type>
<scope>test</scope>
<exclusions>
<exclusion>
<groupId>*</groupId>
<artifactId>*</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-reactive-mysql-client-deployment</artifactId>
<version>${project.version}</version>
<type>pom</type>
<scope>test</scope>
<exclusions>
<exclusion>
<groupId>*</groupId>
<artifactId>*</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-resteasy-reactive-jsonb-deployment</artifactId>
<version>${project.version}</version>
<type>pom</type>
<scope>test</scope>
<exclusions>
<exclusion>
<groupId>*</groupId>
<artifactId>*</artifactId>
</exclusion>
</exclusions>
</dependency>
</dependencies>

<build>
<resources>
<resource>
<directory>src/main/resources</directory>
<filtering>true</filtering>
</resource>
</resources>
<plugins>
<plugin>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<skip>true</skip>
<systemPropertyVariables>
<org.hibernate.reactive.common.InternalStateAssertions.ENFORCE>true</org.hibernate.reactive.common.InternalStateAssertions.ENFORCE>
</systemPropertyVariables>
</configuration>
</plugin>
<plugin>
<artifactId>maven-failsafe-plugin</artifactId>
<configuration>
<skip>true</skip>
<systemPropertyVariables>
<org.hibernate.reactive.common.InternalStateAssertions.ENFORCE>true</org.hibernate.reactive.common.InternalStateAssertions.ENFORCE>
</systemPropertyVariables>
</configuration>
</plugin>
<plugin>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-maven-plugin</artifactId>
<executions>
<execution>
<goals>
<goal>build</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>

<profiles>
<profile>
<id>test-mariadb</id>
<activation>
<property>
<name>test-containers</name>
</property>
</activation>
<build>
<plugins>
<plugin>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<skip>false</skip>
</configuration>
</plugin>
<plugin>
<artifactId>maven-failsafe-plugin</artifactId>
<configuration>
<skip>false</skip>
</configuration>
</plugin>
</plugins>
</build>
</profile>

<profile>
<id>docker-mariadb</id>
<activation>
<property>
<name>start-containers</name>
</property>
</activation>
<properties>
<reactive-mysql.url>vertx-reactive:mysql://localhost:3308/hibernate_orm_test</reactive-mysql.url>
<mysql.jdbc.url>jdbc:mysql://localhost:3308/hibernate_orm_test</mysql.jdbc.url>
</properties>
<build>
<plugins>
<plugin>
<groupId>io.fabric8</groupId>
<artifactId>docker-maven-plugin</artifactId>
<configuration>
<images>
<image>
<name>healthcheck-${mariadb.image}</name>
<alias>quarkus-test-mariadb</alias>
<build>
<from>${mariadb.image}</from>
<healthCheck>
<!-- The exact values for these aren't very important, but it is important they are there -->
<interval>5s</interval>
<timeout>3s</timeout>
<startPeriod>5s</startPeriod>
<retries>5</retries>
<!-- We could also use /usr/local/bin/healthcheck.sh but it seemed complicated to get the right level.
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-->
<cmd>
<shell>mysqladmin ping -h localhost -u root -psecret|| exit 1</shell>
</cmd>
</healthCheck>
</build>
<run>
<network>
<mode>bridge</mode>
</network>
<ports>
<port>3308:3306</port>
</ports>
<env>
<MYSQL_USER>hibernate_orm_test</MYSQL_USER>
<MYSQL_PASSWORD>hibernate_orm_test</MYSQL_PASSWORD>
<MYSQL_DATABASE>hibernate_orm_test</MYSQL_DATABASE>
<MYSQL_RANDOM_ROOT_PASSWORD>true</MYSQL_RANDOM_ROOT_PASSWORD>
</env>
<log>
<prefix>MariaDB:</prefix>
<date>default</date>
<color>cyan</color>
</log>
<!-- Speed things up a bit by not actually flushing writes to disk -->
<tmpfs>/var/lib/mysql</tmpfs>
<wait>
<!-- good docs found at: https://dmp.fabric8.io/#start-wait -->
<time>20000</time>
<healthy>true</healthy>
</wait>
<volumes>
<bind>
<volume>
${project.basedir}/custom-mariadbconfig:/etc/mysql/conf.d${volume.access.modifier}
</volume>
</bind>
</volumes>
</run>
</image>
</images>
<!--Stops all mariadb images currently running, not just those we just started.
Useful to stop processes still running from a previously failed integration test run -->
<allContainers>true</allContainers>
</configuration>
<executions>
<execution>
<id>docker-start</id>
<phase>compile</phase>
<goals>
<goal>stop</goal>
<goal>build</goal>
<goal>start</goal>
</goals>
</execution>
<execution>
<id>docker-stop</id>
<phase>post-integration-test</phase>
<goals>
<goal>stop</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<executions>
<execution>
<id>docker-prune</id>
<phase>generate-resources</phase>
<goals>
<goal>exec</goal>
</goals>
<configuration>
<executable>${docker-prune.location}</executable>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
</profiles>


</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
package io.quarkus.it.hibernate.reactive.mysql;

import java.util.Objects;

import jakarta.persistence.Entity;
import jakarta.persistence.Id;
import jakarta.persistence.Table;

@Entity
@Table(name = "Pig")
public class GuineaPig {

@Id
private Integer id;
private String name;

public GuineaPig() {
}

public GuineaPig(Integer id, String name) {
this.id = id;
this.name = name;
}

public Integer getId() {
return id;
}

public void setId(Integer id) {
this.id = id;
}

public String getName() {
return name;
}

public void setName(String name) {
this.name = name;
}

@Override
public String toString() {
return id + ": " + name;
}

@Override
public boolean equals(Object o) {
if (this == o) {
return true;
}
if (o == null || getClass() != o.getClass()) {
return false;
}
GuineaPig guineaPig = (GuineaPig) o;
return Objects.equals(name, guineaPig.name);
}

@Override
public int hashCode() {
return Objects.hash(name);
}
}
Loading

0 comments on commit 9bfc508

Please sign in to comment.