From 293abc8b352ec006d0ff0bbeac2ca13816cb5327 Mon Sep 17 00:00:00 2001 From: Peter Braun Date: Tue, 4 Mar 2025 23:00:50 +0100 Subject: [PATCH] fix: make indirect host counting live test more reliable --- .../tests/live/tests/test_indirect_host_counting.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/awx/main/tests/live/tests/test_indirect_host_counting.py b/awx/main/tests/live/tests/test_indirect_host_counting.py index ce202f02ae..203687604b 100644 --- a/awx/main/tests/live/tests/test_indirect_host_counting.py +++ b/awx/main/tests/live/tests/test_indirect_host_counting.py @@ -49,7 +49,15 @@ def test_indirect_host_counting(live_tmp_folder, run_job_from_playbook): # Task might not run due to race condition, so make it run here job.refresh_from_db() if job.event_queries_processed is False: - save_indirect_host_entries.delay(job.id, wait_for_events=False) + for _ in range(10): + save_indirect_host_entries.delay(job.id, wait_for_events=True) + job.refresh_from_db() + if job.event_queries_processed is True: + break + time.sleep(0.5) + else: + raise RuntimeError(f'Job events not received for job_id={job.id}') + # This will poll for the background task to finish for _ in range(10): if IndirectManagedNodeAudit.objects.filter(job=job).exists():