Skip to content

Commit 6c95045

Browse files
committed
fix: develop a more flexible solution for sidekiq helper
Signed-off-by: Tim Knight <tim.knight1@engineering.digital.dwp.gov.uk>
1 parent 0426f1f commit 6c95045

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

tests/functional/conftest.py

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -211,20 +211,24 @@ def _check(
211211
@pytest.fixture
212212
def wait_for_sidekiq(gl):
213213
"""
214-
Return a helper function to wait until there are no busy sidekiq processes.
214+
Return a helper function to wait until there are spare sidekiq processes.
215+
216+
Because not all Groups can be deleted immediately in GL 16, we will likely have busy Sidekiq jobs
217+
set aside for their deletion in 1 days time.
215218
216219
Use this with asserts for slow tasks (group/project/user creation/deletion).
217220
"""
218221

219222
def _wait(timeout: int = 30, step: float = 0.5, allow_fail: bool = False) -> bool:
220223
for count in range(timeout):
221224
time.sleep(step)
222-
busy = False
223225
processes = gl.sidekiq.process_metrics()["processes"]
226+
busy_processes = []
224227
for process in processes:
225228
if process["busy"]:
226-
busy = True
227-
if not busy:
229+
busy_processes.append(process)
230+
# If we have at least one spare process, continue
231+
if not (len(busy_processes) + 1) >= len(processes):
228232
return True
229233
logging.info(f"sidekiq busy {count} of {timeout}")
230234
assert allow_fail, "sidekiq process should have terminated but did not."

0 commit comments

Comments
 (0)