Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

copy whl from outer context; stop on fail #18

Merged
merged 2 commits into from
Jul 10, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 10 additions & 5 deletions .github/workflows/workflow.yml
Original file line number Diff line number Diff line change
Expand Up @@ -87,15 +87,20 @@ jobs:

- {name: run unit tests, run: pytest}

- name: prepare docker images for integration tests
run: CLICKHOUSE_VERSION=${{ matrix.clickhouse }} make test-integration-prepare

- name: prepare integration tests
run: |
cd tests
CLICKHOUSE_VERSION=${{ matrix.clickhouse }} python3 -m env_control create
cd ..

- name: run integration tests
run: make test-integration
run: |
cd tests
behave --show-timings --junit -D skip_setup
cd ..

- name: publish test report
uses: mikepenz/action-junit-report@v3
if: always()
with:
report_paths: 'tests/reports/*.xml'

2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

## General info

Hello! In order for us (YANDEX LLC) to accept patches and other contributions from you, you will have to adopt our Yandex Contributor License Agreement (the “**CLA**”). The current version of the CLA can be found here:
Hello! In order for us (YANDEX LLC) to accept patches and other contributions from you, you will have to adopt our Yandex Contributor License Agreement (the "**CLA**"). The current version of the CLA can be found here:
1) https://yandex.ru/legal/cla/?lang=en (in English) and
2) https://yandex.ru/legal/cla/?lang=ru (in Russian).

Expand Down
9 changes: 0 additions & 9 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -82,15 +82,6 @@ version.txt:
build-deb-package: prepare-changelog
cd debian && debuild --check-dirname-level 0 --preserve-env --no-lintian --no-tgz-check -uc -us

export CLICKHOUSE_VERSION?=latest

test-integration-prepare:
cp dist/*.whl tests/
cd tests && CLICKHOUSE_VERSION=${CLICKHOUSE_VERSION} python3 -m env_control create

test-integration:
cd tests && behave --show-timings -D skip_setup --junit

.PHONY: help
help:
@echo "Base targets:"
Expand Down
33 changes: 28 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,20 +14,43 @@ All of these tools must be run on the same host as ClickHouse server is running.

## Local development (using venv)

```bash
```sh
python3 -m venv venv
source venv/bin/activate
pip install .[test]
flit install
flit build --no-use-vcs
flit install

# lint
black .
isort .

# run tests
# unit tests
pytest

CLICKHOUSE_VERSION="1.2.3.4" make test-integration-prepare
make test-integration
# integration tests (rebuild docker images using a .whl file)
cd tests; behave

# integration tests (do not rebuild docker images)
# useful when you didn't change source code
cd tests; behave -D skip_setup

# integration tests (supply a custom ClickHouse version to test against)
cd tests; CLICKHOUSE_VERSION="1.2.3.4" behave

# If you want to have containers running on failure, supply a flag:
# behave -D no_stop_on_fail
```

Please note: base images for tests are pulled from [chtools Dockerhub](https://hub.docker.com/u/chtools).
If you want to build base images locally, run

```sh
docker buildx bake -f tests/bake.hcl
```

If you want to build base images for multiple versions of ClickHouse, run:

```sh
CLICKHOUSE_VERSIONS='1.2.3.4, 5.6.7.8, latest' docker buildx bake -f tests/bake.hcl
```
2 changes: 1 addition & 1 deletion tests/configuration.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ def create():
},
"depends_on": ["zookeeper"],
"args": {
"CLICKHOUSE_VERSION": "$CLICKHOUSE_VERSION",
"CLICKHOUSE_VERSION": "${CLICKHOUSE_VERSION:-latest}",
},
"db": {
"user": "reader",
Expand Down
6 changes: 4 additions & 2 deletions tests/environment.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,9 @@ def after_all(context):
"""
Clean up.
"""
if context.failed and not context.aborted:
logging.warning("Remember to run `make clean` after you done")
if (context.failed and not context.aborted) and context.config.userdata.getbool(
"no_stop_on_fail"
):
logging.info("Not stopping containers on failure as requested")
return
env_control.stop(context)
2 changes: 1 addition & 1 deletion tests/images/clickhouse/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
ARG CLICKHOUSE_VERSION
FROM chtools/test-clickhouse:$CLICKHOUSE_VERSION

COPY *.whl /
COPY dist/*.whl /
RUN pip3 install *.whl
2 changes: 1 addition & 1 deletion tests/images/zookeeper/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM chtools/test-zookeeper

COPY *.whl /
COPY dist/*.whl /
RUN python3 -m pip install *.whl
4 changes: 2 additions & 2 deletions tests/modules/compose.py
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ def _generate_service_config(
All paths are relative to the location of compose-config.yaml
(which is ./staging/compose-config.yaml by default)
"""
staging_dir = config["staging_dir"]
staging_dir = "tests/" + config["staging_dir"]
network_name = config["network_name"]

volumes = [f"./images/{instance_name}/config:/config:rw"]
Expand All @@ -164,7 +164,7 @@ def _generate_service_config(

service = {
"build": {
"context": "..",
"context": "../..",
"dockerfile": f"{staging_dir}/images/{instance_name}/Dockerfile",
"args": instance_config.get("args", []),
},
Expand Down