ClickHouse/tests/integration/test_system_reload_async_metrics/test.py

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

50 lines
1.3 KiB
Python
Raw Normal View History

import os
import shutil
import time
2024-09-27 10:19:39 +00:00
import pytest
from helpers.cluster import ClickHouseCluster
# Tests that SYSTEM RELOAD ASYNCHRONOUS METRICS works.
# Config default.xml sets a large refresh interval of asynchronous metrics, so that the periodic updates don't interfere with the manual
# update below.
cluster = ClickHouseCluster(__file__)
node = cluster.add_instance(
"node",
main_configs=["configs/default.xml"],
stay_alive=True,
)
@pytest.fixture(scope="module")
def start_cluster():
try:
cluster.start()
yield cluster
finally:
cluster.shutdown()
SCRIPT_DIR = os.path.dirname(os.path.realpath(__file__))
CONFIG_DIR = os.path.join(SCRIPT_DIR, "configs")
2024-01-23 10:33:03 +00:00
def test_system_reload_async_metrics(start_cluster):
node.query("SYSTEM DROP QUERY CACHE")
res1 = node.query(
"SELECT value FROM system.asynchronous_metrics WHERE metric = 'NumberOfTables'"
)
2024-01-23 05:58:24 +00:00
# create table and test that the table creation is reflected in the asynchronous metrics
2024-01-23 06:23:34 +00:00
node.query("CREATE TABLE tab (col UInt64) ENGINE MergeTree ORDER BY tuple()")
node.query("SYSTEM RELOAD ASYNCHRONOUS METRICS")
res2 = node.query(
"SELECT value FROM system.asynchronous_metrics WHERE metric = 'NumberOfTables'"
)
assert int(res1.rstrip()) + 1 == int(res2.rstrip())