Skip to content

Commit f980974

Browse files
DAOS-18593 test: replace sleep with retry in rebuild/interactive.py (#17559)
Replace arbitrary sleep with a retry on expected DER_NONEXIST. Signed-off-by: Dalton Bohning <[email protected]>
1 parent 79c332d commit f980974

File tree

1 file changed

+20
-9
lines changed

1 file changed

+20
-9
lines changed

src/tests/ftest/rebuild/interactive.py

Lines changed: 20 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
"""
2-
(C) Copyright 2025 Hewlett Packard Enterprise Development LP
2+
(C) Copyright 2025-2026 Hewlett Packard Enterprise Development LP
33
44
SPDX-License-Identifier: BSD-2-Clause-Patent
55
"""
@@ -8,6 +8,7 @@
88

99
from apricot import TestWithServers
1010
from data_utils import assert_val_in_list
11+
from exception_utils import CommandFailure
1112
from ior_utils import get_ior
1213
from job_manager_utils import get_job_manager
1314

@@ -74,10 +75,6 @@ def __run_rebuild_interactive(self, pool, cont_ior, ior,
7475
- 'dmg pool reintegrate'
7576
- 'dmg system reintegrate'
7677
"""
77-
# Time to wait between rebuild start and manual stop.
78-
# If we stop too early rebuild might not have started yet.
79-
# Ideally, if we could poll the "actual" rebuild status this would not be necessary.
80-
secs_between_rebuild_start_and_manual_stop = 4
8178

8279
ior_flags_read = self.params.get('flags_read', '/run/ior/*')
8380
ior_ppn = self.params.get('ppn', '/run/ior/*')
@@ -100,8 +97,15 @@ def __run_rebuild_interactive(self, pool, cont_ior, ior,
10097
pool.wait_for_rebuild_to_start(interval=1)
10198

10299
self.log_step(f'{exclude_method} - Manually stop rebuild')
103-
time.sleep(secs_between_rebuild_start_and_manual_stop)
104-
pool.rebuild_stop()
100+
for i in range(3):
101+
try:
102+
pool.rebuild_stop()
103+
break
104+
except CommandFailure as error:
105+
if i == 2 or 'DER_NONEXIST' not in str(error):
106+
raise
107+
self.log.info('Assuming rebuild is not started yet. Retrying in 3 seconds...')
108+
time.sleep(3)
105109

106110
self.log_step(f'{exclude_method} - Wait for rebuild to stop')
107111
pool.wait_for_rebuild_to_stop(interval=3)
@@ -145,8 +149,15 @@ def __run_rebuild_interactive(self, pool, cont_ior, ior,
145149
pool.wait_for_rebuild_to_start(interval=1)
146150

147151
self.log_step(f'{reint_method} - Manually stop rebuild')
148-
time.sleep(secs_between_rebuild_start_and_manual_stop)
149-
pool.rebuild_stop()
152+
for i in range(3):
153+
try:
154+
pool.rebuild_stop()
155+
break
156+
except CommandFailure as error:
157+
if i == 2 or 'DER_NONEXIST' not in str(error):
158+
raise
159+
self.log.info('Assuming rebuild is not started yet. Retrying in 3 seconds...')
160+
time.sleep(3)
150161

151162
self.log_step(f'{reint_method} - Wait for rebuild to stop')
152163
pool.wait_for_rebuild_to_stop(interval=3)

0 commit comments

Comments
 (0)