ClickHouse/tests/integration/helpers/wait_for_helpers.py
2022-11-23 15:16:09 +00:00

31 lines
997 B
Python

import time
from helpers.test_tools import assert_eq_with_retry
def _parse_table_database(table, database):
if database is not None:
return table, database
if "." in table:
return reversed(table.split(".", 1))
return table, "default"
def wait_for_delete_inactive_parts(node, table, database=None, **kwargs):
table, database = _parse_table_database(table, database)
inactive_parts_query = (
f"SELECT count() FROM system.parts "
f"WHERE not active AND table = '{table}' AND database = '{database}';"
)
assert_eq_with_retry(node, inactive_parts_query, "0\n", **kwargs)
def wait_for_delete_empty_parts(node, table, database=None, **kwargs):
table, database = _parse_table_database(table, database)
empty_parts_query = (
f"SELECT count() FROM system.parts "
f"WHERE active AND rows = 0 AND table = '{table}' AND database = '{database}'"
)
assert_eq_with_retry(node, empty_parts_query, "0\n", **kwargs)