Skip to content
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

modules/clickhouse: JDBC driver name changed, liveness port #5474

Merged
merged 7 commits into from
Jun 28, 2022
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
package org.testcontainers.containers;

import com.google.common.collect.Sets;
import org.testcontainers.containers.wait.strategy.HttpWaitStrategy;
import org.testcontainers.utility.DockerImageName;

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

public class ClickHouseContainer extends JdbcDatabaseContainer {
public class ClickHouseContainer extends JdbcDatabaseContainer<ClickHouseContainer> {

public static final String NAME = "clickhouse";

Expand Down Expand Up @@ -53,23 +53,27 @@ public ClickHouseContainer(final DockerImageName dockerImageName) {
super(dockerImageName);
dockerImageName.assertCompatibleWith(DEFAULT_IMAGE_NAME, CLICKHOUSE_IMAGE_NAME);

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

@Override
public Set<Integer> getLivenessCheckPortNumbers() {
return Sets.newHashSet(HTTP_PORT);
return new HashSet<>(getMappedPort(HTTP_PORT));
}

@Override
public String getDriverClassName() {
return DRIVER_CLASS_NAME;
try {
Class.forName(DRIVER_CLASS_NAME);
return DRIVER_CLASS_NAME;
} catch (ClassNotFoundException e) {
return "com.clickhouse.jdbc.ClickHouseDriver";
}
}

@Override
Expand Down