Skip to content

Commit

Permalink
Taught monitor_task_group fixture to respond better to fatal errors.
Browse files Browse the repository at this point in the history
fixes pulp#3923.
  • Loading branch information
ggainey committed Jul 11, 2023
1 parent ee78e0c commit d517e67
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGES/3923.misc
@@ -0,0 +1 @@
Fixed possible infinite-wait in monitor_task_group fixture.
11 changes: 10 additions & 1 deletion pulpcore/tests/functional/__init__.py
Expand Up @@ -812,9 +812,18 @@ def _monitor_task(task_href):
@pytest.fixture(scope="session")
def monitor_task_group(task_groups_api_client):
def _monitor_task_group(task_group_href):
def tasks_open(tg):
return (tg.waiting + tg.running) > 0

def group_wait(tg):
return not tg.all_tasks_dispatched or tasks_open(tg)

def group_fail(tg):
return tg.failed > 0 and not tasks_open(tg)

task_group = task_groups_api_client.read(task_group_href)

while not task_group.all_tasks_dispatched or (task_group.waiting + task_group.running) > 0:
while group_wait(task_group) and not group_fail(task_group):
sleep(SLEEP_TIME)
task_group = task_groups_api_client.read(task_group_href)

Expand Down

0 comments on commit d517e67

Please sign in to comment.