ClickHouse/tests/integration/test_alter_settings_on_cluster/test.py

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

76 lines
2.3 KiB
Python
Raw Normal View History

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]:
2021-01-07 03:31:23 +00:00
assert node.query(
database="test_default_database",
sql="SHOW CREATE test_local_table FORMAT TSV",
).endswith("old_parts_lifetime = 100\n")
2022-12-01 16:41:29 +00:00
ch1.query_and_get_error(
database="test_default_database",
sql="ALTER TABLE test_local_table MODIFY SETTING temporary_directories_lifetime = 1 RESET SETTING old_parts_lifetime;",
)
ch1.query_and_get_error(
database="test_default_database",
sql="ALTER TABLE test_local_table RESET SETTING old_parts_lifetime MODIFY SETTING temporary_directories_lifetime = 1;",
)
ch1.query(
database="test_default_database",
sql="ALTER TABLE test_local_table ON CLUSTER 'cluster' RESET SETTING old_parts_lifetime;",
)
for node in [ch1, ch2]:
assert not node.query(
database="test_default_database",
sql="SHOW CREATE test_local_table FORMAT TSV",
).endswith("old_parts_lifetime = 100\n")