mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-25 17:12:03 +00:00
55 lines
1.5 KiB
Python
55 lines
1.5 KiB
Python
import pytest
|
|
from helpers.cluster import ClickHouseCluster
|
|
|
|
cluster = ClickHouseCluster(__file__)
|
|
ch1 = cluster.add_instance(
|
|
"ch1",
|
|
main_configs=[
|
|
"configs/config.d/clusters.xml",
|
|
"configs/config.d/distributed_ddl.xml",
|
|
],
|
|
with_zookeeper=True,
|
|
)
|
|
ch2 = cluster.add_instance(
|
|
"ch2",
|
|
main_configs=[
|
|
"configs/config.d/clusters.xml",
|
|
"configs/config.d/distributed_ddl.xml",
|
|
],
|
|
with_zookeeper=True,
|
|
)
|
|
|
|
|
|
@pytest.fixture(scope="module")
|
|
def started_cluster():
|
|
try:
|
|
cluster.start()
|
|
ch1.query("CREATE DATABASE test_default_database ON CLUSTER 'cluster';")
|
|
yield cluster
|
|
|
|
finally:
|
|
cluster.shutdown()
|
|
|
|
|
|
def test_default_database_on_cluster(started_cluster):
|
|
ch1.query(
|
|
database="test_default_database",
|
|
sql="CREATE TABLE test_local_table (x UInt64) ENGINE=ReplicatedMergeTree('/clickhouse/tables/test_local_table', 'r1') ORDER BY tuple();",
|
|
)
|
|
|
|
ch2.query(
|
|
database="test_default_database",
|
|
sql="CREATE TABLE test_local_table (x UInt64) ENGINE=ReplicatedMergeTree('/clickhouse/tables/test_local_table', 'r2') ORDER BY tuple();",
|
|
)
|
|
|
|
ch1.query(
|
|
database="test_default_database",
|
|
sql="ALTER TABLE test_local_table ON CLUSTER 'cluster' MODIFY SETTING old_parts_lifetime = 100;",
|
|
)
|
|
|
|
for node in [ch1, ch2]:
|
|
assert node.query(
|
|
database="test_default_database",
|
|
sql="SHOW CREATE test_local_table FORMAT TSV",
|
|
).endswith("old_parts_lifetime = 100\n")
|