mirror of
https://github.com/ansible/awx.git
synced 2026-03-09 13:39:27 -02:30
Fix indirect host counting task test race condition (#15871)
This commit is contained in:
@@ -50,13 +50,14 @@ def test_indirect_host_counting(live_tmp_folder, run_job_from_playbook):
|
|||||||
job.refresh_from_db()
|
job.refresh_from_db()
|
||||||
if job.event_queries_processed is False:
|
if job.event_queries_processed is False:
|
||||||
save_indirect_host_entries.delay(job.id, wait_for_events=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):
|
# event_queries_processed only assures the task has started, it might take a minor amount of time to finish
|
||||||
if IndirectManagedNodeAudit.objects.filter(job=job).exists():
|
for _ in range(10):
|
||||||
break
|
if IndirectManagedNodeAudit.objects.filter(job=job).exists():
|
||||||
time.sleep(0.2)
|
break
|
||||||
else:
|
time.sleep(0.2)
|
||||||
raise RuntimeError(f'No IndirectManagedNodeAudit records ever populated for job_id={job.id}')
|
else:
|
||||||
|
raise RuntimeError(f'No IndirectManagedNodeAudit records ever populated for job_id={job.id}')
|
||||||
|
|
||||||
assert IndirectManagedNodeAudit.objects.filter(job=job).count() == 1
|
assert IndirectManagedNodeAudit.objects.filter(job=job).count() == 1
|
||||||
host_audit = IndirectManagedNodeAudit.objects.filter(job=job).first()
|
host_audit = IndirectManagedNodeAudit.objects.filter(job=job).first()
|
||||||
|
|||||||
Reference in New Issue
Block a user