[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-block] [PULL 04/20] iotests.py: rewrite run_job to be pickier
From: |
Max Reitz |
Subject: |
[Qemu-block] [PULL 04/20] iotests.py: rewrite run_job to be pickier |
Date: |
Fri, 14 Jun 2019 15:40:05 +0200 |
From: John Snow <address@hidden>
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 <address@hidden>
Message-id: address@hidden
Reviewed-by: Max Reitz <address@hidden>
Signed-off-by: Max Reitz <address@hidden>
---
tests/qemu-iotests/iotests.py | 48 +++++++++++++++++++++--------------
1 file changed, 29 insertions(+), 19 deletions(-)
diff --git a/tests/qemu-iotests/iotests.py b/tests/qemu-iotests/iotests.py
index 6a3703e6ee..3ecef5bc90 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')
--
2.21.0
- [Qemu-block] [PULL 00/20] Block patches, Max Reitz, 2019/06/14
- [Qemu-block] [PULL 01/20] blockdev-backup: don't check aio_context too early, Max Reitz, 2019/06/14
- [Qemu-block] [PULL 04/20] iotests.py: rewrite run_job to be pickier,
Max Reitz <=
- [Qemu-block] [PULL 02/20] iotests.py: do not use infinite waits, Max Reitz, 2019/06/14
- [Qemu-block] [PULL 06/20] event_match: always match on None value, Max Reitz, 2019/06/14
- [Qemu-block] [PULL 08/20] iotests: Fix intermittent failure in 219, Max Reitz, 2019/06/14
- [Qemu-block] [PULL 07/20] iotests: Filter 175's allocation information, Max Reitz, 2019/06/14
- [Qemu-block] [PULL 03/20] QEMUMachine: add events_wait method, Max Reitz, 2019/06/14
- [Qemu-block] [PULL 05/20] iotests: add iotest 256 for testing blockdev-backup across iothread contexts, Max Reitz, 2019/06/14
- [Qemu-block] [PULL 09/20] hw/block/fdc: floppy command FIFO memory initialization, Max Reitz, 2019/06/14
- [Qemu-block] [PULL 10/20] iotests: restrict 254 to support only qcow2, Max Reitz, 2019/06/14
- [Qemu-block] [PULL 12/20] qapi/block-core: Overlays are not snapshots, Max Reitz, 2019/06/14
- [Qemu-block] [PULL 11/20] qemu-img: Fix options leakage in img_rebase(), Max Reitz, 2019/06/14