This commit is contained in:
Кирилл Гарбар 2024-05-13 00:35:38 +03:00
parent 0ce90f4ef4
commit 5f2228cd16

View File

@ -40,8 +40,8 @@ def started_cluster():
cluster.shutdown() cluster.shutdown()
def q(node, query): def q(node, query, database=database_name):
return node.query(database=database_name, sql=query) return node.query(database=database, sql=query)
def create_tables(): def create_tables():
@ -166,20 +166,24 @@ def test_modify_engine_on_restart(started_cluster):
def test_modify_engine_fails_if_zk_path_exists(started_cluster): def test_modify_engine_fails_if_zk_path_exists(started_cluster):
ch1.query("CREATE DATABASE IF NOT EXISTS " + database_name + " ON CLUSTER cluster") database_name = "zk_path"
ch1.query("CREATE DATABASE " + database_name + " ON CLUSTER cluster")
q( q(
ch1, ch1,
"CREATE TABLE already_exists_1 ( A Int64, D Date, S String ) ENGINE MergeTree() PARTITION BY toYYYYMM(D) ORDER BY A;", "CREATE TABLE already_exists_1 ( A Int64, D Date, S String ) ENGINE MergeTree() PARTITION BY toYYYYMM(D) ORDER BY A;",
database_name,
) )
uuid = q( uuid = q(
ch1, ch1,
f"SELECT uuid FROM system.tables WHERE table = 'already_exists_1' and database = '{database_name}'", f"SELECT uuid FROM system.tables WHERE table = 'already_exists_1' and database = '{database_name}'",
database_name,
).strip("'[]\n") ).strip("'[]\n")
q( q(
ch1, 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;", 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"]) set_convert_flags(ch1, database_name, ["already_exists_1"])