mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-10 01:25:21 +00:00
Add test for ZK disconnect
This commit is contained in:
parent
25d06ca710
commit
1b71bbf1b1
@ -1,4 +1,5 @@
|
||||
import pytest
|
||||
import time
|
||||
|
||||
from helpers.cluster import ClickHouseCluster
|
||||
from helpers.network import PartitionManager
|
||||
@ -39,9 +40,18 @@ def remove_children(client, path):
|
||||
|
||||
|
||||
def test_keeper_map_without_zk(started_cluster):
|
||||
def wait_disconnect_from_zk():
|
||||
for _ in range(20):
|
||||
if len(node.query_and_get_answer_with_error("SELECT * FROM system.zookeeper WHERE path='/'")[1]) != 0:
|
||||
break
|
||||
time.sleep(1)
|
||||
else:
|
||||
assert False, "ClickHouse didn't disconnect from ZK after DROP rule was added"
|
||||
|
||||
def assert_keeper_exception_after_partition(query):
|
||||
with PartitionManager() as pm:
|
||||
pm.drop_instance_zk_connections(node)
|
||||
wait_disconnect_from_zk()
|
||||
error = node.query_and_get_error(query)
|
||||
assert "Coordination::Exception" in error
|
||||
|
||||
@ -49,17 +59,17 @@ def test_keeper_map_without_zk(started_cluster):
|
||||
"CREATE TABLE test_keeper_map_without_zk (key UInt64, value UInt64) ENGINE = KeeperMap('/test_without_zk') PRIMARY KEY(key);"
|
||||
)
|
||||
|
||||
node.query(
|
||||
node.query_with_retry(
|
||||
"CREATE TABLE test_keeper_map_without_zk (key UInt64, value UInt64) ENGINE = KeeperMap('/test_without_zk') PRIMARY KEY(key);"
|
||||
)
|
||||
|
||||
assert_keeper_exception_after_partition(
|
||||
"INSERT INTO test_keeper_map_without_zk VALUES (1, 11)"
|
||||
)
|
||||
node.query("INSERT INTO test_keeper_map_without_zk VALUES (1, 11)")
|
||||
node.query_with_retry("INSERT INTO test_keeper_map_without_zk VALUES (1, 11)")
|
||||
|
||||
assert_keeper_exception_after_partition("SELECT * FROM test_keeper_map_without_zk")
|
||||
node.query("SELECT * FROM test_keeper_map_without_zk")
|
||||
node.query_with_retry("SELECT * FROM test_keeper_map_without_zk")
|
||||
|
||||
with PartitionManager() as pm:
|
||||
pm.drop_instance_zk_connections(node)
|
||||
@ -67,7 +77,7 @@ def test_keeper_map_without_zk(started_cluster):
|
||||
error = node.query_and_get_error("SELECT * FROM test_keeper_map_without_zk")
|
||||
assert "Failed to activate table because of connection issues" in error
|
||||
|
||||
node.query("SELECT * FROM test_keeper_map_without_zk")
|
||||
node.query_with_retry("SELECT * FROM test_keeper_map_without_zk")
|
||||
|
||||
client = get_genuine_zk()
|
||||
remove_children(client, "/test_keeper_map/test_without_zk")
|
||||
|
Loading…
Reference in New Issue
Block a user