ClickHouse/tests/integration/test_system_clusters_actual_information/test.py

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

60 lines
1.5 KiB
Python
Raw Normal View History

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
@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')"
)
yield cluster
finally:
cluster.shutdown()
def test(started_cluster):
node.query("SYSTEM RELOAD CONFIG")
error = node.query_and_get_error(
"SELECT count() FROM distributed SETTINGS receive_timeout=1, handshake_timeout_ms=1"
)
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