Development

Test configuration

In setup.cfg you can find ClickHouse server port, credentials, logging level and another options than can be tuned during local testing.

Running tests locally

Install desired Python version with system package manager/pyenv/another manager.

ClickHouse on host machine

Install desired versions of clickhouse-server and clickhouse-client on your machine.

Run tests:

python setup.py test

ClickHouse in docker

Create container desired version of clickhouse-server:

docker run --rm -e "TZ=Europe/Moscow" -p 127.0.0.1:9000:9000 --name test-clickhouse-server yandex/clickhouse-server:$VERSION

Create container with the same version of clickhouse-client:

docker run --rm --entrypoint "/bin/sh" --name test-clickhouse-client --link test-clickhouse-server:clickhouse-server yandex/clickhouse-client:$VERSION -c 'while :; do sleep 1; done'

Create clickhouse-client script on your host machine:

echo -e '#!/bin/bash\n\ndocker exec -e "`env | grep ^TZ=`" test-clickhouse-client clickhouse-client "$@"' | sudo tee /usr/local/bin/clickhouse-client > /dev/null
sudo chmod +x /usr/local/bin/clickhouse-client

After it container test-clickhouse-client will communicate with test-clickhouse-server transparently from host machine.

Set host=clickhouse-server in setup.cfg.

Add entry in hosts file:

echo '127.0.0.1 clickhouse-server' | sudo tee -a /etc/hosts > /dev/null

Set TZ=UTC and run tests:

export TZ=UTC
python setup.py test