Skip to content

Commit

Permalink
Patch container before integration test
Browse files Browse the repository at this point in the history
  • Loading branch information
zhicwu committed Apr 4, 2022
1 parent 096fcf2 commit e86bd13
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -97,23 +97,22 @@ public class ClickHouseServerForTest {
}

final String additionalPackages = customPackages;

final String customDirectory = "/custom";
clickhouseContainer = (ClickHouseChecker.isNullOrEmpty(additionalPackages)
? new GenericContainer<>(imageNameWithTag)
: new GenericContainer<>(new ImageFromDockerfile().withDockerfileFromBuilder(builder -> builder
.from(imageNameWithTag).run("apt-get update && apt-get install -y " + additionalPackages))))
.withEnv("TZ", timezone)
.withExposedPorts(ClickHouseProtocol.GRPC.getDefaultPort(),
ClickHouseProtocol.HTTP.getDefaultPort(),
ClickHouseProtocol.MYSQL.getDefaultPort(),
ClickHouseProtocol.TCP.getDefaultPort(),
ClickHouseProtocol.POSTGRESQL.getDefaultPort())
.withClasspathResourceMapping("containers/clickhouse-server/config.d",
"/etc/clickhouse-server/config.d", BindMode.READ_ONLY)
.withClasspathResourceMapping("containers/clickhouse-server/users.d",
"/etc/clickhouse-server/users.d", BindMode.READ_ONLY)
.waitingFor(Wait.forHttp("/ping").forPort(ClickHouseProtocol.HTTP.getDefaultPort())
.forStatusCode(200).withStartupTimeout(Duration.of(60, SECONDS)));
.withCreateContainerCmdModifier(it -> it.withEntrypoint("/bin/sh"))
.withCommand("-c", String.format("chmod +x %1$s/patch && %1$s/patch", customDirectory))
.withEnv("TZ", timezone)
.withExposedPorts(ClickHouseProtocol.GRPC.getDefaultPort(),
ClickHouseProtocol.HTTP.getDefaultPort(),
ClickHouseProtocol.MYSQL.getDefaultPort(),
ClickHouseProtocol.TCP.getDefaultPort(),
ClickHouseProtocol.POSTGRESQL.getDefaultPort())
.withClasspathResourceMapping("containers/clickhouse-server", customDirectory, BindMode.READ_ONLY)
.waitingFor(Wait.forHttp("/ping").forPort(ClickHouseProtocol.HTTP.getDefaultPort())
.forStatusCode(200).withStartupTimeout(Duration.of(60, SECONDS)));
}
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#!/bin/bash

set -e

SERVER_CONF_DIR="/etc/clickhouse-server"
ROOT_ELEMENT="yandex"
REPLACE_TO="clickhouse"

if [ -n "$(grep 'yandex>' /entrypoint.sh >/dev/null)" ]; then
ROOT_ELEMENT="clickhouse"
REPLACE_TO="yandex"
fi

\cp -rfv "$(dirname $0)/." $SERVER_CONF_DIR
find $SERVER_CONF_DIR -type f -name "*.xml" -exec sed -i -e "s|$ROOT_ELEMENT>|$REPLACE_TO>|g" {} \; || true

/entrypoint.sh

0 comments on commit e86bd13

Please sign in to comment.