Skip to content

use customized wait strategy in jdbc container #8759

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 7 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ public class GenericContainer<SELF extends GenericContainer<SELF>>
@Setter(AccessLevel.NONE)
private InspectContainerResponse containerInfo;

static WaitStrategy DEFAULT_WAIT_STRATEGY = Wait.defaultWaitStrategy();
protected static WaitStrategy DEFAULT_WAIT_STRATEGY = Wait.defaultWaitStrategy();

/**
* The approach to determine if the container is ready.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
package org.testcontainers.clickhouse;

import org.testcontainers.containers.JdbcDatabaseContainer;
import org.testcontainers.containers.wait.strategy.HttpWaitStrategy;
import org.testcontainers.utility.DockerImageName;

import java.time.Duration;
import java.util.HashSet;
import java.util.Set;

Expand Down Expand Up @@ -50,11 +48,6 @@ public ClickHouseContainer(final DockerImageName dockerImageName) {
dockerImageName.assertCompatibleWith(CLICKHOUSE_IMAGE_NAME);

addExposedPorts(HTTP_PORT, NATIVE_PORT);
this.waitStrategy =
new HttpWaitStrategy()
.forStatusCode(200)
.forResponsePredicate("Ok."::equals)
.withStartupTimeout(Duration.ofMinutes(1));
}

@Override
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
package org.testcontainers.containers;

import org.testcontainers.containers.wait.strategy.HttpWaitStrategy;
import org.testcontainers.utility.ComparableVersion;
import org.testcontainers.utility.DockerImageName;

import java.time.Duration;
import java.util.HashSet;
import java.util.Set;

Expand Down Expand Up @@ -65,11 +63,6 @@ public ClickHouseContainer(final DockerImageName dockerImageName) {
supportsNewDriver = isNewDriverSupported(dockerImageName);

addExposedPorts(HTTP_PORT, NATIVE_PORT);
this.waitStrategy =
new HttpWaitStrategy()
.forStatusCode(200)
.forResponsePredicate("Ok."::equals)
.withStartupTimeout(Duration.ofMinutes(1));
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,11 @@ public SELF withInitScripts(Iterable<String> initScriptPaths) {
@SneakyThrows(InterruptedException.class)
@Override
protected void waitUntilContainerStarted() {
if (getWaitStrategy() != DEFAULT_WAIT_STRATEGY) {
getWaitStrategy().waitUntilReady(this);
return;
}

logger()
.info(
"Waiting for database connection to become available at {} using query '{}'",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,10 @@

import com.google.common.base.Strings;
import org.jetbrains.annotations.NotNull;
import org.testcontainers.containers.wait.strategy.LogMessageWaitStrategy;
import org.testcontainers.utility.DockerImageName;

import java.sql.Connection;
import java.sql.SQLException;
import java.time.Duration;
import java.time.temporal.ChronoUnit;
import java.util.Set;

/**
Expand Down Expand Up @@ -47,11 +44,6 @@ public PrestoContainer(final DockerImageName dockerImageName) {
super(dockerImageName);
dockerImageName.assertCompatibleWith(DEFAULT_IMAGE_NAME);

this.waitStrategy =
new LogMessageWaitStrategy()
.withRegEx(".*======== SERVER STARTED ========.*")
.withStartupTimeout(Duration.of(60, ChronoUnit.SECONDS));

addExposedPort(PRESTO_PORT);
}

Expand Down
Loading