Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update MariaDB image to 10.6 for integration tests and dev services #23329

Merged
merged 1 commit into from
Feb 1, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion build-parent/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@

<!-- Database images for JDBC/Reactive/Hibernate tests -->
<postgres.image>docker.io/postgres:14.1</postgres.image>
<mariadb.image>docker.io/mariadb:10.4</mariadb.image>
<mariadb.image>docker.io/mariadb:10.6</mariadb.image>
<db2.image>docker.io/ibmcom/db2:11.5.5.0</db2.image>
<mssql.image>mcr.microsoft.com/mssql/server:2019-CU8-ubuntu-16.04</mssql.image>
<oracle.image>docker.io/gvenzl/oracle-xe:21.3.0-slim</oracle.image>
Expand Down
9 changes: 9 additions & 0 deletions extensions/devservices/common/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -40,4 +40,13 @@
<artifactId>quarkus-core</artifactId>
</dependency>
</dependencies>

<build>
<resources>
<resource>
<directory>src/main/resources</directory>
<filtering>true</filtering>
</resource>
</resources>
</build>
</project>
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
package io.quarkus.devservices.common;

import java.io.IOException;
import java.io.InputStream;
import java.io.UncheckedIOException;
import java.util.Collections;
import java.util.Properties;

import org.testcontainers.containers.GenericContainer;
import org.testcontainers.containers.Network;
Expand Down Expand Up @@ -38,4 +42,27 @@ public static String configureSharedNetwork(GenericContainer<?> container, Strin

return hostName;
}

public static String getDefaultImageNameFor(String devserviceName) {
var imageName = LazyProperties.INSTANCE.getProperty(devserviceName + ".image");
if (imageName == null) {
throw new IllegalArgumentException("No default image configured for " + devserviceName);
}
return imageName;
}

