Skip to content
Open
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
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ Integration tests usually require [Docker](https://docs.docker.com/engine/instal
| `TEST_CLICKHOUSE_PASSWORD` | `test_default_password` | Password |
| `TEST_CLICKHOUSE_SECURE` | `false` | `true` uses HTTPS on port 8443 (ClickHouse Cloud) |
| `TEST_CLICKHOUSE_TIMEZONE` | `UTC` | Timezone inside a started container |
| `TEST_CLICKHOUSE_ADDITIONAL_PACKAGES` | | Extra apt packages installed into the image |
| `TEST_CLICKHOUSE_ADDITIONAL_PACKAGES` | | Extra apt packages installed into the image. Needs an image with `apt-get`: from ClickHouse 26.12, use a tag with the suffix `-ubuntu` (the default image has no shell) |
| `TEST_DB_NAME` | generated | Database name. An external name must start with `clickhouse_java_test_` |
| `TEST_PROXY_ADDRESS` | | External proxy as `host:port` |
| `TEST_PROXY_IMAGE` | `ghcr.io/shopify/toxiproxy:2.5.0` | Toxiproxy image |
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import org.testcontainers.containers.Network;
import org.testcontainers.containers.wait.strategy.Wait;
import org.testcontainers.images.builder.ImageFromDockerfile;
import org.testcontainers.utility.MountableFile;

import java.time.Duration;
import java.util.List;
Expand All @@ -27,7 +28,7 @@ public abstract class ClickHouseContainerStarter {

static final String FRONTEND_ALIAS = "clickhouse";
static final String CONTAINER_TMP_DIR = "/tmp";
private static final String CUSTOM_DIRECTORY = "/custom";
private static final String SERVER_CONFIG_DIRECTORY = "/etc/clickhouse-server";
private static final String CONFIG_RESOURCE = "containers/clickhouse-server";

protected final ClickHouseTestEnvironment environment;
Expand Down Expand Up @@ -124,12 +125,10 @@ protected final GenericContainer<?> newClickHouseServer(String networkAlias, Str
.from(environment.getImageRef())
.run("apt-get update && apt-get install -y " + additionalPackages))))
.withCreateContainerCmdModifier(command -> {
command.withEntrypoint("/bin/sh");
if (containerName != null) {
command.withName(containerName);
}
})
.withCommand("-c", String.format("chmod +x %1$s/patch && %1$s/patch", CUSTOM_DIRECTORY))
.withEnv("TZ", environment.getTimezone())
.withExposedPorts(
ClickHouseProtocol.GRPC.getDefaultPort(),
Expand All @@ -139,7 +138,9 @@ protected final GenericContainer<?> newClickHouseServer(String networkAlias, Str
ClickHouseProtocol.TCP.getDefaultPort(),
ClickHouseProtocol.TCP.getDefaultSecurePort(),
ClickHouseProtocol.POSTGRESQL.getDefaultPort())
.withClasspathResourceMapping(CONFIG_RESOURCE, CUSTOM_DIRECTORY, BindMode.READ_ONLY)
// The default image has no shell: copy the files into the configuration directory of the
// image (a copy merges with the files of the image), and keep the entrypoint of the image.
.withCopyFileToContainer(MountableFile.forClasspathResource(CONFIG_RESOURCE), SERVER_CONFIG_DIRECTORY)
.withClasspathResourceMapping("empty.csv", "/var/lib/clickhouse/user_files/empty.csv",
BindMode.READ_ONLY)
.withFileSystemBind(System.getProperty("java.io.tmpdir"), CONTAINER_TMP_DIR, BindMode.READ_WRITE)
Expand All @@ -149,10 +150,12 @@ protected final GenericContainer<?> newClickHouseServer(String networkAlias, Str
container = container
.withEnv("CLICKHOUSE_REPLICA", replicaName)
.withEnv("CLICKHOUSE_INTERSERVER_HOST", networkAlias)
.withClasspathResourceMapping("containers/clickhouse-cluster/config.d/custom_config.xml",
CUSTOM_DIRECTORY + "/config.d/custom_config.xml", BindMode.READ_ONLY)
.withClasspathResourceMapping("containers/clickhouse-cluster/users.d/cluster_quorum.xml",
CUSTOM_DIRECTORY + "/users.d/cluster_quorum.xml", BindMode.READ_ONLY);
.withCopyFileToContainer(MountableFile.forClasspathResource(
"containers/clickhouse-cluster/config.d/custom_config.xml"),
SERVER_CONFIG_DIRECTORY + "/config.d/custom_config.xml")
.withCopyFileToContainer(MountableFile.forClasspathResource(
"containers/clickhouse-cluster/users.d/cluster_quorum.xml"),
SERVER_CONFIG_DIRECTORY + "/users.d/cluster_quorum.xml");
}
return container.waitingFor(Wait.forHttp("/ping").forPort(HTTP_PORT)
.forStatusCode(200).withStartupTimeout(Duration.of(600, SECONDS)));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,16 +36,14 @@ final class ClusterClickHouseContainerStarter extends ClickHouseContainerStarter
String baseName = environment.getContainerName();
this.keeper = new GenericContainer<>(environment.getImageRef())
.withCreateContainerCmdModifier(command -> {
command.withEntrypoint("/bin/sh");
command.withEntrypoint("/usr/bin/clickhouse");
if (baseName != null) {
command.withName(baseName + "-keeper");
}
})
.withNetwork(network)
.withNetworkAliases("clickhouse-keeper")
.withCommand("-c", "mkdir -p /var/lib/clickhouse/coordination/log"
+ " /var/lib/clickhouse/coordination/snapshots"
+ " && exec clickhouse-keeper --config-file=/etc/clickhouse-keeper/keeper_config.xml")
.withCommand("keeper", "--config-file=/etc/clickhouse-keeper/keeper_config.xml")
.withClasspathResourceMapping(KEEPER_CONFIG, "/etc/clickhouse-keeper/keeper_config.xml",
BindMode.READ_ONLY)
.withExposedPorts(KEEPER_PORT)
Expand Down

This file was deleted.

Loading