Use fixed ports in ci, necessary for woodpecker-ci
This commit is contained in:
parent
9552221cc4
commit
b7e60a7723
2 changed files with 29 additions and 17 deletions
9
pom.xml
9
pom.xml
|
@ -153,6 +153,15 @@
|
||||||
<groupId>org.jboss.resteasy</groupId>
|
<groupId>org.jboss.resteasy</groupId>
|
||||||
<artifactId>resteasy-multipart-provider</artifactId>
|
<artifactId>resteasy-multipart-provider</artifactId>
|
||||||
</exclusion>
|
</exclusion>
|
||||||
|
<!-- The POM for ... is invalid -->
|
||||||
|
<exclusion>
|
||||||
|
<groupId>com.sun.istack</groupId>
|
||||||
|
<artifactId>istack-commons-tools</artifactId>
|
||||||
|
</exclusion>
|
||||||
|
<exclusion>
|
||||||
|
<groupId>com.sun.istack</groupId>
|
||||||
|
<artifactId>istack-commons-runtime</artifactId>
|
||||||
|
</exclusion>
|
||||||
</exclusions>
|
</exclusions>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
|
|
|
@ -15,6 +15,7 @@ import org.junit.jupiter.api.extension.ParameterContext;
|
||||||
import org.junit.jupiter.api.extension.ParameterResolver;
|
import org.junit.jupiter.api.extension.ParameterResolver;
|
||||||
import org.keycloak.admin.client.Keycloak;
|
import org.keycloak.admin.client.Keycloak;
|
||||||
import org.keycloak.admin.client.token.TokenService;
|
import org.keycloak.admin.client.token.TokenService;
|
||||||
|
import org.testcontainers.containers.FixedHostPortGenericContainer;
|
||||||
import org.testcontainers.containers.GenericContainer;
|
import org.testcontainers.containers.GenericContainer;
|
||||||
import org.testcontainers.containers.wait.strategy.Wait;
|
import org.testcontainers.containers.wait.strategy.Wait;
|
||||||
import org.testcontainers.utility.MountableFile;
|
import org.testcontainers.utility.MountableFile;
|
||||||
|
@ -45,28 +46,30 @@ public class KeycloakExtension implements BeforeAllCallback, ParameterResolver {
|
||||||
throw new Exception("Failed to read properties", e);
|
throw new Exception("Failed to read properties", e);
|
||||||
}
|
}
|
||||||
var version = properties.getProperty("version");
|
var version = properties.getProperty("version");
|
||||||
|
var image = "quay.io/keycloak/keycloak:" + version;
|
||||||
var jar = properties.getProperty("jar");
|
var jar = properties.getProperty("jar");
|
||||||
var timeout = properties.getProperty("timeout");
|
var timeout = properties.getProperty("timeout");
|
||||||
|
|
||||||
// create and start container
|
// create and start container
|
||||||
|
|
||||||
@SuppressWarnings("resource")
|
@SuppressWarnings({ "resource", "deprecation" })
|
||||||
var container = new GenericContainer<>("quay.io/keycloak/keycloak:" + version)
|
var container = (System.getenv("CI") == null
|
||||||
.withEnv("KEYCLOAK_ADMIN", "admin")
|
? new GenericContainer<>(image).withExposedPorts(8080)
|
||||||
.withEnv("KEYCLOAK_ADMIN_PASSWORD", "password")
|
: new FixedHostPortGenericContainer<>(image).withFixedExposedPort(8080, 8080))
|
||||||
.withEnv("KC_LOG_LEVEL", "io.kokuwa:trace")
|
.withEnv("KEYCLOAK_ADMIN", "admin")
|
||||||
// otherwise port 9000 will be used, with this config we can test different keycloak versions
|
.withEnv("KEYCLOAK_ADMIN_PASSWORD", "password")
|
||||||
.withEnv("KC_LEGACY_OBSERVABILITY_INTERFACE", "true")
|
.withEnv("KC_LOG_LEVEL", "io.kokuwa:trace")
|
||||||
.withEnv("KC_HEALTH_ENABLED", "true")
|
// otherwise port 9000 will be used, with this config we can test different keycloak versions
|
||||||
.withEnv("KC_METRICS_ENABLED", "true")
|
.withEnv("KC_LEGACY_OBSERVABILITY_INTERFACE", "true")
|
||||||
.withEnv("KC_METRICS_STATS_ENABLED", "true")
|
.withEnv("KC_HEALTH_ENABLED", "true")
|
||||||
.withEnv("KC_METRICS_STATS_INTERVAL", "PT1s")
|
.withEnv("KC_METRICS_ENABLED", "true")
|
||||||
.withCopyFileToContainer(MountableFile.forHostPath(jar), "/opt/keycloak/providers/metrics.jar")
|
.withEnv("KC_METRICS_STATS_ENABLED", "true")
|
||||||
.withLogConsumer(out -> System.out.print(out.getUtf8String()))
|
.withEnv("KC_METRICS_STATS_INTERVAL", "PT1s")
|
||||||
.withExposedPorts(8080)
|
.withCopyFileToContainer(MountableFile.forHostPath(jar), "/opt/keycloak/providers/metrics.jar")
|
||||||
.withStartupTimeout(Duration.parse(timeout))
|
.withLogConsumer(out -> System.out.print(out.getUtf8String()))
|
||||||
.waitingFor(Wait.forHttp("/health").forPort(8080))
|
.withStartupTimeout(Duration.parse(timeout))
|
||||||
.withCommand("start-dev");
|
.waitingFor(Wait.forHttp("/health").forPort(8080).withStartupTimeout(Duration.ofMinutes(10)))
|
||||||
|
.withCommand("start-dev");
|
||||||
try {
|
try {
|
||||||
container.start();
|
container.start();
|
||||||
} catch (RuntimeException e) {
|
} catch (RuntimeException e) {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue