-
Notifications
You must be signed in to change notification settings - Fork 7.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #4713 from Enmk/test_runner_for_stateless_tests
Fixed test failures when running clickhouse-server on different host
- Loading branch information
Showing
13 changed files
with
164 additions
and
67 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
17 changes: 10 additions & 7 deletions
17
docker/test/stateless/clickhouse-statelest-test-runner.Dockerfile
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,15 @@ | ||
FROM ubuntu:18.10 | ||
# Since right now we can't set volumes to the docker during build, we split building container in stages: | ||
# 1. build base container | ||
# 2. run base conatiner with mounted volumes | ||
# 3. commit container as image | ||
FROM ubuntu:18.10 as clickhouse-test-runner-base | ||
|
||
ARG CLICKHOUSE_PACKAGES_DIR | ||
COPY ${CLICKHOUSE_PACKAGES_DIR}/clickhouse-*.deb /packages/ | ||
# A volume where directory with clickhouse packages to be mounted, | ||
# for later installing. | ||
VOLUME /packages | ||
|
||
RUN apt-get update ;\ | ||
CMD apt-get update ;\ | ||
DEBIAN_FRONTEND=noninteractive \ | ||
apt install -y /packages/clickhouse-common-static_*.deb \ | ||
/packages/clickhouse-client_*.deb \ | ||
/packages/clickhouse-test_*.deb \ | ||
wait-for-it; \ | ||
rm -rf /packages | ||
/packages/clickhouse-test_*.deb |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,31 +1,84 @@ | ||
#!/bin/sh | ||
|
||
set -e | ||
set -e -x | ||
|
||
# Run tests in docker | ||
# OR | ||
# Build containers from deb packages, copying the tests from the source directory | ||
trap 'rc=$?; echo EXITED WITH: $rc; exit $rc' EXIT | ||
|
||
# CLI option to prevent rebuilding images, just re-run tests with images leftover from previuos time | ||
readonly NO_REBUILD_FLAG="--no-rebuild" | ||
|
||
readonly CLICKHOUSE_DOCKER_DIR="$(realpath ${1})" | ||
readonly CLICKHOUSE_PACKAGES_DIR="${2}" | ||
readonly CLICKHOUSE_PACKAGES_ARG="${2}" | ||
CLICKHOUSE_SERVER_IMAGE="${3}" | ||
|
||
# Build test runner image | ||
docker build \ | ||
-f "${CLICKHOUSE_DOCKER_DIR}/test/stateless/clickhouse-statelest-test-runner.Dockerfile" \ | ||
-t clickhouse-statelest-test-runner:local \ | ||
--build-arg CLICKHOUSE_PACKAGES_DIR="${CLICKHOUSE_PACKAGES_DIR}" \ | ||
"${CLICKHOUSE_DOCKER_DIR}" | ||
if [ ${CLICKHOUSE_PACKAGES_ARG} != ${NO_REBUILD_FLAG} ]; then | ||
readonly CLICKHOUSE_PACKAGES_DIR="$(realpath ${2})" # or --no-rebuild | ||
fi | ||
|
||
|
||
# In order to allow packages directory to be anywhere, and to reduce amoun of context sent to the docker daemon, | ||
# all images are built in multiple stages: | ||
# 1. build base image, install dependencies | ||
# 2. run image with volume mounted, install what needed from those volumes | ||
# 3. tag container as image | ||
# 4. [optional] build another image atop of tagged. | ||
|
||
# TODO: optionally mount most recent clickhouse-test and queries directory from local machine | ||
|
||
if [ ${CLICKHOUSE_PACKAGES_ARG} != ${NO_REBUILD_FLAG} ]; then | ||
docker build \ | ||
-f "${CLICKHOUSE_DOCKER_DIR}/test/stateless/clickhouse-statelest-test-runner.Dockerfile" \ | ||
--target clickhouse-test-runner-base \ | ||
-t clickhouse-test-runner-base:preinstall \ | ||
"${CLICKHOUSE_DOCKER_DIR}/test/stateless" | ||
|
||
docker rm -f clickhouse-test-runner-installing-packages || true | ||
docker run \ | ||
-v "${CLICKHOUSE_PACKAGES_DIR}:/packages" \ | ||
--name clickhouse-test-runner-installing-packages \ | ||
clickhouse-test-runner-base:preinstall | ||
docker commit clickhouse-test-runner-installing-packages clickhouse-statelest-test-runner:local | ||
docker rm -f clickhouse-test-runner-installing-packages || true | ||
fi | ||
|
||
# # Create a bind-volume to the clickhouse-test script file | ||
# docker volume create --driver local --opt type=none --opt device=/home/enmk/proj/ClickHouse_master/dbms/tests/clickhouse-test --opt o=bind clickhouse-test-script-volume | ||
# docker volume create --driver local --opt type=none --opt device=/home/enmk/proj/ClickHouse_master/dbms/tests/queries --opt o=bind clickhouse-test-queries-dir-volume | ||
|
||
# Build server image (optional) from local packages | ||
if [ -z "${CLICKHOUSE_SERVER_IMAGE}" ]; then | ||
CLICKHOUSE_SERVER_IMAGE="yandex/clickhouse_server:local" | ||
CLICKHOUSE_SERVER_IMAGE="yandex/clickhouse-server:local" | ||
|
||
docker build \ | ||
-f "${CLICKHOUSE_DOCKER_DIR}/server/local.Dockerfile" \ | ||
-t "${CLICKHOUSE_SERVER_IMAGE}" \ | ||
--build-arg CLICKHOUSE_PACKAGES_DIR=${CLICKHOUSE_PACKAGES_DIR} \ | ||
"${CLICKHOUSE_DOCKER_DIR}" | ||
if [ ${CLICKHOUSE_PACKAGES_ARG} != ${NO_REBUILD_FLAG} ]; then | ||
docker build \ | ||
-f "${CLICKHOUSE_DOCKER_DIR}/server/local.Dockerfile" \ | ||
--target clickhouse-server-base \ | ||
-t clickhouse-server-base:preinstall \ | ||
"${CLICKHOUSE_DOCKER_DIR}/server" | ||
|
||
docker rm -f clickhouse_server_base_installing_server || true | ||
docker run -v "${CLICKHOUSE_PACKAGES_DIR}:/packages" \ | ||
--name clickhouse_server_base_installing_server \ | ||
clickhouse-server-base:preinstall | ||
docker commit clickhouse_server_base_installing_server clickhouse-server-base:postinstall | ||
|
||
docker build \ | ||
-f "${CLICKHOUSE_DOCKER_DIR}/server/local.Dockerfile" \ | ||
--target clickhouse-server \ | ||
-t "${CLICKHOUSE_SERVER_IMAGE}" \ | ||
"${CLICKHOUSE_DOCKER_DIR}/server" | ||
fi | ||
fi | ||
|
||
CLICKHOUSE_SERVER_IMAGE="${CLICKHOUSE_SERVER_IMAGE}" docker-compose -f "${CLICKHOUSE_DOCKER_DIR}/test/test_runner_docker_compose.yaml" run test-runner | ||
docker rm -f test-runner || true | ||
docker-compose down | ||
CLICKHOUSE_SERVER_IMAGE="${CLICKHOUSE_SERVER_IMAGE}" \ | ||
docker-compose -f "${CLICKHOUSE_DOCKER_DIR}/test/test_runner_docker_compose.yaml" \ | ||
create \ | ||
--build --force-recreate | ||
|
||
CLICKHOUSE_SERVER_IMAGE="${CLICKHOUSE_SERVER_IMAGE}" \ | ||
docker-compose -f "${CLICKHOUSE_DOCKER_DIR}/test/test_runner_docker_compose.yaml" \ | ||
run \ | ||
--name test-runner \ | ||
test-runner |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters