diff --git a/tests/integration/test_modify_engine_on_restart/configs/config.d/clusters.xml b/tests/integration/test_modify_engine_on_restart/configs/config.d/clusters.xml
index fbcf6499ec15..c8bbb7f35301 100644
--- a/tests/integration/test_modify_engine_on_restart/configs/config.d/clusters.xml
+++ b/tests/integration/test_modify_engine_on_restart/configs/config.d/clusters.xml
@@ -15,8 +15,6 @@
-/clickhouse/tables/{database}/{table}/{uuid}
-
01
diff --git a/tests/integration/test_modify_engine_on_restart/configs/config.d/clusters_unusual.xml b/tests/integration/test_modify_engine_on_restart/configs/config.d/clusters_zk_path.xml
similarity index 80%
rename from tests/integration/test_modify_engine_on_restart/configs/config.d/clusters_unusual.xml
rename to tests/integration/test_modify_engine_on_restart/configs/config.d/clusters_zk_path.xml
index 812291335b89..ba13cd870318 100644
--- a/tests/integration/test_modify_engine_on_restart/configs/config.d/clusters_unusual.xml
+++ b/tests/integration/test_modify_engine_on_restart/configs/config.d/clusters_zk_path.xml
@@ -15,6 +15,6 @@
01
-/lol/kek/'/{uuid}
+/clickhouse/'/{database}/{table}/{uuid}
diff --git a/tests/integration/test_modify_engine_on_restart/test.py b/tests/integration/test_modify_engine_on_restart/test.py
index 81854340752f..289b25dd89e5 100644
--- a/tests/integration/test_modify_engine_on_restart/test.py
+++ b/tests/integration/test_modify_engine_on_restart/test.py
@@ -1,9 +1,5 @@
import pytest
-from test_modify_engine_on_restart.common import (
- check_flags_deleted,
- set_convert_flags,
- get_table_path,
-)
+from test_modify_engine_on_restart.common import check_flags_deleted, set_convert_flags
from helpers.cluster import ClickHouseCluster
cluster = ClickHouseCluster(__file__)
@@ -40,8 +36,8 @@ def started_cluster():
cluster.shutdown()
-def q(node, query, database=database_name):
- return node.query(database=database, sql=query)
+def q(node, query):
+ return node.query(database=database_name, sql=query)
def create_tables():
@@ -124,7 +120,7 @@ def check_replica_added():
q(
ch2,
- f"CREATE TABLE rmt ( A Int64, D Date, S String ) ENGINE ReplicatedMergeTree('/clickhouse/tables/{database_name}/rmt/{uuid}', '{{replica}}') PARTITION BY toYYYYMM(D) ORDER BY A",
+ f"CREATE TABLE rmt ( A Int64, D Date, S String ) ENGINE ReplicatedMergeTree('/clickhouse/tables/{uuid}/{{shard}}', '{{replica}}') PARTITION BY toYYYYMM(D) ORDER BY A",
)
ch2.query(database=database_name, sql="SYSTEM SYNC REPLICA rmt", timeout=20)
@@ -140,7 +136,7 @@ def check_replica_added():
def test_modify_engine_on_restart(started_cluster):
- ch1.query("CREATE DATABASE IF NOT EXISTS " + database_name + " ON CLUSTER cluster")
+ ch1.query("CREATE DATABASE " + database_name + " ON CLUSTER cluster")
create_tables()
@@ -163,42 +159,3 @@ def test_modify_engine_on_restart(started_cluster):
ch1.restart_clickhouse()
check_tables(True)
-
-
-def test_modify_engine_fails_if_zk_path_exists(started_cluster):
- database_name = "zk_path"
- ch1.query("CREATE DATABASE " + database_name + " ON CLUSTER cluster")
-
- q(
- ch1,
- "CREATE TABLE already_exists_1 ( A Int64, D Date, S String ) ENGINE MergeTree() PARTITION BY toYYYYMM(D) ORDER BY A;",
- database_name,
- )
- uuid = q(
- ch1,
- f"SELECT uuid FROM system.tables WHERE table = 'already_exists_1' and database = '{database_name}'",
- database_name,
- ).strip("'[]\n")
-
- q(
- ch1,
- f"CREATE TABLE already_exists_2 ( A Int64, D Date, S String ) ENGINE ReplicatedMergeTree('/clickhouse/tables/{database_name}/already_exists_1/{uuid}', 'r2') PARTITION BY toYYYYMM(D) ORDER BY A;",
- database_name,
- )
-
- set_convert_flags(ch1, database_name, ["already_exists_1"])
-
- table_data_path = get_table_path(ch1, "already_exists_1", database_name)
-
- ch1.stop_clickhouse()
- ch1.start_clickhouse(retry_start=False, expected_to_fail=True)
-
- # Check if we can cancel convertation
- ch1.exec_in_container(
- [
- "bash",
- "-c",
- f"rm {table_data_path}convert_to_replicated",
- ]
- )
- ch1.start_clickhouse()
diff --git a/tests/integration/test_modify_engine_on_restart/test_unusual_path.py b/tests/integration/test_modify_engine_on_restart/test_zk_path.py
similarity index 52%
rename from tests/integration/test_modify_engine_on_restart/test_unusual_path.py
rename to tests/integration/test_modify_engine_on_restart/test_zk_path.py
index e82f48e8b340..8bbfe64240f2 100644
--- a/tests/integration/test_modify_engine_on_restart/test_unusual_path.py
+++ b/tests/integration/test_modify_engine_on_restart/test_zk_path.py
@@ -1,12 +1,16 @@
import pytest
-from test_modify_engine_on_restart.common import check_flags_deleted, set_convert_flags
+from test_modify_engine_on_restart.common import (
+ check_flags_deleted,
+ get_table_path,
+ set_convert_flags,
+)
from helpers.cluster import ClickHouseCluster
cluster = ClickHouseCluster(__file__)
ch1 = cluster.add_instance(
"ch1",
main_configs=[
- "configs/config.d/clusters_unusual.xml",
+ "configs/config.d/clusters_zk_path.xml",
"configs/config.d/distributed_ddl.xml",
],
with_zookeeper=True,
@@ -27,8 +31,8 @@ def started_cluster():
cluster.shutdown()
-def q(node, query):
- return node.query(database=database_name, sql=query)
+def q(node, query, database=database_name):
+ return node.query(database=database, sql=query)
def create_tables():
@@ -63,7 +67,7 @@ def check_tables():
)
.strip()
.startswith(
- "ReplicatedReplacingMergeTree(\\'/lol/kek/\\\\\\'/{uuid}\\', \\'{replica}\\', D)"
+ "ReplicatedReplacingMergeTree(\\'/clickhouse/\\\\\\'/{database}/{table}/{uuid}\\', \\'{replica}\\', D)"
)
)
assert (
@@ -73,7 +77,7 @@ def check_tables():
)
.strip()
.startswith(
- "ReplicatedVersionedCollapsingMergeTree(\\'/lol/kek/\\\\\\'/{uuid}\\', \\'{replica}\\', Sign, Version)"
+ "ReplicatedVersionedCollapsingMergeTree(\\'/clickhouse/\\\\\\'/{database}/{table}/{uuid}\\', \\'{replica}\\', Sign, Version)"
)
)
@@ -90,3 +94,42 @@ def test_modify_engine_on_restart_with_unusual_path(started_cluster):
check_flags_deleted(ch1, database_name, ["replacing_ver", "collapsing_ver"])
check_tables()
+
+
+def test_modify_engine_fails_if_zk_path_exists(started_cluster):
+ database_name = "zk_path"
+ ch1.query("CREATE DATABASE " + database_name + " ON CLUSTER cluster")
+
+ q(
+ ch1,
+ "CREATE TABLE already_exists_1 ( A Int64, D Date, S String ) ENGINE MergeTree() PARTITION BY toYYYYMM(D) ORDER BY A;",
+ database_name,
+ )
+ uuid = q(
+ ch1,
+ f"SELECT uuid FROM system.tables WHERE table = 'already_exists_1' and database = '{database_name}'",
+ database_name,
+ ).strip("'[]\n")
+
+ q(
+ ch1,
+ f"CREATE TABLE already_exists_2 ( A Int64, D Date, S String ) ENGINE ReplicatedMergeTree('/clickhouse/\\'/{database_name}/already_exists_1/{uuid}', 'r2') PARTITION BY toYYYYMM(D) ORDER BY A;",
+ database_name,
+ )
+
+ set_convert_flags(ch1, database_name, ["already_exists_1"])
+
+ table_data_path = get_table_path(ch1, "already_exists_1", database_name)
+
+ ch1.stop_clickhouse()
+ ch1.start_clickhouse(retry_start=False, expected_to_fail=True)
+
+ # Check if we can cancel convertation
+ ch1.exec_in_container(
+ [
+ "bash",
+ "-c",
+ f"rm {table_data_path}convert_to_replicated",
+ ]
+ )
+ ch1.start_clickhouse()