2024-06-05 11:46:23 +00:00
|
|
|
import time
|
|
|
|
|
|
|
|
import pytest
|
|
|
|
from helpers.cluster import ClickHouseCluster
|
|
|
|
|
|
|
|
cluster = ClickHouseCluster(__file__)
|
|
|
|
node1 = cluster.add_instance(
|
|
|
|
"node1",
|
|
|
|
main_configs=["configs/asynchronous_metrics_update_period_s.xml"],
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
@pytest.fixture(scope="module")
|
|
|
|
def started_cluster():
|
|
|
|
try:
|
|
|
|
cluster.start()
|
|
|
|
yield cluster
|
|
|
|
|
|
|
|
finally:
|
|
|
|
cluster.shutdown()
|
|
|
|
|
|
|
|
|
|
|
|
# asynchronous metrics are updated once every 60s by default. To make the test run faster, the setting
|
2024-06-07 16:53:44 +00:00
|
|
|
# asynchronous_metric_update_period_s is being set to 1s so that the metrics are populated faster and
|
2024-06-05 11:46:23 +00:00
|
|
|
# are available for querying during the test.
|
2024-06-07 16:53:44 +00:00
|
|
|
def test_asynchronous_metric_jemalloc_profile_active(started_cluster):
|
2024-06-08 10:19:15 +00:00
|
|
|
# default open
|
2024-06-07 16:41:47 +00:00
|
|
|
if node1.is_built_with_sanitizer():
|
|
|
|
pytest.skip("Disabled for sanitizers")
|
|
|
|
|
2024-06-27 06:46:10 +00:00
|
|
|
res = node1.query(
|
2024-06-06 02:20:09 +00:00
|
|
|
"SELECT * FROM system.asynchronous_metrics WHERE metric ILIKE '%jemalloc.prof.active%' FORMAT Vertical;"
|
|
|
|
)
|
2024-06-05 11:46:23 +00:00
|
|
|
assert (
|
2024-06-27 06:46:10 +00:00
|
|
|
res
|
2024-06-06 02:20:09 +00:00
|
|
|
== """Row 1:
|
2024-06-05 11:46:23 +00:00
|
|
|
──────
|
|
|
|
metric: jemalloc.prof.active
|
2024-06-27 06:46:10 +00:00
|
|
|
value: 0
|
2024-06-05 11:46:23 +00:00
|
|
|
description: An internal metric of the low-level memory allocator (jemalloc). See https://jemalloc.net/jemalloc.3.html
|
|
|
|
"""
|
|
|
|
)
|
2024-06-27 06:46:10 +00:00
|
|
|
# enable
|
|
|
|
node1.query("SYSTEM JEMALLOC ENABLE PROFILE")
|
|
|
|
node1.query("SYSTEM RELOAD ASYNCHRONOUS METRICS")
|
|
|
|
res = node1.query(
|
2024-06-06 02:20:09 +00:00
|
|
|
"SELECT * FROM system.asynchronous_metrics WHERE metric ILIKE '%jemalloc.prof.active%' FORMAT Vertical;"
|
|
|
|
)
|
2024-06-05 11:46:23 +00:00
|
|
|
assert (
|
2024-06-27 06:46:10 +00:00
|
|
|
res
|
2024-06-06 02:20:09 +00:00
|
|
|
== """Row 1:
|
2024-06-05 11:46:23 +00:00
|
|
|
──────
|
|
|
|
metric: jemalloc.prof.active
|
2024-06-27 06:46:10 +00:00
|
|
|
value: 1
|
2024-06-05 11:46:23 +00:00
|
|
|
description: An internal metric of the low-level memory allocator (jemalloc). See https://jemalloc.net/jemalloc.3.html
|
2024-06-06 02:20:09 +00:00
|
|
|
"""
|
|
|
|
)
|
2024-06-27 06:46:10 +00:00
|
|
|
# disable
|
|
|
|
node1.query("SYSTEM JEMALLOC DISABLE PROFILE")
|
|
|
|
node1.query("SYSTEM RELOAD ASYNCHRONOUS METRICS")
|
|
|
|
res = node1.query(
|
2024-06-06 02:20:09 +00:00
|
|
|
"SELECT * FROM system.asynchronous_metrics WHERE metric ILIKE '%jemalloc.prof.active%' FORMAT Vertical;"
|
|
|
|
)
|
|
|
|
assert (
|
2024-06-27 06:46:10 +00:00
|
|
|
res
|
2024-06-06 02:20:09 +00:00
|
|
|
== """Row 1:
|
|
|
|
──────
|
|
|
|
metric: jemalloc.prof.active
|
2024-06-27 06:46:10 +00:00
|
|
|
value: 0
|
2024-06-06 02:20:09 +00:00
|
|
|
description: An internal metric of the low-level memory allocator (jemalloc). See https://jemalloc.net/jemalloc.3.html
|
2024-06-05 11:46:23 +00:00
|
|
|
"""
|
|
|
|
)
|