Common test functions, check flags are removed

This commit is contained in:
Кирилл Гарбар 2024-01-09 04:22:40 +03:00
parent c7b14d190e
commit bebb2c9dca
6 changed files with 41 additions and 70 deletions

View File

@ -0,0 +1,23 @@
from helpers.cluster import ClickHouseCluster
def check_flags_deleted(node, database_name, tables):
for table in tables:
assert "convert_to_replicated" not in node.exec_in_container(
[
"bash",
"-c",
f"ls /var/lib/clickhouse/data/{database_name}/{table}/",
]
)
def set_convert_flags(node, database_name, tables):
for table in tables:
node.exec_in_container(
[
"bash",
"-c",
f"touch /var/lib/clickhouse/data/{database_name}/{table}/convert_to_replicated",
]
)

View File

@ -1,4 +1,5 @@
import pytest
from test_modify_engine_on_restart.common import check_flags_deleted, set_convert_flags
from helpers.cluster import ClickHouseCluster
cluster = ClickHouseCluster(__file__)
@ -109,27 +110,6 @@ def check_tables(converted):
)
def set_convert_flags():
# Set convert flag on actually convertable tables
for table in ["rmt", "replacing"]:
ch1.exec_in_container(
[
"bash",
"-c",
f"touch /var/lib/clickhouse/data/{database_name}/{table}/convert_to_replicated",
]
)
# Set flag to not MergeTree table to check that nothing happens
ch1.exec_in_container(
[
"bash",
"-c",
f"touch /var/lib/clickhouse/data/{database_name}/log/convert_to_replicated",
]
)
def check_replica_added():
# Add replica to check if zookeeper path is correct and consistent with table uuid
@ -166,10 +146,12 @@ def test_modify_engine_on_restart(started_cluster):
check_tables(False)
set_convert_flags()
set_convert_flags(ch1, database_name, ["rmt", "replacing", "log"])
ch1.restart_clickhouse()
check_flags_deleted(ch1, database_name, ["rmt", "replacing"])
check_tables(True)
check_replica_added()

View File

@ -1,4 +1,5 @@
import pytest
from test_modify_engine_on_restart.common import check_flags_deleted, set_convert_flags
from helpers.cluster import ClickHouseCluster
cluster = ClickHouseCluster(__file__)
@ -77,25 +78,15 @@ def check_tables():
)
def set_convert_flags():
# Set convert flag on actually convertable tables
for table in ["replacing_ver", "collapsing_ver"]:
ch1.exec_in_container(
[
"bash",
"-c",
f"touch /var/lib/clickhouse/data/{database_name}/{table}/convert_to_replicated",
]
)
def test_modify_engine_on_restart_with_arguments(started_cluster):
ch1.query("CREATE DATABASE " + database_name)
create_tables()
set_convert_flags()
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()

View File

@ -1,4 +1,5 @@
import pytest
from test_modify_engine_on_restart.common import check_flags_deleted, set_convert_flags
from helpers.cluster import ClickHouseCluster
cluster = ClickHouseCluster(__file__)
@ -115,17 +116,6 @@ def check_tables(converted):
assert q(ch1, "SELECT count() FROM hourly_data").strip() == "8"
def set_convert_flags():
for table in ["hourly_data", "monthly_aggregated_data"]:
ch1.exec_in_container(
[
"bash",
"-c",
f"touch /var/lib/clickhouse/data/{database_name}/{table}/convert_to_replicated",
]
)
def test_modify_engine_on_restart_with_materialized_view(started_cluster):
ch1.query(f"CREATE DATABASE {database_name}")
@ -133,8 +123,10 @@ def test_modify_engine_on_restart_with_materialized_view(started_cluster):
check_tables(False)
set_convert_flags()
set_convert_flags(ch1, database_name, ["hourly_data", "monthly_aggregated_data"])
ch1.restart_clickhouse()
check_flags_deleted(ch1, database_name, ["hourly_data", "monthly_aggregated_data"])
check_tables(True)

View File

@ -1,4 +1,5 @@
import pytest
from test_modify_engine_on_restart.common import check_flags_deleted, set_convert_flags
from helpers.cluster import ClickHouseCluster
cluster = ClickHouseCluster(__file__)
@ -57,16 +58,6 @@ def check_tables():
)
def set_convert_flags():
ch1.exec_in_container(
[
"bash",
"-c",
f"touch /var/lib/clickhouse/data/{database_name}/mt/convert_to_replicated",
]
)
def remove_convert_flags():
ch1.exec_in_container(
[
@ -87,7 +78,7 @@ def test_modify_engine_on_restart_ordinary_database(started_cluster):
check_tables()
set_convert_flags()
set_convert_flags(ch1, database_name, ["mt"])
cannot_start = False
try:

View File

@ -1,4 +1,5 @@
import pytest
from test_modify_engine_on_restart.common import check_flags_deleted, set_convert_flags
from helpers.cluster import ClickHouseCluster
cluster = ClickHouseCluster(__file__)
@ -77,24 +78,15 @@ def check_tables():
)
def set_convert_flags():
for table in ["replacing_ver", "collapsing_ver"]:
ch1.exec_in_container(
[
"bash",
"-c",
f"touch /var/lib/clickhouse/data/{database_name}/{table}/convert_to_replicated",
]
)
def test_modify_engine_on_restart_with_unusual_path(started_cluster):
ch1.query("CREATE DATABASE " + database_name)
create_tables()
set_convert_flags()
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()