Files
ClickGap AI Bot 0d4ebbacf7 Add integration test for cgroup metrics path concatenation bug
Add test_cgroup_metrics/ to verify that CGroupUserTime and CGroupSystemTime
metrics are correctly collected when ClickHouse runs in a cgroup v2 environment
with a nested cgroup path.

The test detects the bug in src/Common/AsynchronousMetrics.cpp:119 where
openCgroupv2MetricFile incorrectly concatenates the cgroup path with the
filename using string addition instead of proper path operations. This causes
paths like '/sys/fs/cgroup/docker/abc' + 'cpu.stat' to produce
'/sys/fs/cgroup/docker/abccpu.stat' instead of the correct
'/sys/fs/cgroup/docker/abc/cpu.stat'.

The test:
- Uses pytest.skip() when cgroup v2 is not available (proper CI reporting)
- Uses retry/poll loops instead of fixed sleeps for metric collection
- Queries system.asynchronous_metrics for CGroupUserTime and CGroupSystemTime
- Asserts the metrics exist and have non-negative values
- Verifies CPU time increases by at least 1ms after CPU-intensive work

If the path concatenation bug is present, the metrics will not be reported
and the test will fail.
2026-05-08 15:00:31 +00:00

0 lines
0 B
Python