Merge pull request #30150 from azat/test_MemoryTracking-flap

Make test_MemoryTracking::test_http not flaky
This commit is contained in:
alexey-milovidov 2021-10-15 01:28:59 +03:00 committed by GitHub
commit 9a57fbc9e8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -2,6 +2,17 @@
# pylint: disable=redefined-outer-name
# pylint: disable=line-too-long
# This test verifies that memory tracking does not have significant drift,
# in other words, every allocation should be taken into account at the global
# memory tracker.
#
# So we are running some queries with GROUP BY to make some allocations,
# and after we are checking MemoryTracking metric from system.metrics,
# and check that it does not changes too frequently.
#
# Also note, that syncing MemoryTracking with RSS had been disabled in
# asynchronous_metrics_update_period_s.xml.
import logging
import pytest
from helpers.cluster import ClickHouseCluster
@ -46,6 +57,8 @@ def get_MemoryTracking():
return int(http_query("SELECT value FROM system.metrics WHERE metric = 'MemoryTracking'"))
def check_memory(memory):
# bytes -> megabytes
memory = [*map(lambda x: int(int(x)/1024/1024), memory)]
# 3 changes to MemoryTracking is minimum, since:
# - this is not that high to not detect inacuracy
# - memory can go like X/X+N due to some background allocations