[12826] Configuring Postgres and MariaDb version
This commit is contained in:
parent
15a04021e0
commit
4fd3049c85
3 changed files with 20 additions and 5 deletions
|
@ -105,3 +105,7 @@ These tests are disabled by default. They using Quarkus development mode predefi
|
||||||
mvn clean install -Dkc.test.storage.database=true -Dtest=MariaDBStartDatabaseTest
|
mvn clean install -Dkc.test.storage.database=true -Dtest=MariaDBStartDatabaseTest
|
||||||
|
|
||||||
to spin up a MariaDB container and start Keycloak with it.
|
to spin up a MariaDB container and start Keycloak with it.
|
||||||
|
|
||||||
|
To use a specific database container image, use the option -Dkc.db.postgresql.container.image to specify the image tag of the postgres image to use or -Dkc.db.mariadb.container.image=<name:tag> for mariadb.
|
||||||
|
Example:
|
||||||
|
mvn clean install -Dkc.test.storage.database=true -Dtest=PostgreSQLDistTest -Dkc.db.postgresql.container.image=postgres:
|
||||||
|
|
|
@ -116,9 +116,12 @@
|
||||||
<artifactId>maven-surefire-plugin</artifactId>
|
<artifactId>maven-surefire-plugin</artifactId>
|
||||||
<configuration>
|
<configuration>
|
||||||
<argLine>-Xmx1024m -XX:MaxMetaspaceSize=512m</argLine>
|
<argLine>-Xmx1024m -XX:MaxMetaspaceSize=512m</argLine>
|
||||||
<systemProperties>
|
<systemPropertyVariables>
|
||||||
<kc.test.storage.database>true</kc.test.storage.database>
|
<kc.test.storage.database>true</kc.test.storage.database>
|
||||||
</systemProperties>
|
<!--DB Container -->
|
||||||
|
<kc.db.postgresql.container.image>postgres:alpine</kc.db.postgresql.container.image>
|
||||||
|
<kc.db.mariadb.container.image>mariadb:10.5.9</kc.db.mariadb.container.image>
|
||||||
|
</systemPropertyVariables>
|
||||||
</configuration>
|
</configuration>
|
||||||
</plugin>
|
</plugin>
|
||||||
</plugins>
|
</plugins>
|
||||||
|
|
|
@ -22,6 +22,7 @@ import org.jetbrains.annotations.NotNull;
|
||||||
import org.testcontainers.containers.JdbcDatabaseContainer;
|
import org.testcontainers.containers.JdbcDatabaseContainer;
|
||||||
import org.testcontainers.containers.MariaDBContainer;
|
import org.testcontainers.containers.MariaDBContainer;
|
||||||
import org.testcontainers.containers.PostgreSQLContainer;
|
import org.testcontainers.containers.PostgreSQLContainer;
|
||||||
|
import org.testcontainers.utility.DockerImageName;
|
||||||
|
|
||||||
public class DatabaseContainer {
|
public class DatabaseContainer {
|
||||||
|
|
||||||
|
@ -66,11 +67,18 @@ public class DatabaseContainer {
|
||||||
}
|
}
|
||||||
|
|
||||||
private JdbcDatabaseContainer createContainer() {
|
private JdbcDatabaseContainer createContainer() {
|
||||||
|
|
||||||
|
String POSTGRES_IMAGE = System.getProperty("kc.db.postgresql.container.image");
|
||||||
|
String MARIADB_IMAGE = System.getProperty("kc.db.mariadb.container.image");
|
||||||
|
|
||||||
|
DockerImageName POSTGRES = DockerImageName.parse(POSTGRES_IMAGE).asCompatibleSubstituteFor("postgres");
|
||||||
|
DockerImageName MARIADB = DockerImageName.parse(MARIADB_IMAGE).asCompatibleSubstituteFor("mariadb");
|
||||||
|
|
||||||
switch (alias) {
|
switch (alias) {
|
||||||
case "postgres":
|
case "postgres":
|
||||||
return new PostgreSQLContainer("postgres:alpine");
|
return new PostgreSQLContainer(POSTGRES);
|
||||||
case "mariadb":
|
case "mariadb":
|
||||||
return new MariaDBContainer("mariadb:10.5.9");
|
return new MariaDBContainer(MARIADB);
|
||||||
default:
|
default:
|
||||||
throw new RuntimeException("Unsupported database: " + alias);
|
throw new RuntimeException("Unsupported database: " + alias);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue