Skip to content

Commit 84894a2

Browse files
author
maxim-lixakov
committed
[DOP-19899] - add integration Clickhouse tests & CI
1 parent 32726c9 commit 84894a2

File tree

18 files changed

+623
-19
lines changed

18 files changed

+623
-19
lines changed

.env.docker

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,14 @@ TEST_ORACLE_USER=syncmaster
7676
TEST_ORACLE_PASSWORD=changeme
7777
TEST_ORACLE_SERVICE_NAME=XEPDB1
7878

79+
TEST_CLICKHOUSE_HOST_FOR_CONFTEST=test-clickhouse
80+
TEST_CLICKHOUSE_PORT_FOR_CONFTEST=8123
81+
TEST_CLICKHOUSE_HOST_FOR_WORKER=test-clickhouse
82+
TEST_CLICKHOUSE_PORT_FOR_WORKER=8123
83+
TEST_CLICKHOUSE_USER=default
84+
TEST_CLICKHOUSE_PASSWORD=
85+
TEST_CLICKHOUSE_DB=default
86+
7987
TEST_HIVE_CLUSTER=test-hive
8088
TEST_HIVE_USER=syncmaster
8189
TEST_HIVE_PASSWORD=changeme

.env.local

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,14 @@ export TEST_ORACLE_USER=syncmaster
6262
export TEST_ORACLE_PASSWORD=changeme
6363
export TEST_ORACLE_SERVICE_NAME=XEPDB1
6464

