2021-03-05 23:45:17 +00:00
|
|
|
import os
|
|
|
|
import sys
|
|
|
|
import time
|
|
|
|
|
|
|
|
import pytest
|
|
|
|
|
|
|
|
sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
|
|
|
|
|
|
|
|
from helpers.cluster import ClickHouseCluster
|
|
|
|
|
|
|
|
cluster = ClickHouseCluster(__file__)
|
|
|
|
node = cluster.add_instance(
|
|
|
|
"node", with_zookeeper=True, main_configs=["configs/remote_servers.xml"]
|
|
|
|
)
|
|
|
|
|
2024-03-14 18:06:02 +00:00
|
|
|
|
2021-03-05 23:45:17 +00:00
|
|
|
@pytest.fixture(scope="module")
|
|
|
|
def started_cluster():
|
|
|
|
try:
|
|
|
|
cluster.start()
|
2021-04-29 11:57:48 +00:00
|
|
|
node.query_with_retry(
|
|
|
|
"CREATE TABLE distributed (id UInt32, date Date) ENGINE = Distributed('test_cluster', 'default', 'replicated')"
|
|
|
|
)
|
2021-03-05 23:45:17 +00:00
|
|
|
|
|
|
|
yield cluster
|
|
|
|
|
|
|
|
finally:
|
|
|
|
cluster.shutdown()
|
|
|
|
|
|
|
|
|
|
|
|
def test(started_cluster):
|
|
|
|
node.query("SYSTEM RELOAD CONFIG")
|
2023-05-23 11:39:40 +00:00
|
|
|
error = node.query_and_get_error(
|
|
|
|
"SELECT count() FROM distributed SETTINGS receive_timeout=1, handshake_timeout_ms=1"
|
2021-03-05 23:45:17 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
result = node.query(
|
|
|
|
"SELECT errors_count, estimated_recovery_time FROM system.clusters WHERE cluster='test_cluster' and host_name='node_1'"
|
|
|
|
)
|
|
|
|
errors_count, recovery_time = map(int, result.split())
|
|
|
|
assert errors_count == 3
|
|
|
|
|
|
|
|
while True:
|
|
|
|
time.sleep(1)
|
|
|
|
|
|
|
|
result = node.query(
|
|
|
|
"SELECT errors_count, estimated_recovery_time FROM system.clusters WHERE cluster='test_cluster' and host_name='node_1'"
|
|
|
|
)
|
|
|
|
prev_time = recovery_time
|
|
|
|
errors_count, recovery_time = map(int, result.split())
|
|
|
|
|
|
|
|
if recovery_time == 0:
|
|
|
|
break
|
|
|
|
|
|
|
|
assert recovery_time < prev_time
|
|
|
|
assert errors_count > 0
|
|
|
|
|
|
|
|
assert recovery_time == 0
|
|
|
|
assert errors_count == 0
|