Skip to content

Commit f0d54df

Browse files
authored
Merge pull request ClickHouse#79948 from ClickHouse/ncb/fix-cgroup-limit
fix flaky test_cgroup_limit
2 parents 96829ff + 5286df1 commit f0d54df

File tree

1 file changed

+12
-12
lines changed
  • tests/integration/test_cgroup_limit

1 file changed

+12
-12
lines changed

tests/integration/test_cgroup_limit/test.py

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,9 @@
1-
#!/usr/bin/env python3
2-
31
import logging
42
import math
53
import os
64
import subprocess
7-
from tempfile import NamedTemporaryFile
85

9-
import pytest
6+
from helpers.test_tools import wait_condition
107

118

129
def run_command_in_container(cmd, *args):
@@ -43,14 +40,17 @@ def run_with_cpu_limit(cmd, num_cpus, *args):
4340

4441
def test_cgroup_cpu_limit():
4542
for num_cpus in (1, 2, 4, 2.8):
46-
result = run_with_cpu_limit(
47-
"clickhouse local -q \"select value from system.settings where name='max_threads'\"",
48-
num_cpus,
49-
)
50-
expect_output = (r"\'auto({})\'".format(math.ceil(num_cpus))).encode()
51-
assert (
52-
result.strip() == expect_output
53-
), f"fail for cpu limit={num_cpus}, result={result.strip()}, expect={expect_output}"
43+
def run_with_retry():
44+
result = run_with_cpu_limit(
45+
"clickhouse local -q \"select value from system.settings where name='max_threads'\"",
46+
num_cpus,
47+
)
48+
expect_output = (r"\'auto({})\'".format(math.ceil(num_cpus))).encode()
49+
return (
50+
result.strip() == expect_output
51+
), f"fail for cpu limit={num_cpus}, result={result.strip()}, expect={expect_output}"
52+
53+
wait_condition(run_with_retry, lambda x:x, max_attempts=3, delay=0.2)
5454

5555

5656
# For manual run

0 commit comments

Comments
 (0)