Faster Quarkus Docker based tests

This commit is contained in:
andreaTP 2021-12-06 11:07:51 +00:00 committed by Pedro Igor
parent 8750d94140
commit e1a2e27e6c
2 changed files with 4 additions and 10 deletions

View file

@ -1,20 +1,15 @@
package org.keycloak.it.utils;
import org.apache.commons.io.FileUtils;
import org.apache.commons.io.IOUtils;
import org.jboss.logging.Logger;
import org.keycloak.common.Version;
import org.testcontainers.containers.GenericContainer;
import org.testcontainers.containers.output.OutputFrame;
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 java.io.File;
import java.net.URL;
import java.time.Duration;
import java.util.List;
public final class DockerKeycloakDistribution implements KeycloakDistribution {
@ -50,10 +45,7 @@ public final class DockerKeycloakDistribution implements KeycloakDistribution {
.withFileFromFile("Dockerfile", dockerFile)
.withBuildArg("KEYCLOAK_DIST", "keycloakx.tar.gz")
)
.withExposedPorts(8080)
.withStartupTimeout(Duration.ofSeconds(40))
.withStartupAttempts(1)
.waitingFor(Wait.forHttp("/").forStatusCode(200).withReadTimeout(Duration.ofSeconds(2)));
.withExposedPorts(8080);
}
public <T> DockerKeycloakDistribution(boolean debug, boolean manualStop, boolean reCreate) {
@ -69,6 +61,7 @@ public final class DockerKeycloakDistribution implements KeycloakDistribution {
this.stderr = List.of();
this.backupConsumer = new ToStringConsumer();
keycloakContainer = runKeycloakContainer();
keycloakContainer
@ -95,12 +88,13 @@ public final class DockerKeycloakDistribution implements KeycloakDistribution {
this.stderr = getErrorStream();
keycloakContainer.stop();
keycloakContainer = null;
this.exitCode = 0;
}
} catch (Exception cause) {
this.exitCode = -1;
throw new RuntimeException("Failed to stop the server", cause);
} finally {
keycloakContainer = null;
}
}