1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87
|
.. _development:
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.
Install test requirements and build package:
.. code-block:: bash
python testsrequire.py && python setup.py develop
You should install cython if you want to change ``*.pyx`` files:
.. code-block:: bash
pip install cython
ClickHouse on host machine
^^^^^^^^^^^^^^^^^^^^^^^^^^
Install desired versions of ``clickhouse-server`` and ``clickhouse-client`` on
your machine.
Run tests:
.. code-block:: bash
py.test -v
ClickHouse in docker
^^^^^^^^^^^^^^^^^^^^
Create container desired version of ``clickhouse-server``:
.. code-block:: bash
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``:
.. code-block:: bash
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:
.. code-block:: bash
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:
.. code-block:: bash
echo '127.0.0.1 clickhouse-server' | sudo tee -a /etc/hosts > /dev/null
Set ``TZ=UTC`` and run tests:
.. code-block:: bash
export TZ=UTC
py.test -v
GitHub Actions in forked repository
-----------------------------------
Workflows in forked repositories can be used for running tests.
Workflows don't run in forked repositories by default.
You must enable GitHub Actions in the **Actions** tab of the forked repository.
|