(highly not recommended) If you really want to use OS packages on modern debian/ubuntu instead of "pip": sudo apt install -y docker docker-compose python3-pytest python3-dicttoxml python3-docker python3-pymysql python3-pymongo python3-tzlocal python3-kazoo python3-psycopg2 kafka-python python3-pytest-timeout python3-minio
If you want to run the tests under a non-privileged user, you must add this user to docker group: sudo usermod -aG docker $USER and re-login.
(You must close all your sessions (for example, restart your computer))
To check, that you have access to Docker, run docker ps.
Run the tests with the pytest command. To select which tests to run, use: pytest -k <test_name_pattern>
By default tests are run with system-wide client binary, server binary and base configs. To change that,
set the following environment variables:`
CLICKHOUSE_TESTS_SERVER_BIN_PATH to choose the server binary.
CLICKHOUSE_TESTS_CLIENT_BIN_PATH to choose the client binary.
CLICKHOUSE_TESTS_BASE_CONFIG_DIR to choose the directory from which base configs (config.xml and
users.xml) are taken.
For tests that use common docker compose files you may need to set up their path with environment variable: DOCKER_COMPOSE_DIR=$HOME/ClickHouse/docker/test/integration/runner/compose
Running with runner script
The only requirement is fresh configured docker and
docker pull yandex/clickhouse-integration-tests-runner
Notes:
If you want to run integration tests without sudo you have to add your user to docker group sudo usermod -aG docker $USER. More information about docker configuration.
If you already had run these tests without ./runner script you may have problems with pytest cache. It can be removed with rm -r __pycache__ .pytest_cache/.
Some tests maybe require a lot of resources (CPU, RAM, etc.). Better not try large tests like test_cluster_copier or test_distributed_ddl* on your laptop.
You can run tests via ./runner script and pass pytest arguments as last arg:
You can just open shell inside a container by overwritting the command:
./runner --command=bash
Rebuilding the docker containers
The main container used for integration tests lives in docker/test/integration/Dockerfile. Rebuild it with
cd docker/test/integration
docker build -t yandex/clickhouse-integration-test .
The helper container used by the runner script is in docker/test/integration/runner/Dockerfile.
Adding new tests
To add new test named foo, create a directory test_foo with an empty __init__.py and a file
named test.py containing tests in it. All functions with names starting with test will become test cases.
helpers directory contains utilities for:
Launching a ClickHouse cluster with or without ZooKeeper in docker containers.
Sending queries to launched instances.
Introducing network failures such as severing network link between two instances.
To assert that two TSV files must be equal, wrap them in the TSV class and use the regular assert
statement. Example: assert TSV(result) == TSV(reference). In case the assertion fails, pytest
will automagically detect the types of variables and only the small diff of two files is printed.