mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-29 19:12:03 +00:00
try updating tests to wait for cluster configs to come in sync
This commit is contained in:
parent
1bef6fc76c
commit
4550b15876
@ -77,8 +77,16 @@ def get_config_str(zk: KazooClient) -> str:
|
|||||||
return zk.get("/keeper/config")[0].decode("utf-8")
|
return zk.get("/keeper/config")[0].decode("utf-8")
|
||||||
|
|
||||||
|
|
||||||
def configs_equal(left: str, right: str) -> bool:
|
def wait_configs_equal(left_config: str, right_zk: KazooClient, timeout: float = 30.0):
|
||||||
"""
|
"""
|
||||||
Check whether /keeper/config nodes are equal
|
Check whether get /keeper/config result in left_config is equal
|
||||||
|
to get /keeper/config on right_zk ZK connection.
|
||||||
"""
|
"""
|
||||||
return sorted(left.split("\n")) == sorted(right.split("\n"))
|
elapsed: float = 0.
|
||||||
|
while sorted(left_config.split("\n")) != sorted(get_config_str(right_zk).split("\n")):
|
||||||
|
time.sleep(1)
|
||||||
|
elapsed += 1
|
||||||
|
if elapsed >= timeout:
|
||||||
|
raise Exception(
|
||||||
|
f"timeout while checking nodes configs to get equal. "
|
||||||
|
f"Left: {left_config}, right: {get_config_str(right_zk)}")
|
||||||
|
@ -91,7 +91,7 @@ def test_reconfig_add(started_cluster):
|
|||||||
assert "node3" not in config
|
assert "node3" not in config
|
||||||
|
|
||||||
zk2 = get_fake_zk(node2)
|
zk2 = get_fake_zk(node2)
|
||||||
assert ku.configs_equal(config, ku.get_config_str(zk2))
|
ku.wait_configs_equal(config, zk2)
|
||||||
|
|
||||||
for i in range(100):
|
for i in range(100):
|
||||||
assert zk2.exists(f"/test_three_{i}") is not None
|
assert zk2.exists(f"/test_three_{i}") is not None
|
||||||
@ -132,7 +132,7 @@ def test_reconfig_add(started_cluster):
|
|||||||
assert "node3" in config
|
assert "node3" in config
|
||||||
|
|
||||||
zk3 = get_fake_zk(node3)
|
zk3 = get_fake_zk(node3)
|
||||||
assert ku.configs_equal(config, ku.get_config_str(zk3))
|
ku.wait_configs_equal(config, zk3)
|
||||||
|
|
||||||
for i in range(100):
|
for i in range(100):
|
||||||
assert zk3.exists(f"/test_four_{i}") is not None
|
assert zk3.exists(f"/test_four_{i}") is not None
|
||||||
|
@ -70,11 +70,11 @@ def test_reconfig_remove_followers_from_3(started_cluster):
|
|||||||
|
|
||||||
zk2 = get_fake_zk(node2)
|
zk2 = get_fake_zk(node2)
|
||||||
zk2.sync("/test_two_0")
|
zk2.sync("/test_two_0")
|
||||||
assert ku.configs_equal(config, ku.get_config_str(zk2))
|
ku.wait_configs_equal(config, zk2)
|
||||||
|
|
||||||
zk3 = get_fake_zk(node3)
|
zk3 = get_fake_zk(node3)
|
||||||
zk3.sync("/test_two_0")
|
zk3.sync("/test_two_0")
|
||||||
assert ku.configs_equal(config, ku.get_config_str(zk3))
|
ku.wait_configs_equal(config, zk3)
|
||||||
|
|
||||||
for i in range(100):
|
for i in range(100):
|
||||||
assert zk2.exists(f"test_two_{i}") is not None
|
assert zk2.exists(f"test_two_{i}") is not None
|
||||||
@ -92,7 +92,7 @@ def test_reconfig_remove_followers_from_3(started_cluster):
|
|||||||
zk2.stop()
|
zk2.stop()
|
||||||
zk2.close()
|
zk2.close()
|
||||||
zk2 = get_fake_zk(node2)
|
zk2 = get_fake_zk(node2)
|
||||||
assert ku.configs_equal(config, ku.get_config_str(zk2))
|
ku.wait_configs_equal(config, zk2)
|
||||||
|
|
||||||
for i in range(100):
|
for i in range(100):
|
||||||
assert zk2.exists(f"test_two_{i}") is not None
|
assert zk2.exists(f"test_two_{i}") is not None
|
||||||
|
@ -54,11 +54,11 @@ def test_reconfig_remove_2_and_leader(started_cluster):
|
|||||||
|
|
||||||
zk4 = get_fake_zk(node4)
|
zk4 = get_fake_zk(node4)
|
||||||
zk4.sync("/test_two_0")
|
zk4.sync("/test_two_0")
|
||||||
assert ku.configs_equal(config, ku.get_config_str(zk4))
|
ku.wait_configs_equal(config, zk4)
|
||||||
|
|
||||||
zk5 = get_fake_zk(node5)
|
zk5 = get_fake_zk(node5)
|
||||||
zk5.sync("/test_two_0")
|
zk5.sync("/test_two_0")
|
||||||
assert ku.configs_equal(config, ku.get_config_str(zk5))
|
ku.wait_configs_equal(config, zk5)
|
||||||
|
|
||||||
for i in range(100):
|
for i in range(100):
|
||||||
assert zk4.exists(f"test_two_{i}") is not None
|
assert zk4.exists(f"test_two_{i}") is not None
|
||||||
@ -83,7 +83,7 @@ def test_reconfig_remove_2_and_leader(started_cluster):
|
|||||||
zk1 = get_fake_zk(node1)
|
zk1 = get_fake_zk(node1)
|
||||||
zk1.sync("/test_two_0")
|
zk1.sync("/test_two_0")
|
||||||
|
|
||||||
assert ku.configs_equal(config, ku.get_config_str(zk1))
|
ku.wait_configs_equal(config, zk1)
|
||||||
|
|
||||||
for i in range(200):
|
for i in range(200):
|
||||||
assert zk1.exists(f"test_two_{i}") is not None
|
assert zk1.exists(f"test_two_{i}") is not None
|
||||||
@ -128,11 +128,11 @@ def test_reconfig_remove_2_and_leader(started_cluster):
|
|||||||
zk2.close()
|
zk2.close()
|
||||||
zk2 = get_fake_zk(node2)
|
zk2 = get_fake_zk(node2)
|
||||||
zk2.sync("/test_leader_0")
|
zk2.sync("/test_leader_0")
|
||||||
assert ku.configs_equal(config, ku.get_config_str(zk2))
|
ku.wait_configs_equal(config, zk2)
|
||||||
|
|
||||||
zk3 = get_fake_zk(node3)
|
zk3 = get_fake_zk(node3)
|
||||||
zk3.sync("/test_leader_0")
|
zk3.sync("/test_leader_0")
|
||||||
assert ku.configs_equal(config, ku.get_config_str(zk3))
|
ku.wait_configs_equal(config, zk3)
|
||||||
|
|
||||||
for i in range(100):
|
for i in range(100):
|
||||||
assert zk2.exists(f"test_leader_{i}") is not None
|
assert zk2.exists(f"test_leader_{i}") is not None
|
||||||
|
@ -62,11 +62,11 @@ def test_reconfig_replace_leader(started_cluster):
|
|||||||
|
|
||||||
zk2 = get_fake_zk(node2)
|
zk2 = get_fake_zk(node2)
|
||||||
zk2.sync("/test_four_0")
|
zk2.sync("/test_four_0")
|
||||||
assert ku.configs_equal(config, ku.get_config_str(zk2))
|
ku.wait_configs_equal(config, zk2)
|
||||||
|
|
||||||
zk3 = get_fake_zk(node3)
|
zk3 = get_fake_zk(node3)
|
||||||
zk3.sync("/test_four_0")
|
zk3.sync("/test_four_0")
|
||||||
assert ku.configs_equal(config, ku.get_config_str(zk3))
|
ku.wait_configs_equal(config, zk3)
|
||||||
|
|
||||||
for i in range(100):
|
for i in range(100):
|
||||||
assert zk2.exists(f"/test_four_{i}") is not None
|
assert zk2.exists(f"/test_four_{i}") is not None
|
||||||
@ -104,7 +104,7 @@ def test_reconfig_replace_leader(started_cluster):
|
|||||||
assert "node4" in config
|
assert "node4" in config
|
||||||
|
|
||||||
zk4 = get_fake_zk(node4)
|
zk4 = get_fake_zk(node4)
|
||||||
assert ku.configs_equal(config, ku.get_config_str(zk4))
|
ku.wait_configs_equal(config, zk4)
|
||||||
|
|
||||||
for i in range(100):
|
for i in range(100):
|
||||||
assert zk4.exists(f"test_four_{i}") is not None
|
assert zk4.exists(f"test_four_{i}") is not None
|
||||||
@ -114,13 +114,13 @@ def test_reconfig_replace_leader(started_cluster):
|
|||||||
zk2.close()
|
zk2.close()
|
||||||
zk2 = get_fake_zk(node2)
|
zk2 = get_fake_zk(node2)
|
||||||
zk2.sync("/test_four_0")
|
zk2.sync("/test_four_0")
|
||||||
assert ku.configs_equal(config, ku.get_config_str(zk2))
|
ku.wait_configs_equal(config, zk2)
|
||||||
|
|
||||||
zk3.stop()
|
zk3.stop()
|
||||||
zk3.close()
|
zk3.close()
|
||||||
zk3 = get_fake_zk(node3)
|
zk3 = get_fake_zk(node3)
|
||||||
zk3.sync("/test_four_0")
|
zk3.sync("/test_four_0")
|
||||||
assert ku.configs_equal(config, ku.get_config_str(zk3))
|
ku.wait_configs_equal(config, zk3)
|
||||||
|
|
||||||
for i in range(200):
|
for i in range(200):
|
||||||
assert zk2.exists(f"test_four_{i}") is not None
|
assert zk2.exists(f"test_four_{i}") is not None
|
||||||
|
@ -62,11 +62,11 @@ def test_reconfig_replace_leader_in_one_command(started_cluster):
|
|||||||
|
|
||||||
zk2 = get_fake_zk(node2)
|
zk2 = get_fake_zk(node2)
|
||||||
zk2.sync("/test_four_0")
|
zk2.sync("/test_four_0")
|
||||||
assert ku.configs_equal(config, ku.get_config_str(zk2))
|
ku.wait_configs_equal(config, zk2)
|
||||||
|
|
||||||
zk3 = get_fake_zk(node3)
|
zk3 = get_fake_zk(node3)
|
||||||
zk3.sync("/test_four_0")
|
zk3.sync("/test_four_0")
|
||||||
assert ku.configs_equal(config, ku.get_config_str(zk3))
|
ku.wait_configs_equal(config, zk3)
|
||||||
|
|
||||||
for i in range(100):
|
for i in range(100):
|
||||||
assert zk2.exists(f"/test_four_{i}") is not None
|
assert zk2.exists(f"/test_four_{i}") is not None
|
||||||
@ -91,7 +91,7 @@ def test_reconfig_replace_leader_in_one_command(started_cluster):
|
|||||||
|
|
||||||
zk4 = get_fake_zk(node4)
|
zk4 = get_fake_zk(node4)
|
||||||
zk4.sync("/test_four_0")
|
zk4.sync("/test_four_0")
|
||||||
assert ku.configs_equal(config, ku.get_config_str(zk4))
|
ku.wait_configs_equal(config, zk4)
|
||||||
|
|
||||||
for i in range(100):
|
for i in range(100):
|
||||||
assert zk4.exists(f"test_four_{i}") is not None
|
assert zk4.exists(f"test_four_{i}") is not None
|
||||||
@ -107,13 +107,13 @@ def test_reconfig_replace_leader_in_one_command(started_cluster):
|
|||||||
zk2.close()
|
zk2.close()
|
||||||
zk2 = get_fake_zk(node2)
|
zk2 = get_fake_zk(node2)
|
||||||
zk2.sync("/test_four_0")
|
zk2.sync("/test_four_0")
|
||||||
assert ku.configs_equal(config, ku.get_config_str(zk2))
|
ku.wait_configs_equal(config, zk2)
|
||||||
|
|
||||||
zk3.stop()
|
zk3.stop()
|
||||||
zk3.close()
|
zk3.close()
|
||||||
zk3 = get_fake_zk(node3)
|
zk3 = get_fake_zk(node3)
|
||||||
zk3.sync("/test_four_0")
|
zk3.sync("/test_four_0")
|
||||||
assert ku.configs_equal(config, ku.get_config_str(zk3))
|
ku.configs_equal(config, zk3)
|
||||||
|
|
||||||
for i in range(200):
|
for i in range(200):
|
||||||
assert zk2.exists(f"test_four_{i}") is not None
|
assert zk2.exists(f"test_four_{i}") is not None
|
||||||
|
Loading…
Reference in New Issue
Block a user