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..2843eaeba5 100644 --- a/awx/main/tests/live/tests/test_indirect_host_counting.py +++ b/awx/main/tests/live/tests/test_indirect_host_counting.py @@ -50,13 +50,14 @@ def test_indirect_host_counting(live_tmp_folder, run_job_from_playbook): job.refresh_from_db() if job.event_queries_processed is False: save_indirect_host_entries.delay(job.id, wait_for_events=False) - # This will poll for the background task to finish - for _ in range(10): - if IndirectManagedNodeAudit.objects.filter(job=job).exists(): - break - time.sleep(0.2) - else: - raise RuntimeError(f'No IndirectManagedNodeAudit records ever populated for job_id={job.id}') + + # event_queries_processed only assures the task has started, it might take a minor amount of time to finish + for _ in range(10): + if IndirectManagedNodeAudit.objects.filter(job=job).exists(): + break + time.sleep(0.2) + else: + raise RuntimeError(f'No IndirectManagedNodeAudit records ever populated for job_id={job.id}') assert IndirectManagedNodeAudit.objects.filter(job=job).count() == 1 host_audit = IndirectManagedNodeAudit.objects.filter(job=job).first()