Skip to content

Commit d2697c0

Browse files
authored
Merge pull request ClickHouse#79865 from ClickHouse/ncb/fix-cov-by-broken-exists
fix flaky test test_covered_by_broken_exists
2 parents 9981e37 + 31dc138 commit d2697c0

File tree

1 file changed

+22
-13
lines changed
  • tests/integration/test_covered_by_broken_exists

1 file changed

+22
-13
lines changed

tests/integration/test_covered_by_broken_exists/test.py

Lines changed: 22 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
1-
import logging
21
import time
32

43
import pytest
54

65
from helpers.cluster import ClickHouseCluster
7-
from helpers.test_tools import TSV, assert_eq_with_retry
6+
from helpers.test_tools import wait_condition
87

98
cluster = ClickHouseCluster(__file__)
109
node1 = cluster.add_instance("node1", stay_alive=True, with_zookeeper=True)
@@ -94,14 +93,24 @@ def test_make_clone_covered_by_broken_detached_dir_exists(started_cluster):
9493

9594
instance.restart_clickhouse(kill=True)
9695

97-
assert [
98-
"broken-on-start_all_0_1_1",
99-
"broken-on-start_all_0_2_2",
100-
"broken-on-start_all_0_3_3",
101-
"covered-by-broken_all_0_0_0",
102-
"covered-by-broken_all_1_1_0",
103-
"covered-by-broken_all_2_2_0",
104-
"covered-by-broken_all_3_3_0",
105-
] == sorted(
106-
instance.exec_in_container(["ls", data_path + "detached/"]).strip().split("\n")
107-
)
96+
# Sometimes,though rare, there seems to be a slight delay on ci and the parts don't become
97+
# available immediately after restarting the server. In this case, the test fails. So, sleep
98+
# for a second and then try to assert with retries to ensure that the test is not flaky.
99+
time.sleep(1)
100+
101+
def assert_detached_parts(): # check that the broken parts are not in system.parts
102+
return [
103+
"broken-on-start_all_0_1_1",
104+
"broken-on-start_all_0_2_2",
105+
"broken-on-start_all_0_3_3",
106+
"covered-by-broken_all_0_0_0",
107+
"covered-by-broken_all_1_1_0",
108+
"covered-by-broken_all_2_2_0",
109+
"covered-by-broken_all_3_3_0",
110+
] == sorted(
111+
instance.exec_in_container(["ls", data_path + "detached/"])
112+
.strip()
113+
.split("\n")
114+
)
115+
116+
wait_condition(assert_detached_parts, lambda x: x, max_attempts=10, delay=0.2)

0 commit comments

Comments
 (0)