ClickHouse/tests/integration/test_alternative_keeper_config/test.py

68 lines
1.7 KiB
Python
Raw Normal View History

2022-12-29 06:56:09 +00:00
#!/usr/bin/env python3
2022-12-28 08:58:21 +00:00
import pytest
from helpers.cluster import ClickHouseCluster
2022-12-29 08:37:20 +00:00
from helpers.test_tools import TSV
2022-12-28 08:58:21 +00:00
cluster = ClickHouseCluster(__file__)
node1 = cluster.add_instance(
"node1",
2023-03-23 12:58:39 +00:00
main_configs=[
"configs/remote_servers.xml",
"configs/keeper_config.xml",
"configs/enable_keeper1.xml",
],
2022-12-28 08:58:21 +00:00
macros={"replica": "node1"},
)
node2 = cluster.add_instance(
"node2",
2023-03-23 12:58:39 +00:00
main_configs=[
"configs/remote_servers.xml",
"configs/zookeeper_config.xml",
"configs/enable_keeper2.xml",
],
2022-12-28 08:58:21 +00:00
macros={"replica": "node2"},
)
2023-03-23 12:58:39 +00:00
node3 = cluster.add_instance(
"node3",
main_configs=["configs/remote_servers.xml", "configs/enable_keeper3.xml"],
macros={"replica": "node3"},
)
2022-12-28 08:58:21 +00:00
@pytest.fixture(scope="module", autouse=True)
def started_cluster():
try:
cluster.start()
yield cluster
finally:
cluster.shutdown()
def test_create_insert(started_cluster):
2023-05-03 18:06:46 +00:00
node1.query("DROP TABLE IF EXISTS tbl ON CLUSTER 'test_cluster' SYNC")
2022-12-28 08:58:21 +00:00
node1.query(
"""
CREATE TABLE tbl ON CLUSTER 'test_cluster' (
id Int64,
str String
) ENGINE=ReplicatedMergeTree('/clickhouse/tables/tbl/', '{replica}')
ORDER BY id
"""
)
node1.query("INSERT INTO tbl VALUES (1, 'str1')")
node2.query("INSERT INTO tbl VALUES (1, 'str1')") # Test deduplication
2023-03-23 12:58:39 +00:00
node3.query("INSERT INTO tbl VALUES (2, 'str2')")
2022-12-28 08:58:21 +00:00
2023-04-07 07:49:19 +00:00
node1.query("SYSTEM SYNC REPLICA ON CLUSTER 'test_cluster' tbl")
2023-03-23 12:58:39 +00:00
for node in [node1, node2, node3]:
expected = [[1, "str1"], [2, "str2"]]
assert node.query("SELECT * FROM tbl ORDER BY id") == TSV(expected)
assert node.query("CHECK TABLE tbl") == "1\n"