2019-02-11 07:57:51 +00:00
|
|
|
#!/bin/sh
|
|
|
|
|
2019-02-21 09:21:20 +00:00
|
|
|
set -e -x
|
2019-02-11 07:57:51 +00:00
|
|
|
|
2020-09-30 17:06:14 +00:00
|
|
|
# Not sure why shellcheck complains that rc is not assigned before it is referenced.
|
|
|
|
# shellcheck disable=SC2154
|
2019-02-21 09:21:20 +00:00
|
|
|
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"
|
2019-02-11 07:57:51 +00:00
|
|
|
|
2020-09-30 17:06:14 +00:00
|
|
|
readonly CLICKHOUSE_DOCKER_DIR="$(realpath "${1}")"
|
2019-02-21 09:21:20 +00:00
|
|
|
readonly CLICKHOUSE_PACKAGES_ARG="${2}"
|
2019-02-11 07:57:51 +00:00
|
|
|
CLICKHOUSE_SERVER_IMAGE="${3}"
|
|
|
|
|
2020-09-30 17:06:14 +00:00
|
|
|
if [ "${CLICKHOUSE_PACKAGES_ARG}" != "${NO_REBUILD_FLAG}" ]; then
|
|
|
|
readonly CLICKHOUSE_PACKAGES_DIR="$(realpath "${2}")" # or --no-rebuild
|
2019-02-21 09:21:20 +00:00
|
|
|
fi
|
|
|
|
|
|
|
|
|
2020-06-29 11:19:06 +00:00
|
|
|
# In order to allow packages directory to be anywhere, and to reduce amount of context sent to the docker daemon,
|
2019-02-21 09:21:20 +00:00
|
|
|
# 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
|
|
|
|
|
2020-09-30 17:06:14 +00:00
|
|
|
if [ "${CLICKHOUSE_PACKAGES_ARG}" != "${NO_REBUILD_FLAG}" ]; then
|
2020-06-29 11:19:06 +00:00
|
|
|
docker build --network=host \
|
2020-05-29 00:42:25 +00:00
|
|
|
-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
|
2020-06-29 11:19:06 +00:00
|
|
|
docker run --network=host \
|
2020-05-29 00:42:25 +00:00
|
|
|
-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
|
2019-02-21 09:21:20 +00:00
|
|
|
fi
|
|
|
|
|
|
|
|
# # Create a bind-volume to the clickhouse-test script file
|
2020-04-01 23:51:21 +00:00
|
|
|
# docker volume create --driver local --opt type=none --opt device=/home/enmk/proj/ClickHouse_master/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/tests/queries --opt o=bind clickhouse-test-queries-dir-volume
|
2019-02-11 07:57:51 +00:00
|
|
|
|
|
|
|
# Build server image (optional) from local packages
|
|
|
|
if [ -z "${CLICKHOUSE_SERVER_IMAGE}" ]; then
|
2020-05-29 00:42:25 +00:00
|
|
|
CLICKHOUSE_SERVER_IMAGE="yandex/clickhouse-server:local"
|
|
|
|
|
2020-09-30 17:06:14 +00:00
|
|
|
if [ "${CLICKHOUSE_PACKAGES_ARG}" != "${NO_REBUILD_FLAG}" ]; then
|
2020-06-29 11:19:06 +00:00
|
|
|
docker build --network=host \
|
2020-05-29 00:42:25 +00:00
|
|
|
-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
|
2020-06-29 11:19:06 +00:00
|
|
|
docker run --network=host -v "${CLICKHOUSE_PACKAGES_DIR}:/packages" \
|
2020-05-29 00:42:25 +00:00
|
|
|
--name clickhouse_server_base_installing_server \
|
|
|
|
clickhouse-server-base:preinstall
|
|
|
|
docker commit clickhouse_server_base_installing_server clickhouse-server-base:postinstall
|
|
|
|
|
2020-06-29 11:19:06 +00:00
|
|
|
docker build --network=host \
|
2020-05-29 00:42:25 +00:00
|
|
|
-f "${CLICKHOUSE_DOCKER_DIR}/server/local.Dockerfile" \
|
|
|
|
--target clickhouse-server \
|
|
|
|
-t "${CLICKHOUSE_SERVER_IMAGE}" \
|
|
|
|
"${CLICKHOUSE_DOCKER_DIR}/server"
|
|
|
|
fi
|
2019-02-11 07:57:51 +00:00
|
|
|
fi
|
|
|
|
|
2019-02-21 09:21:20 +00:00
|
|
|
docker rm -f test-runner || true
|
|
|
|
docker-compose down
|
|
|
|
CLICKHOUSE_SERVER_IMAGE="${CLICKHOUSE_SERVER_IMAGE}" \
|
2020-05-29 00:42:25 +00:00
|
|
|
docker-compose -f "${CLICKHOUSE_DOCKER_DIR}/test/test_runner_docker_compose.yaml" \
|
|
|
|
create \
|
|
|
|
--build --force-recreate
|
2019-02-21 09:21:20 +00:00
|
|
|
|
|
|
|
CLICKHOUSE_SERVER_IMAGE="${CLICKHOUSE_SERVER_IMAGE}" \
|
2020-05-29 00:42:25 +00:00
|
|
|
docker-compose -f "${CLICKHOUSE_DOCKER_DIR}/test/test_runner_docker_compose.yaml" \
|
|
|
|
run \
|
|
|
|
--name test-runner \
|
|
|
|
test-runner
|