Perhaps you can query the status of job using the correlation id (taking the examples from ovirt-system-tests):
dead_snap1_params = types.Snapshot(
description=SNAPSHOT_DESC_1,
persist_memorystate=False,
disk_attachments=[
types.DiskAttachment(
disk=types.Disk(
)
)
]
)
correlation_id = uuid.uuid4()
vm1_snapshots_service.add(dead_snap1_params,
query={'correlation_id': correlation_id})
testlib.assert_true_within_long(
lambda:
test_utils.all_jobs_finished(engine, correlation_id)
)
All jobs finished checks that jobs with correlation_id have finished, it is implemented like this[2]:
def all_jobs_finished(engine, correlation_id):
try:
jobs = engine.jobs_service().list(
search='correlation_id=%s' % correlation_id
)
except:
jobs = engine.jobs_service().list()
return all(job.status != types.JobStatus.STARTED for job in jobs)
You can instead do something like this:
jobs = engine.jobs_service().list(
search='correlation_id=%s' % correlation_id
)
return any(job.status == types.JobStatus.FAILED for job in jobs)