aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorJohn Snow <jsnow@redhat.com>2019-05-23 13:06:42 -0400
committerMax Reitz <mreitz@redhat.com>2019-06-14 14:16:57 +0200
commitd6a79af0e641806d6bd6a42a4920e294b5db179c (patch)
tree21230cc5c72b009c388d01f1dfe9ecd4ee3990c5 /tests
parentf6f4b3f045ea18e3fa93a50cd0462236c428d62e (diff)
downloadqemu-d6a79af0e641806d6bd6a42a4920e294b5db179c.zip
qemu-d6a79af0e641806d6bd6a42a4920e294b5db179c.tar.gz
qemu-d6a79af0e641806d6bd6a42a4920e294b5db179c.tar.bz2
iotests.py: rewrite run_job to be pickier
Don't pull events out of the queue that don't belong to us; be choosier so that we can use this method to drive jobs that were launched by transactions that may have more jobs. Signed-off-by: John Snow <jsnow@redhat.com> Message-id: 20190523170643.20794-5-jsnow@redhat.com Reviewed-by: Max Reitz <mreitz@redhat.com> Signed-off-by: Max Reitz <mreitz@redhat.com>
Diffstat (limited to 'tests')
-rw-r--r--tests/qemu-iotests/iotests.py48
1 files changed, 29 insertions, 19 deletions
diff --git a/tests/qemu-iotests/iotests.py b/tests/qemu-iotests/iotests.py
index 6a3703e..3ecef5b 100644
--- a/tests/qemu-iotests/iotests.py
+++ b/tests/qemu-iotests/iotests.py
@@ -543,27 +543,37 @@ class VM(qtest.QEMUQtestMachine):
# Returns None on success, and an error string on failure
def run_job(self, job, auto_finalize=True, auto_dismiss=False,
pre_finalize=None, wait=60.0):
+ match_device = {'data': {'device': job}}
+ match_id = {'data': {'id': job}}
+ events = [
+ ('BLOCK_JOB_COMPLETED', match_device),
+ ('BLOCK_JOB_CANCELLED', match_device),
+ ('BLOCK_JOB_ERROR', match_device),
+ ('BLOCK_JOB_READY', match_device),
+ ('BLOCK_JOB_PENDING', match_id),
+ ('JOB_STATUS_CHANGE', match_id)
+ ]
error = None
while True:
- for ev in self.get_qmp_events_filtered(wait=wait):
- if ev['event'] == 'JOB_STATUS_CHANGE':
- status = ev['data']['status']
- if status == 'aborting':
- result = self.qmp('query-jobs')
- for j in result['return']:
- if j['id'] == job:
- error = j['error']
- log('Job failed: %s' % (j['error']))
- elif status == 'pending' and not auto_finalize:
- if pre_finalize:
- pre_finalize()
- self.qmp_log('job-finalize', id=job)
- elif status == 'concluded' and not auto_dismiss:
- self.qmp_log('job-dismiss', id=job)
- elif status == 'null':
- return error
- else:
- log(ev)
+ ev = filter_qmp_event(self.events_wait(events))
+ if ev['event'] != 'JOB_STATUS_CHANGE':
+ log(ev)
+ continue
+ status = ev['data']['status']
+ if status == 'aborting':
+ result = self.qmp('query-jobs')
+ for j in result['return']:
+ if j['id'] == job:
+ error = j['error']
+ log('Job failed: %s' % (j['error']))
+ elif status == 'pending' and not auto_finalize:
+ if pre_finalize:
+ pre_finalize()
+ self.qmp_log('job-finalize', id=job)
+ elif status == 'concluded' and not auto_dismiss:
+ self.qmp_log('job-dismiss', id=job)
+ elif status == 'null':
+ return error
def node_info(self, node_name):
nodes = self.qmp('query-named-block-nodes')