|
1 | | -import logging |
2 | 1 | import time |
3 | 2 |
|
4 | 3 | import pytest |
5 | 4 |
|
6 | 5 | from helpers.cluster import ClickHouseCluster |
7 | | -from helpers.test_tools import TSV, assert_eq_with_retry |
| 6 | +from helpers.test_tools import wait_condition |
8 | 7 |
|
9 | 8 | cluster = ClickHouseCluster(__file__) |
10 | 9 | 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): |
94 | 93 |
|
95 | 94 | instance.restart_clickhouse(kill=True) |
96 | 95 |
|
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