Better tests

This commit is contained in:
Yatsishin Ilya 2021-07-28 13:21:59 +03:00
parent 421650dc68
commit 50ae1b3255
3 changed files with 22 additions and 18 deletions

View File

@ -2,7 +2,7 @@ import pytest
from helpers.cluster import ClickHouseCluster
cluster = ClickHouseCluster(__file__)
cluster = ClickHouseCluster(__file__, name="detach")
# Version 21.6.3.14 has incompatible partition id for tables with UUID in partition key.
node_21_6 = cluster.add_instance('node_21_6', image='yandex/clickhouse-server', tag='21.6.3.14', stay_alive=True, with_installed_binary=True)

View File

@ -23,14 +23,9 @@ node5 = cluster.add_instance('node5', macros={'cluster': 'test3'}, main_configs=
all_nodes = [node1, node2, node3, node4, node5]
@pytest.fixture(scope="module")
def started_cluster():
try:
cluster.start()
def prepare_cluster():
for node in all_nodes:
node.query("DROP TABLE IF EXISTS test_mutations")
node.query("DROP TABLE IF EXISTS test_mutations SYNC")
for node in [node1, node2, node3, node4]:
node.query("""
@ -44,6 +39,11 @@ def started_cluster():
node5.query(
"CREATE TABLE test_mutations(d Date, x UInt32, i UInt32) ENGINE MergeTree() ORDER BY x PARTITION BY toYYYYMM(d)")
@pytest.fixture(scope="module")
def started_cluster():
try:
cluster.start()
yield cluster
finally:
@ -165,6 +165,8 @@ def wait_for_mutations(nodes, number_of_mutations):
def test_mutations(started_cluster):
prepare_cluster()
DURATION_SECONDS = 30
nodes = [node1, node2]
@ -212,6 +214,8 @@ def test_mutations(started_cluster):
]
)
def test_mutations_dont_prevent_merges(started_cluster, nodes):
prepare_cluster()
for year in range(2000, 2016):
rows = ''
date_str = '{}-01-{}'.format(year, random.randint(1, 10))

View File

@ -86,7 +86,7 @@ def test_upgrade_while_mutation(start_cluster):
node3.restart_with_latest_version(signal=9)
# checks for readonly
exec_query_with_retry(node3, "OPTIMIZE TABLE mt1", retry_count=60)
exec_query_with_retry(node3, "OPTIMIZE TABLE mt1", sleep_time=5, retry_count=60)
node3.query("ALTER TABLE mt1 DELETE WHERE id > 100000", settings={"mutations_sync": "2"})
# will delete nothing, but previous async mutation will finish with this query