Faster Quarkus Docker based tests
This commit is contained in:
parent
8750d94140
commit
e1a2e27e6c
2 changed files with 4 additions and 10 deletions
|
@ -1,20 +1,15 @@
|
||||||
package org.keycloak.it.utils;
|
package org.keycloak.it.utils;
|
||||||
|
|
||||||
import org.apache.commons.io.FileUtils;
|
import org.apache.commons.io.FileUtils;
|
||||||
import org.apache.commons.io.IOUtils;
|
|
||||||
import org.jboss.logging.Logger;
|
import org.jboss.logging.Logger;
|
||||||
import org.keycloak.common.Version;
|
import org.keycloak.common.Version;
|
||||||
import org.testcontainers.containers.GenericContainer;
|
import org.testcontainers.containers.GenericContainer;
|
||||||
import org.testcontainers.containers.output.OutputFrame;
|
import org.testcontainers.containers.output.OutputFrame;
|
||||||
import org.testcontainers.containers.output.ToStringConsumer;
|
import org.testcontainers.containers.output.ToStringConsumer;
|
||||||
import org.testcontainers.containers.startupcheck.OneShotStartupCheckStrategy;
|
|
||||||
import org.testcontainers.containers.wait.strategy.Wait;
|
|
||||||
import org.testcontainers.containers.wait.strategy.WaitStrategy;
|
|
||||||
import org.testcontainers.images.builder.ImageFromDockerfile;
|
import org.testcontainers.images.builder.ImageFromDockerfile;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
import java.time.Duration;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public final class DockerKeycloakDistribution implements KeycloakDistribution {
|
public final class DockerKeycloakDistribution implements KeycloakDistribution {
|
||||||
|
@ -50,10 +45,7 @@ public final class DockerKeycloakDistribution implements KeycloakDistribution {
|
||||||
.withFileFromFile("Dockerfile", dockerFile)
|
.withFileFromFile("Dockerfile", dockerFile)
|
||||||
.withBuildArg("KEYCLOAK_DIST", "keycloakx.tar.gz")
|
.withBuildArg("KEYCLOAK_DIST", "keycloakx.tar.gz")
|
||||||
)
|
)
|
||||||
.withExposedPorts(8080)
|
.withExposedPorts(8080);
|
||||||
.withStartupTimeout(Duration.ofSeconds(40))
|
|
||||||
.withStartupAttempts(1)
|
|
||||||
.waitingFor(Wait.forHttp("/").forStatusCode(200).withReadTimeout(Duration.ofSeconds(2)));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public <T> DockerKeycloakDistribution(boolean debug, boolean manualStop, boolean reCreate) {
|
public <T> DockerKeycloakDistribution(boolean debug, boolean manualStop, boolean reCreate) {
|
||||||
|
@ -69,6 +61,7 @@ public final class DockerKeycloakDistribution implements KeycloakDistribution {
|
||||||
this.stderr = List.of();
|
this.stderr = List.of();
|
||||||
this.backupConsumer = new ToStringConsumer();
|
this.backupConsumer = new ToStringConsumer();
|
||||||
|
|
||||||
|
|
||||||
keycloakContainer = runKeycloakContainer();
|
keycloakContainer = runKeycloakContainer();
|
||||||
|
|
||||||
keycloakContainer
|
keycloakContainer
|
||||||
|
@ -95,12 +88,13 @@ public final class DockerKeycloakDistribution implements KeycloakDistribution {
|
||||||
this.stderr = getErrorStream();
|
this.stderr = getErrorStream();
|
||||||
|
|
||||||
keycloakContainer.stop();
|
keycloakContainer.stop();
|
||||||
keycloakContainer = null;
|
|
||||||
this.exitCode = 0;
|
this.exitCode = 0;
|
||||||
}
|
}
|
||||||
} catch (Exception cause) {
|
} catch (Exception cause) {
|
||||||
this.exitCode = -1;
|
this.exitCode = -1;
|
||||||
throw new RuntimeException("Failed to stop the server", cause);
|
throw new RuntimeException("Failed to stop the server", cause);
|
||||||
|
} finally {
|
||||||
|
keycloakContainer = null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue