ClickHouse/tests/integration/test_keeper_profiler/test.py

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

97 lines
2.9 KiB
Python
Raw Normal View History

2024-06-14 13:38:09 +00:00
import pytest
2024-09-27 10:19:39 +00:00
2024-06-14 13:38:09 +00:00
from helpers.cluster import ClickHouseCluster
from helpers.keeper_utils import KeeperClient, KeeperException
2024-09-27 10:19:39 +00:00
from helpers.test_tools import TSV
2024-06-14 13:38:09 +00:00
cluster = ClickHouseCluster(__file__)
node = cluster.add_instance(
"node1",
main_configs=["configs/keeper_config1.xml"],
stay_alive=True,
)
node2 = cluster.add_instance(
"node2",
main_configs=["configs/keeper_config2.xml"],
stay_alive=True,
with_minio=True,
)
node3 = cluster.add_instance(
"node3",
main_configs=["configs/keeper_config3.xml"],
stay_alive=True,
with_minio=True,
)
2024-06-14 13:45:00 +00:00
2024-06-14 13:38:09 +00:00
@pytest.fixture(scope="module", autouse=True)
def started_cluster():
try:
cluster.start()
yield cluster
finally:
cluster.shutdown()
def test_profiler(started_cluster):
node = cluster.instances["node1"]
2024-06-17 11:24:44 +00:00
if node.is_built_with_sanitizer():
2024-06-17 11:24:07 +00:00
return
2024-06-14 13:38:09 +00:00
node.query(
"CREATE TABLE t (key UInt32, value String) Engine = ReplicatedMergeTree('/clickhouse-tables/test1', 'r1') ORDER BY key"
)
2024-06-16 16:13:36 +00:00
for _ in range(100):
2024-06-16 09:36:12 +00:00
node.query("INSERT INTO t SELECT number, toString(number) from numbers(100)")
2024-06-14 13:38:09 +00:00
node.query("system flush logs")
assert int(node.query("exists system.trace_log"))
2024-06-17 15:59:17 +00:00
result = node.query(
"""
2024-06-14 13:38:09 +00:00
set allow_introspection_functions=1;
system flush logs;
select cnt from (
select count() as cnt, formatReadableSize(sum(size)),
arrayStringConcat(
arrayMap(x, y -> concat(x, ': ', y), arrayMap(x -> addressToLine(x), trace), arrayMap(x -> demangle(addressToSymbol(x)), trace)),
'\n') as trace
2024-06-18 14:33:59 +00:00
from system.trace_log where trace_type = Real and (trace ilike '%KeeperTCPHandler%' or trace ilike '%KeeperDispatcher%') group by trace order by cnt desc) limit 1;
2024-06-14 13:38:09 +00:00
"""
)
2024-06-17 15:59:17 +00:00
if len(result) == 0:
assert 0 < int(
node.query(
"""
set allow_introspection_functions=1;
system flush logs;
2024-06-17 20:35:49 +00:00
select sum(cnt) from (
2024-06-17 15:59:17 +00:00
select count() as cnt, formatReadableSize(sum(size)),
arrayStringConcat(
arrayMap(x, y -> concat(x, ': ', y), arrayMap(x -> addressToLine(x), trace), arrayMap(x -> demangle(addressToSymbol(x)), trace)),
'\n') as trace
from system.trace_log where trace_type = Real group by trace);
"""
)
)
result = node.query(
"""
set allow_introspection_functions=1;
system flush logs;
select * from (
select count() as cnt, formatReadableSize(sum(size)),
arrayStringConcat(
arrayMap(x, y -> concat(x, ': ', y), arrayMap(x -> addressToLine(x), trace), arrayMap(x -> demangle(addressToSymbol(x)), trace)),
'\n') as trace
from system.trace_log where trace_type = Real group by trace);
"""
)
print(result)
assert False
assert 1 < int(result)