diff --git a/pom.xml b/pom.xml index 704807462e..c432697d2f 100644 --- a/pom.xml +++ b/pom.xml @@ -76,7 +76,7 @@ 2.2.220 6.2.5.Final 6.2.5.Final - 14.0.10.Final + 14.0.13.Final 4.6.2.Final @@ -812,6 +812,16 @@ infinispan-core-jakarta ${infinispan.version} + + org.infinispan + infinispan-commons + ${infinispan.version} + + + org.infinispan + infinispan-commons-jakarta + ${infinispan.version} + org.infinispan infinispan-cachestore-remote diff --git a/quarkus/tests/junit5/src/main/java/org/keycloak/it/junit5/extension/DatabaseContainer.java b/quarkus/tests/junit5/src/main/java/org/keycloak/it/junit5/extension/DatabaseContainer.java index 32e72c2a7d..ed385393c1 100644 --- a/quarkus/tests/junit5/src/main/java/org/keycloak/it/junit5/extension/DatabaseContainer.java +++ b/quarkus/tests/junit5/src/main/java/org/keycloak/it/junit5/extension/DatabaseContainer.java @@ -26,6 +26,7 @@ import org.testcontainers.containers.MSSQLServerContainer; import org.testcontainers.containers.MariaDBContainer; import org.testcontainers.containers.MySQLContainer; import org.testcontainers.containers.PostgreSQLContainer; +import org.testcontainers.images.PullPolicy; import org.testcontainers.utility.DockerImageName; public class DatabaseContainer { @@ -107,6 +108,13 @@ public class DatabaseContainer { String MARIADB_IMAGE = System.getProperty("kc.db.mariadb.container.image"); String MYSQL_IMAGE = System.getProperty("kc.db.mysql.container.image"); String INFINISPAN_IMAGE = System.getProperty("kc.infinispan.container.image"); + if (INFINISPAN_IMAGE.matches("quay.io/infinispan/.*-SNAPSHOT")) { + // If the image name ends with SNAPSHOT, someone is trying to use a snapshot release of Infinispan. + // Then switch to the closest match of the Infinispan test container + INFINISPAN_IMAGE = INFINISPAN_IMAGE.replaceAll("quay.io/infinispan/", "quay.io/infinispan-test/"); + INFINISPAN_IMAGE = INFINISPAN_IMAGE.replaceAll("[0-9]*-SNAPSHOT$", "x"); + } + String MSSQL_IMAGE = System.getProperty("kc.db.mssql.container.image"); switch (alias) { @@ -123,8 +131,13 @@ public class DatabaseContainer { DockerImageName MSSQL = DockerImageName.parse(MSSQL_IMAGE).asCompatibleSubstituteFor("sqlserver"); return configureJdbcContainer(new MSSQLServerContainer<>(MSSQL)); case "infinispan": - return configureInfinispanUser(new GenericContainer<>(INFINISPAN_IMAGE)) + GenericContainer infinispanContainer = configureInfinispanUser(new GenericContainer<>(INFINISPAN_IMAGE)) .withExposedPorts(11222); + // the images in the 'infinispan-test' repository point to tags that are frequently refreshed, therefore, always pull them + if (infinispanContainer.getDockerImageName().startsWith("quay.io/infinispan-test")) { + infinispanContainer.withImagePullPolicy(PullPolicy.alwaysPull()); + } + return infinispanContainer; default: throw new RuntimeException("Unsupported database: " + alias); } diff --git a/testsuite/integration-arquillian/tests/base/src/main/java/org/keycloak/testsuite/util/InfinispanContainer.java b/testsuite/integration-arquillian/tests/base/src/main/java/org/keycloak/testsuite/util/InfinispanContainer.java index 1fa33cd6c9..0b60b818a6 100644 --- a/testsuite/integration-arquillian/tests/base/src/main/java/org/keycloak/testsuite/util/InfinispanContainer.java +++ b/testsuite/integration-arquillian/tests/base/src/main/java/org/keycloak/testsuite/util/InfinispanContainer.java @@ -21,6 +21,7 @@ import org.jboss.logging.Logger; import org.keycloak.testsuite.arquillian.HotRodContainerProvider; import org.testcontainers.containers.GenericContainer; import org.testcontainers.containers.wait.strategy.Wait; +import org.testcontainers.images.PullPolicy; import org.testcontainers.utility.MountableFile; import java.io.IOException; @@ -50,10 +51,15 @@ public class InfinispanContainer extends GenericContainer { private static final Pattern IP_ADDRESS_PATTERN = Pattern.compile("listening on (" + IP_ADDRESS_REGEX + "):" + PORT); public InfinispanContainer() { - super("quay.io/infinispan/server:" + System.getProperty("infinispan.version")); + super(getImageName()); withEnv("USER", USERNAME); withEnv("PASS", PASSWORD); withNetworkMode("host"); + + // the images in the 'infinispan-test' repository point to tags that are frequently refreshed, therefore, always pull them + if (getImageName().startsWith("quay.io/infinispan-test")) { + withImagePullPolicy(PullPolicy.alwaysPull()); + } Path dir = Path.of(Path.of("").toAbsolutePath() + "/target/lib"); String projectVersion = System.getProperty("project.version"); @@ -72,6 +78,17 @@ public class InfinispanContainer extends GenericContainer { withStartupTimeout(Duration.ofMinutes(5)); } + private static String getImageName() { + String version = System.getProperty("infinispan.version"); + if (version.endsWith("-SNAPSHOT")) { + // for snapshot versions, '14.0.13-SNAPSHOT' translates to '14.0.x' + version = version.replaceAll("[0-9]*-SNAPSHOT$", "x"); + return "quay.io/infinispan-test/server:" + version; + } else { + return "quay.io/infinispan/server:" + version; + } + } + @Override public String getHost() { if (HOST == null && this.isRunning()) {