Skip to content

Commit d4a99e9

Browse files
committed
AmateurMergeTree: ci
1 parent 055549e commit d4a99e9

4 files changed

Lines changed: 160 additions & 0 deletions

File tree

.github/workflows/amateur_ci.yaml

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
---
2+
name: AmateurCI
3+
4+
on:
5+
push:
6+
branches: ['amateur-merge-tree']
7+
8+
jobs:
9+
build:
10+
runs-on: ubuntu-latest
11+
name: "Build"
12+
steps:
13+
- name: Checkout code
14+
uses: actions/checkout@v6
15+
with:
16+
submodules: recursive
17+
18+
- name: Restore ccache
19+
uses: actions/cache/restore@v4
20+
with:
21+
path: /tmp/ccache
22+
key: ccache-${{ github.sha }}
23+
restore-keys: |
24+
ccache-
25+
26+
- name: Build
27+
run: |
28+
docker run --rm -v $PWD:/ClickHouse -v /tmp/ccache:/tmp/ccache clickhouse/fasttest:b63954f8a1b316d0686e \
29+
/bin/bash -c "
30+
set -e
31+
apt-get update && apt-get install -y ccache
32+
export CC=clang-21
33+
export CXX=clang++-21
34+
export CCACHE_DIR=/tmp/ccache
35+
cd /ClickHouse/
36+
cmake -DCOMPILER_CACHE=ccache -DCMAKE_BUILD_TYPE=Debug -DOMIT_HEAVY_DEBUG_SYMBOLS=1 -DENABLE_LIBRARIES=0 -DENABLE_UTILS=0 -DENABLE_TESTS=0 -DENABLE_RUST=0 -DENABLE_JEMALLOC=1 -DENABLE_YAML_CPP=1 -DENABLE_AWS_S3=1 -G Ninja -S . -B build
37+
ninja -C build
38+
ccache --show-stats
39+
"
40+
41+
- name: Save ccache
42+
if: github.ref_name == 'amateur-merge-tree'
43+
uses: actions/cache/save@v4
44+
with:
45+
path: /tmp/ccache
46+
key: ccache-${{ github.sha }}
47+
48+
- name: Integration tests
49+
run: |
50+
docker run --rm -v /var/run/docker.sock:/var/run/docker.sock -v $PWD:$PWD --network host clickhouse/integration-tests-runner:c909f2e80ec78b3a6532 \
51+
/bin/bash -c "
52+
CLICKHOUSE_TESTS_SERVER_BIN_PATH=$PWD/build/programs/clickhouse \
53+
pytest $PWD/tests/integration/test_amateur_merge_tree/ -v --timeout=600
54+
"

tests/integration/test_amateur_merge_tree/__init__.py

Whitespace-only changes.
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
---
2+
enforce_keeper_component_tracking: false
3+
4+
storage_configuration:
5+
disks:
6+
s3:
7+
type: object_storage
8+
object_storage_type: s3
9+
metadata_type: amateur
10+
endpoint: http://minio1:9001/root/data/
11+
keeper_prefix: /clickhouse/disks/s3
12+
access_key_id: minio
13+
secret_access_key: ClickHouse_Minio_P@ssw0rd
14+
policies:
15+
s3:
16+
volumes:
17+
- main:
18+
disks:
19+
- s3
Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
#!/usr/bin/env python3
2+
3+
import time
4+
5+
import pytest
6+
7+
from helpers.cluster import ClickHouseCluster
8+
from helpers.test_tools import TSV
9+
10+
cluster = ClickHouseCluster(__file__)
11+
12+
13+
def wait_table_sync(zk_client, zk_table_path):
14+
_, parts_stat = zk_client.get(f"{zk_table_path}/parts")
15+
nodes = zk_client.get_children(f"{zk_table_path}/replicas")
16+
17+
for _ in range(60):
18+
nodes_in_sync = 0
19+
for node in nodes:
20+
node_epoch, _ = zk_client.get(f"{zk_table_path}/replicas/{node}/epoch")
21+
if int(node_epoch) >= parts_stat.pzxid:
22+
nodes_in_sync += 1
23+
24+
if nodes_in_sync == len(nodes):
25+
return
26+
27+
time.sleep(0.5)
28+
29+
30+
@pytest.fixture(scope="module")
31+
def started_cluster():
32+
try:
33+
cluster.add_instance(
34+
"node1",
35+
main_configs=["configs/config.yaml"],
36+
with_minio=True,
37+
with_zookeeper=True,
38+
stay_alive=True,
39+
use_keeper=False,
40+
cpu_limit=3,
41+
)
42+
cluster.add_instance(
43+
"node2",
44+
main_configs=["configs/config.yaml"],
45+
with_minio=True,
46+
with_zookeeper=True,
47+
stay_alive=True,
48+
use_keeper=False,
49+
cpu_limit=3
50+
)
51+
cluster.start()
52+
yield cluster
53+
finally:
54+
cluster.shutdown()
55+
56+
57+
def test_insert_select(started_cluster):
58+
"""
59+
Basic scenario with inserts and replica synchronization
60+
"""
61+
62+
for node_name, node in cluster.instances.items():
63+
data = node.query(f"""
64+
CREATE TABLE test_basic (key UInt32, val String)
65+
ENGINE = AmateurMergeTree('/clickhouse/tables/default/test_basic', '{node_name}')
66+
ORDER BY key
67+
SETTINGS storage_policy = 's3'
68+
""")
69+
70+
cluster.instances["node1"].query("""
71+
INSERT INTO test_basic SELECT number, 'val-' || number FROM numbers(10)
72+
""")
73+
74+
cluster.instances["node2"].query("""
75+
INSERT INTO test_basic SELECT number + 10, 'val-' || (number + 10) FROM numbers(10)
76+
""")
77+
78+
zk_client = cluster.get_kazoo_client("zoo1")
79+
wait_table_sync(zk_client, "/clickhouse/tables/default/test_basic")
80+
81+
expected = [[0, 'val-0', 19, 'val-19']]
82+
for node_name, node in cluster.instances.items():
83+
actual = node.query("""
84+
SELECT min(key), argMin(val, key), max(key), argMax(val, key) FROM test_basic
85+
""")
86+
87+
assert TSV(actual) == TSV(expected), f"Received an unexpected result from node {node_name}"

0 commit comments

Comments
 (0)