2019-08-09 11:17:33 +00:00
|
|
|
import time
|
|
|
|
|
2020-09-16 04:26:10 +00:00
|
|
|
import pytest
|
2024-09-27 10:19:39 +00:00
|
|
|
|
2019-08-09 11:17:33 +00:00
|
|
|
from helpers.cluster import ClickHouseCluster
|
2020-09-16 04:26:10 +00:00
|
|
|
from helpers.network import PartitionManager
|
2019-08-09 11:17:33 +00:00
|
|
|
|
|
|
|
cluster = ClickHouseCluster(__file__)
|
2020-09-16 04:26:10 +00:00
|
|
|
node1 = cluster.add_instance(
|
|
|
|
"node1",
|
|
|
|
main_configs=[
|
|
|
|
"configs/config.d/zookeeper_session_timeout.xml",
|
|
|
|
"configs/remote_servers.xml",
|
|
|
|
],
|
|
|
|
with_zookeeper=True,
|
|
|
|
)
|
2019-08-09 11:17:33 +00:00
|
|
|
|
|
|
|
|
|
|
|
@pytest.fixture(scope="module")
|
|
|
|
def start_cluster():
|
|
|
|
try:
|
|
|
|
cluster.start()
|
|
|
|
node1.query(
|
2022-06-23 19:40:05 +00:00
|
|
|
"CREATE DATABASE zktest ENGINE=Ordinary;",
|
|
|
|
settings={"allow_deprecated_database_ordinary": 1},
|
2020-09-22 11:56:40 +00:00
|
|
|
) # Different behaviour with Atomic
|
2019-08-09 11:17:33 +00:00
|
|
|
node1.query(
|
2022-03-22 16:39:58 +00:00
|
|
|
"""
|
2019-08-09 11:17:33 +00:00
|
|
|
CREATE TABLE zktest.atomic_drop_table (n UInt32)
|
|
|
|
ENGINE = ReplicatedMergeTree('/clickhouse/zktest/tables/atomic_drop_table', 'node1')
|
|
|
|
PARTITION BY n ORDER BY n
|
2022-03-22 16:39:58 +00:00
|
|
|
"""
|
2019-08-09 11:17:33 +00:00
|
|
|
)
|
|
|
|
yield cluster
|
|
|
|
finally:
|
|
|
|
cluster.shutdown()
|
|
|
|
|
2020-09-16 04:26:10 +00:00
|
|
|
|
2019-08-09 11:17:33 +00:00
|
|
|
def test_atomic_delete_with_stopped_zookeeper(start_cluster):
|
|
|
|
node1.query("insert into zktest.atomic_drop_table values (8192)")
|
|
|
|
|
|
|
|
with PartitionManager() as pm:
|
|
|
|
pm.drop_instance_zk_connections(node1)
|
2020-09-16 04:26:10 +00:00
|
|
|
error = node1.query_and_get_error(
|
|
|
|
"DROP TABLE zktest.atomic_drop_table"
|
|
|
|
) # Table won't drop
|
2019-08-09 11:17:33 +00:00
|
|
|
assert error != ""
|
|
|
|
|
|
|
|
time.sleep(5)
|
|
|
|
assert "8192" in node1.query("select * from zktest.atomic_drop_table")
|