Skip to content

Commit

Permalink
Do not check attached containers health
Browse files Browse the repository at this point in the history
Health of these containers is checked by the origin process that
controls them.
  • Loading branch information
kokosing committed Oct 6, 2020
1 parent 62c87d2 commit ce97ec8
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -51,12 +51,10 @@
import static io.prestosql.tests.product.launcher.cli.Commands.runCommand;
import static io.prestosql.tests.product.launcher.docker.ContainerUtil.exposePort;
import static io.prestosql.tests.product.launcher.env.DockerContainer.cleanOrCreateHostPath;
import static io.prestosql.tests.product.launcher.env.Environment.allContainersHealthy;
import static io.prestosql.tests.product.launcher.env.EnvironmentContainers.TESTS;
import static io.prestosql.tests.product.launcher.env.EnvironmentListener.getStandardListeners;
import static io.prestosql.tests.product.launcher.env.common.Standard.CONTAINER_TEMPTO_PROFILE_CONFIG;
import static java.lang.StrictMath.toIntExact;
import static java.lang.String.format;
import static java.time.Duration.ofMinutes;
import static java.util.Objects.requireNonNull;
import static org.testcontainers.containers.BindMode.READ_ONLY;
Expand Down Expand Up @@ -212,22 +210,17 @@ private Environment startEnvironment()
Collection<DockerContainer> allContainers = environment.getContainers();
DockerContainer testsContainer = environment.getContainer(TESTS);

Collection<DockerContainer> environmentContainers = allContainers.stream()
.filter(container -> !container.equals(testsContainer))
.collect(toImmutableList());

if (!attach) {
// Reestablish dependency on every startEnvironment attempt
Collection<DockerContainer> environmentContainers = allContainers.stream()
.filter(container -> !container.equals(testsContainer))
.collect(toImmutableList());
testsContainer.dependsOn(environmentContainers);

log.info("Starting the environment '%s' with configuration %s", this.environment, environmentConfig);
environment.start();
}
else {
if (!allContainersHealthy(environmentContainers)) {
throw new RuntimeException(format("Could not attach tests to unhealthy environment %s", this.environment));
}

testsContainer.setNetwork(new ExistingNetwork(Environment.PRODUCT_TEST_LAUNCHER_NETWORK));
// TODO prune previous ptl-tests container
testsContainer.start();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ public long awaitTestsCompletion()
while (testContainer.isRunning()) {
Thread.sleep(10000); // check every 10 seconds

if (!allContainersHealthy(containers)) {
if (!attached && !allContainersHealthy(containers)) {
log.warn("Environment %s is not healthy, interrupting tests", name);
return ENVIRONMENT_FAILED_EXIT_CODE;
}
Expand Down Expand Up @@ -277,7 +277,7 @@ public void close()
}
}

public static boolean allContainersHealthy(Iterable<DockerContainer> containers)
private static boolean allContainersHealthy(Iterable<DockerContainer> containers)
{
return Streams.stream(containers)
.allMatch(Environment::containerIsHealthy);
Expand Down

0 comments on commit ce97ec8

Please sign in to comment.