From 4fd3049c853a33beab9bd03f981dbfec164530db Mon Sep 17 00:00:00 2001 From: nchopra Date: Fri, 15 Jul 2022 14:21:31 +0100 Subject: [PATCH] [12826] Configuring Postgres and MariaDb version --- quarkus/README.md | 6 +++++- quarkus/tests/integration/pom.xml | 7 +++++-- .../it/junit5/extension/DatabaseContainer.java | 12 ++++++++++-- 3 files changed, 20 insertions(+), 5 deletions(-) diff --git a/quarkus/README.md b/quarkus/README.md index cffc1f266e..fbf46c6e19 100644 --- a/quarkus/README.md +++ b/quarkus/README.md @@ -104,4 +104,8 @@ These tests are disabled by default. They using Quarkus development mode predefi mvn clean install -Dkc.test.storage.database=true -Dtest=MariaDBStartDatabaseTest -to spin up a MariaDB container and start Keycloak with it. \ No newline at end of file +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= for mariadb. +Example: +mvn clean install -Dkc.test.storage.database=true -Dtest=PostgreSQLDistTest -Dkc.db.postgresql.container.image=postgres: diff --git a/quarkus/tests/integration/pom.xml b/quarkus/tests/integration/pom.xml index de4c255f09..4143d6f195 100644 --- a/quarkus/tests/integration/pom.xml +++ b/quarkus/tests/integration/pom.xml @@ -116,9 +116,12 @@ maven-surefire-plugin -Xmx1024m -XX:MaxMetaspaceSize=512m - + true - + + postgres:alpine + mariadb:10.5.9 + diff --git a/quarkus/tests/integration/src/main/java/org/keycloak/it/junit5/extension/DatabaseContainer.java b/quarkus/tests/integration/src/main/java/org/keycloak/it/junit5/extension/DatabaseContainer.java index e9b7f06ea5..cb7af68d0d 100644 --- a/quarkus/tests/integration/src/main/java/org/keycloak/it/junit5/extension/DatabaseContainer.java +++ b/quarkus/tests/integration/src/main/java/org/keycloak/it/junit5/extension/DatabaseContainer.java @@ -22,6 +22,7 @@ import org.jetbrains.annotations.NotNull; import org.testcontainers.containers.JdbcDatabaseContainer; import org.testcontainers.containers.MariaDBContainer; import org.testcontainers.containers.PostgreSQLContainer; +import org.testcontainers.utility.DockerImageName; public class DatabaseContainer { @@ -66,11 +67,18 @@ public class DatabaseContainer { } 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) { case "postgres": - return new PostgreSQLContainer("postgres:alpine"); + return new PostgreSQLContainer(POSTGRES); case "mariadb": - return new MariaDBContainer("mariadb:10.5.9"); + return new MariaDBContainer(MARIADB); default: throw new RuntimeException("Unsupported database: " + alias); }