Skip to content

Commit

Permalink
[clickhouse] Add new JDBC driver name (#5474)
Browse files Browse the repository at this point in the history
Also, fix the liveness port.

Co-authored-by: Sergei Egorov <bsideup@gmail.com>
Co-authored-by: Eddú Meléndez <eddu.melendez@gmail.com>
  • Loading branch information
3 people committed Jun 28, 2022
1 parent 5a2d76f commit e23f378
Showing 1 changed file with 13 additions and 9 deletions.
@@ -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

0 comments on commit e23f378

Please sign in to comment.