ClickHouse/tests/integration/test_undrop_query/test.py

49 lines
1.3 KiB
Python
Raw Normal View History

2023-03-21 12:14:26 +00:00
import pytest
import uuid
2024-03-25 16:24:46 +00:00
import logging
2023-03-21 12:14:26 +00:00
import time
from helpers.cluster import ClickHouseCluster
cluster = ClickHouseCluster(__file__)
node = cluster.add_instance("node", main_configs=["configs/with_delay_config.xml"])
@pytest.fixture(scope="module")
def started_cluster():
try:
cluster.start()
yield cluster
finally:
cluster.shutdown()
2024-03-25 17:18:17 +00:00
2023-03-21 12:14:26 +00:00
def test_undrop_drop_and_undrop_loop(started_cluster):
2024-03-25 16:14:06 +00:00
uuid_list = []
2024-03-21 18:39:05 +00:00
2024-03-26 17:00:35 +00:00
for i in range(4):
2024-03-25 16:14:06 +00:00
table_uuid = uuid.uuid1().__str__()
uuid_list.append(table_uuid)
logging.info(f"table_uuid: {table_uuid}")
2024-03-25 17:18:17 +00:00
2023-03-21 12:14:26 +00:00
node.query(
2024-03-25 16:30:01 +00:00
f"CREATE TABLE test_undrop_{i} UUID '{table_uuid}' (id Int32) ENGINE = MergeTree() ORDER BY id;"
2023-03-21 12:14:26 +00:00
)
2024-03-21 18:39:05 +00:00
2024-03-25 16:14:06 +00:00
node.query(f"DROP TABLE test_undrop_{i};")
2024-03-21 18:39:05 +00:00
2024-03-26 17:00:35 +00:00
for i in range(4):
2024-03-26 17:26:32 +00:00
if (
i >= 3
2024-03-26 17:30:44 +00:00
): # First 3 tables are undropped after 0, 5 and 10 seconds. Fourth is undropped after 21 seconds
2024-03-26 17:04:04 +00:00
time.sleep(6)
2023-03-21 12:14:26 +00:00
error = node.query_and_get_error(
2024-03-25 16:24:46 +00:00
f"UNDROP TABLE test_undrop_loop_{i} UUID '{uuid_list[i]}';"
2023-03-21 12:14:26 +00:00
)
assert "UNKNOWN_TABLE" in error
2024-03-25 16:14:06 +00:00
else:
2024-03-25 17:18:17 +00:00
node.query(f"UNDROP TABLE test_undrop_loop_{i} UUID '{uuid_list[i]}';")
2024-03-26 17:04:04 +00:00
time.sleep(5)