65+
export TEST_CLICKHOUSE_HOST_FOR_CONFTEST=localhost
66+
export TEST_CLICKHOUSE_PORT_FOR_CONFTEST=8123
67+
export TEST_CLICKHOUSE_HOST_FOR_WORKER=test-clickhouse
68+
export TEST_CLICKHOUSE_PORT_FOR_WORKER=8123
69+
export TEST_CLICKHOUSE_USER=default
70+
export TEST_CLICKHOUSE_PASSWORD=
71+
export TEST_CLICKHOUSE_DB=default
72+
6573
export TEST_HIVE_CLUSTER=test-hive
6674
export TEST_HIVE_USER=syncmaster
6775
export TEST_HIVE_PASSWORD=changeme
Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
name: Clickhouse Tests
2+
on:
3+
workflow_call:
4+
5+
env:
6+
DEFAULT_PYTHON: '3.12'
7+
8+
jobs:
9+
tests:
10+
name: Run Clickhouse tests
11+
runs-on: ubuntu-latest
12+
13+
steps:
14+
- name: Checkout code
15+
uses: actions/checkout@v4
16+
17+
- name: Set up QEMU
18+
uses: docker/setup-qemu-action@v3
19+
20+
- name: Set up Docker Buildx
21+
uses: docker/setup-buildx-action@v3
22+
23+
- name: Cache jars
24+
uses: actions/cache@v4
25+
with:
26+
path: ./cached_jars
27+
key: ${{ runner.os }}-python-${{ env.DEFAULT_PYTHON }}-test-clickhouse
28+
restore-keys: |
29+
${{ runner.os }}-python-${{ env.DEFAULT_PYTHON }}-test-clickhouse
30+
${{ runner.os }}-python-
31+
32+
- name: Build Worker Image
33+
uses: docker/build-push-action@v6
34+
with:
35+
context: .
36+
tags: mtsrus/syncmaster-worker:${{ github.sha }}
37+
target: test
38+
file: docker/Dockerfile.worker
39+
load: true
40+
cache-from: mtsrus/syncmaster-worker:develop
41+
42+
- name: Docker compose up
43+
run: |
44+
docker compose -f docker-compose.test.yml --profile all down -v --remove-orphans
45+
docker compose -f docker-compose.test.yml --profile clickhouse up -d --wait --wait-timeout 200
46+
env:
47+
WORKER_IMAGE_TAG: ${{ github.sha }}
48+
49+
- name: Run Clickhouse Tests
50+
run: |
51+
docker compose -f ./docker-compose.test.yml --profile clickhouse exec -T worker coverage run -m pytest -vvv -s -m "worker and clickhouse"
52+
53+
- name: Dump worker logs on failure
54+
if: failure()
55+
uses: jwalton/gh-docker-logs@v2
56+
with:
57+
images: mtsrus/syncmaster-worker
58+
dest: ./logs
59+
60+
# This is important, as coverage is exported after receiving SIGTERM
61+
- name: Shutdown
62+
if: always()
63+
run: |
64+
docker compose -f docker-compose.test.yml --profile all down -v --remove-orphans
65+
66+
- name: Upload worker logs
67+
uses: actions/upload-artifact@v4
68+
if: failure()
69+
with:
70+
name: worker-logs-clickhouse
71+
path: logs/*
72+
73+
- name: Upload coverage results
74+
uses: actions/upload-artifact@v4
75+
with:
76+
name: coverage-clickhouse
77+
path: reports/*
78+
# https://github.com/actions/upload-artifact/issues/602
79+
include-hidden-files: true

.github/workflows/hdfs-tests.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,6 @@ jobs:
4646
env:
4747
WORKER_IMAGE_TAG: ${{ github.sha }}
4848

49-
# This is important, as coverage is exported after receiving SIGTERM
5049
- name: Run HDFS Tests
5150
run: |
5251
docker compose -f ./docker-compose.test.yml --profile hdfs exec -T worker coverage run -m pytest -vvv -s -m "worker and hdfs"
@@ -58,6 +57,7 @@ jobs:
5857
images: mtsrus/syncmaster-worker
5958
dest: ./logs
6059

60+
# This is important, as coverage is exported after receiving SIGTERM
6161
- name: Shutdown
6262
if: always()
6363
run: |

.github/workflows/hive-tests.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,6 @@ jobs:
4646
env:
4747
WORKER_IMAGE_TAG: ${{ github.sha }}
4848

49-
# This is important, as coverage is exported after receiving SIGTERM
5049
- name: Run Hive Tests
5150
run: |
5251
docker compose -f ./docker-compose.test.yml --profile hive exec -T worker coverage run -m pytest -vvv -s -m "worker and hive"
@@ -58,6 +57,7 @@ jobs:
5857
images: mtsrus/syncmaster-worker
5958
dest: ./logs
6059

60+
# This is important, as coverage is exported after receiving SIGTERM
6161
- name: Shutdown
6262
if: always()
6363
run: |

.github/workflows/oracle-tests.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,6 @@ jobs:
4646
env:
4747
WORKER_IMAGE_TAG: ${{ github.sha }}
4848

49-
# This is important, as coverage is exported after receiving SIGTERM
5049
- name: Run Oracle Tests
5150
run: |
5251
docker compose -f ./docker-compose.test.yml --profile oracle exec -T worker coverage run -m pytest -vvv -s -m "worker and oracle"
@@ -58,6 +57,7 @@ jobs:
5857
images: mtsrus/syncmaster-worker
5958
dest: ./logs
6059

60+
# This is important, as coverage is exported after receiving SIGTERM
6161
- name: Shutdown
6262
if: always()
6363
run: |

.github/workflows/scheduler-tests.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,6 @@ jobs:
4646
env:
4747
WORKER_IMAGE_TAG: ${{ github.sha }}
4848

49-
# This is important, as coverage is exported after receiving SIGTERM
5049
- name: Run Scheduler Tests
5150
run: |
5251
docker compose -f ./docker-compose.test.yml --profile worker exec -T worker coverage run -m pytest -vvv -s -m "worker and scheduler_integration"
@@ -58,6 +57,7 @@ jobs:
5857
images: mtsrus/syncmaster-worker
5958
dest: ./logs
6059

60+
# This is important, as coverage is exported after receiving SIGTERM
6161
- name: Shutdown
6262
if: always()
6363
run: |

.github/workflows/tests.yml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,10 @@ jobs:
2020
name: Oracle tests
2121
uses: ./.github/workflows/oracle-tests.yml
2222

23+
clickhouse_tests:
24+
name: Clickhouse tests
25+
uses: ./.github/workflows/clickhouse-tests.yml
26+
2327
hdfs_tests:
2428
name: HDFS tests
2529
uses: ./.github/workflows/hdfs-tests.yml
@@ -44,7 +48,7 @@ jobs:
4448
name: Tests done
4549
runs-on: ubuntu-latest
4650

47-
needs: [oracle_tests, hive_tests, hdfs_tests, s3_tests, unit_tests]
51+
needs: [oracle_tests, clickhouse_tests, hive_tests, hdfs_tests, s3_tests, unit_tests]
4852
steps:
4953
- name: Checkout code
5054
uses: actions/checkout@v4

Makefile

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -65,10 +65,10 @@ broker-start: ##Broker Start broker
6565

6666

6767

68-
test: test-db test-broker ##@Test Run tests
68+
test: test-db test-broker ##@Test Run tests
6969
${POETRY} run pytest $(PYTEST_ARGS)
7070

71-
test-db: test-db-start db-upgrade ##@TestDB Prepare database (in docker)
71+
test-db: test-db-start db-upgrade ##@TestDBPrepare database (in docker)
7272

7373
test-db-start: ##@TestDB Start database
7474
docker compose -f docker-compose.test.yml up -d --wait db $(DOCKER_COMPOSE_ARGS)
@@ -78,33 +78,37 @@ test-broker: test-broker-start ##@TestBroker Prepare broker (in docker)
7878
test-broker-start: ##@TestBroker Start broker
7979
docker compose -f docker-compose.test.yml up -d --wait rabbitmq $(DOCKER_COMPOSE_ARGS)
8080

81-
test-unit: test-db ##@Test Run unit tests
81+
test-unit: test-db ##@Test Run unit tests
8282
${POETRY} run pytest ./tests/test_unit ./tests/test_database $(PYTEST_ARGS)
8383

84-
test-integration-hdfs: test-db ##@Test Run integration tests for HDFS
84+
test-integration-hdfs: test-db ##@Test Run integration tests for HDFS
8585
docker compose -f docker-compose.test.yml --profile hdfs up -d --wait $(DOCKER_COMPOSE_ARGS)
8686
${POETRY} run pytest ./tests/test_integration -m hdfs $(PYTEST_ARGS)
8787

88-
test-integration-hive: test-db ##@Test Run integration tests for Hive
88+
test-integration-hive: test-db ##@Test Run integration tests for Hive
8989
docker compose -f docker-compose.test.yml --profile hive up -d --wait $(DOCKER_COMPOSE_ARGS)
9090
${POETRY} run pytest ./tests/test_integration -m hive $(PYTEST_ARGS)
9191

92-
test-integration-oracle: test-db ##@Test Run integration tests for Oracle
92+
test-integration-clickhouse: test-db ##@Test Run integration tests for Clickhouse
93+
docker compose -f docker-compose.test.yml --profile clickhouse up -d --wait $(DOCKER_COMPOSE_ARGS)
94+
${POETRY} run pytest ./tests/test_integration -m clickhouse $(PYTEST_ARGS)
95+
96+
test-integration-oracle: test-db ##@Test Run integration tests for Oracle
9397
docker compose -f docker-compose.test.yml --profile oracle up -d --wait $(DOCKER_COMPOSE_ARGS)
9498
${POETRY} run pytest ./tests/test_integration -m oracle $(PYTEST_ARGS)
9599

96-
test-integration-s3: test-db ##@Test Run integration tests for S3
100+
test-integration-s3: test-db ##@Test Run integration tests for S3
97101
docker compose -f docker-compose.test.yml --profile s3 up -d --wait $(DOCKER_COMPOSE_ARGS)
98102
${POETRY} run pytest ./tests/test_integration -m s3 $(PYTEST_ARGS)
99103

100-
test-integration: test-db ##@Test Run all integration tests
104+
test-integration: test-db ##@Test Run all integration tests
101105
docker compose -f docker-compose.test.yml --profile all up -d --wait $(DOCKER_COMPOSE_ARGS)
102106
${POETRY} run pytest ./tests/test_integration $(PYTEST_ARGS)
103107

104-
test-check-fixtures: ##@Test Check declared fixtures
108+
test-check-fixtures: ##@Test Check declared fixtures
105109
${POETRY} run pytest --dead-fixtures $(PYTEST_ARGS)
106110

107-
test-cleanup: ##@Test Cleanup tests dependencies
111+
test-cleanup: ##@Test Cleanup tests dependencies
108112
docker compose -f docker-compose.test.yml --profile all down $(ARGS)
109113

110114

docker-compose.test.yml

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ services:
9595
condition: service_healthy
9696
rabbitmq:
9797
condition: service_healthy
98-
profiles: [worker, scheduler, s3, oracle, hdfs, hive, all]
98+
profiles: [worker, scheduler, s3, oracle, hdfs, hive, all, clickhouse]
9999

100100
test-postgres:
101101
image: postgres
@@ -109,7 +109,7 @@ services:
109109
interval: 30s
110110
timeout: 5s
111111
retries: 3
112-
profiles: [s3, oracle, hdfs, hive, all]
112+
profiles: [s3, oracle, clickhouse, hdfs, hive, all]
113113

114114
test-s3:
115115
image: bitnami/minio:latest
@@ -140,6 +140,14 @@ services:
140140
APP_USER_PASSWORD: changeme
141141
profiles: [oracle, all]
142142

143+
test-clickhouse:
144+
image: clickhouse/clickhouse-server
145+
restart: unless-stopped
146+
ports:
147+
- 8123:8123
148+
- 9001:9000
149+
profiles: [clickhouse, all]
150+
143151
metastore-hive:
144152
image: postgres
145153
restart: unless-stopped

0 commit comments

Comments
 (0)