ClickHouse/tests/integration/test_modify_engine_on_restart/test_args.py

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

94 lines
2.3 KiB
Python
Raw Normal View History

import pytest
2024-09-27 10:19:39 +00:00
from helpers.cluster import ClickHouseCluster
2024-09-27 10:19:39 +00:00
from test_modify_engine_on_restart.common import check_flags_deleted, set_convert_flags
cluster = ClickHouseCluster(__file__)
ch1 = cluster.add_instance(
"ch1",
main_configs=[
"configs/config.d/clusters.xml",
"configs/config.d/distributed_ddl.xml",
],
with_zookeeper=True,
macros={"replica": "node1"},
stay_alive=True,
)
database_name = "modify_engine_args"
@pytest.fixture(scope="module")
def started_cluster():
try:
cluster.start()
yield cluster
finally:
cluster.shutdown()
def q(node, query):
return node.query(database=database_name, sql=query)
def create_tables():
# Check one argument
q(
ch1,
"CREATE TABLE replacing_ver ( A Int64, D Date, S String ) ENGINE = ReplacingMergeTree(D) PARTITION BY toYYYYMM(D) ORDER BY A",
)
# Check more than one argument
q(
ch1,
"CREATE TABLE collapsing_ver ( ID UInt64, Sign Int8, Version UInt8 ) ENGINE = VersionedCollapsingMergeTree(Sign, Version) ORDER BY ID",
)
def check_tables():
# Check tables exists
assert (
q(
ch1,
"SHOW TABLES",
).strip()
== "collapsing_ver\nreplacing_ver"
)
# Check engines
assert (
q(
ch1,
f"SELECT engine_full FROM system.tables WHERE database = '{database_name}' and name = 'replacing_ver'",
)
.strip()
.startswith(
2023-12-27 23:35:13 +00:00
"ReplicatedReplacingMergeTree(\\'/clickhouse/tables/{uuid}/{shard}\\', \\'{replica}\\', D)"
)
)
assert (
q(
ch1,
f"SELECT engine_full FROM system.tables WHERE database = '{database_name}' and name = 'collapsing_ver'",
)
.strip()
.startswith(
2023-12-27 23:35:13 +00:00
"ReplicatedVersionedCollapsingMergeTree(\\'/clickhouse/tables/{uuid}/{shard}\\', \\'{replica}\\', Sign, Version)"
)
)
2023-12-28 00:33:56 +00:00
def test_modify_engine_on_restart_with_arguments(started_cluster):
ch1.query("CREATE DATABASE " + database_name)
create_tables()
set_convert_flags(ch1, database_name, ["replacing_ver", "collapsing_ver"])
ch1.restart_clickhouse()
check_flags_deleted(ch1, database_name, ["replacing_ver", "collapsing_ver"])
check_tables()