private static class LazyProperties {

private static final Properties INSTANCE;

static {
var tccl = Thread.currentThread().getContextClassLoader();
try (InputStream in = tccl.getResourceAsStream("devservices.properties")) {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure about "external" dev services. To cover those as well here we could load all properties on the CP.
But then again this can be considered more of an "internal" feature for the beginning?

INSTANCE = new Properties();
INSTANCE.load(in);
} catch (IOException e) {
throw new UncheckedIOException(e);
}
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
mariadb.image=${mariadb.image}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So you would have one common file for all the images, right?

I thought of doing it with a file specific to each devservice but it's certainly easier this way and good enough IMHO. This could be generalized to all devservices next.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@gsmet Yeah, thought about multiple files too. I can change it to a specific one per dev service if you prefer.
This would make loading that specific file a bit more complicated though, but it's definitely doable.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PS: This would also make #23329 (comment) obsolete.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FWIW:

This could be generalized to all devservices next.

I have started working on this.

Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ public class MariaDBDevServicesProcessor {

private static final Logger LOG = Logger.getLogger(MariaDBDevServicesProcessor.class);

public static final String TAG = "10.5.9";
public static final Integer PORT = 3306;
public static final String MY_CNF_CONFIG_OVERRIDE_PARAM_NAME = "TC_MY_CNF";

Expand Down Expand Up @@ -75,8 +74,8 @@ private static class QuarkusMariaDBContainer extends MariaDBContainer {

public QuarkusMariaDBContainer(Optional<String> imageName, OptionalInt fixedExposedPort, boolean useSharedNetwork) {
super(DockerImageName
.parse(imageName.orElse("docker.io/" + MariaDBContainer.IMAGE + ":" + MariaDBDevServicesProcessor.TAG))
.asCompatibleSubstituteFor(DockerImageName.parse(MariaDBContainer.IMAGE)));
.parse(imageName.orElseGet(() -> ConfigureUtil.getDefaultImageNameFor("mariadb")))
.asCompatibleSubstituteFor(DockerImageName.parse(MariaDBContainer.NAME)));
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note: IMAGE is deprecated.

this.fixedExposedPort = fixedExposedPort;
this.useSharedNetwork = useSharedNetwork;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public static String guessDialect(String persistenceUnitName, String resolvedDbK
return "io.quarkus.hibernate.orm.runtime.dialect.QuarkusH2Dialect";
}
if (DatabaseKind.isMariaDB(resolvedDbKind)) {
return "org.hibernate.dialect.MariaDB103Dialect";
return "org.hibernate.dialect.MariaDB106Dialect";
Copy link
Member Author

@famod famod Jan 31, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not entirely sure about this one. But to quote the comment further up:

// For now select the latest dialect from the driver

If it's get's merged like this we should probably add something to the migration guide? 🤔

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed on the change and the note.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 thanks

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

}
if (DatabaseKind.isMySQL(resolvedDbKind)) {
return "org.hibernate.dialect.MySQL8Dialect";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

import org.hibernate.dialect.DB297Dialect;
import org.hibernate.dialect.DerbyTenSevenDialect;
import org.hibernate.dialect.MariaDB103Dialect;
import org.hibernate.dialect.MariaDB106Dialect;
import org.hibernate.dialect.MySQL8Dialect;
import org.hibernate.dialect.Oracle12cDialect;
import org.hibernate.dialect.SQLServer2016Dialect;
Expand Down Expand Up @@ -38,7 +38,7 @@ public void testDialectNames() {
assertDialectMatch(DatabaseKind.DB2, DB297Dialect.class);
assertDialectMatch(DatabaseKind.POSTGRESQL, QuarkusPostgreSQL10Dialect.class);
assertDialectMatch(DatabaseKind.H2, QuarkusH2Dialect.class);
assertDialectMatch(DatabaseKind.MARIADB, MariaDB103Dialect.class);
assertDialectMatch(DatabaseKind.MARIADB, MariaDB106Dialect.class);
assertDialectMatch(DatabaseKind.MYSQL, MySQL8Dialect.class);
assertDialectMatch(DatabaseKind.DERBY, DerbyTenSevenDialect.class);
assertDialectMatch(DatabaseKind.MSSQL, SQLServer2016Dialect.class);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Hibernate ORM settings
quarkus.hibernate-orm.database.generation=none
quarkus.hibernate-orm.multitenant=database
quarkus.hibernate-orm.dialect=org.hibernate.dialect.MariaDB103Dialect
quarkus.hibernate-orm.dialect=org.hibernate.dialect.MariaDB106Dialect
quarkus.hibernate-orm.packages=io.quarkus.it.hibernate.multitenancy.fruit

# We create datasources manually, so a lack of configuration doesn't mean Quarkus should step in with defaults.
Expand All @@ -10,7 +10,7 @@ quarkus.datasource.devservices.enabled=false
# Inventory persistence unit
quarkus.hibernate-orm."inventory".database.generation=none
quarkus.hibernate-orm."inventory".multitenant=database
quarkus.hibernate-orm."inventory".dialect=org.hibernate.dialect.MariaDB103Dialect
quarkus.hibernate-orm."inventory".dialect=org.hibernate.dialect.MariaDB106Dialect
quarkus.hibernate-orm."inventory".packages=io.quarkus.it.hibernate.multitenancy.inventory

#mariadb.base_url is set through Maven config
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Hibernate ORM settings
quarkus.hibernate-orm.database.generation=none
quarkus.hibernate-orm.multitenant=database
quarkus.hibernate-orm.dialect=org.hibernate.dialect.MariaDB103Dialect
quarkus.hibernate-orm.dialect=org.hibernate.dialect.MariaDB106Dialect
quarkus.hibernate-orm.packages=io.quarkus.it.hibernate.multitenancy.fruit

# We create datasources manually, so a lack of configuration doesn't mean Quarkus should step in with defaults.
Expand All @@ -10,7 +10,7 @@ quarkus.datasource.devservices.enabled=false
# Inventory persistence unit
quarkus.hibernate-orm."inventory".database.generation=none
quarkus.hibernate-orm."inventory".multitenant=database
quarkus.hibernate-orm."inventory".dialect=org.hibernate.dialect.MariaDB103Dialect
quarkus.hibernate-orm."inventory".dialect=org.hibernate.dialect.MariaDB106Dialect
quarkus.hibernate-orm."inventory".packages=io.quarkus.it.hibernate.multitenancy.inventory

#mariadb.base_url is set through Maven config
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
<property name="hibernate.archive.autodetection" value="class, hbm"/>

<!-- Connection specific -->
<property name="hibernate.dialect" value="org.hibernate.dialect.MariaDB103Dialect"/>
<property name="hibernate.dialect" value="org.hibernate.dialect.MariaDB106Dialect"/>

<!-- Tuning and debugging -->
<property name="hibernate.show_sql" value="false"/>
Expand Down