iotests: Add @error to wait_until_completed
Callers can use this new parameter to expect failure during the completion process. Signed-off-by: Max Reitz <mreitz@redhat.com> Reviewed-by: John Snow <jsnow@redhat.com> Reviewed-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com> Message-id: 20191108123455.39445-5-mreitz@redhat.com Signed-off-by: Max Reitz <mreitz@redhat.com>
This commit is contained in:
parent
69c6449ff1
commit
216656f5f9
|
@ -811,15 +811,20 @@ class QMPTestCase(unittest.TestCase):
|
||||||
self.assert_no_active_block_jobs()
|
self.assert_no_active_block_jobs()
|
||||||
return result
|
return result
|
||||||
|
|
||||||
def wait_until_completed(self, drive='drive0', check_offset=True, wait=60.0):
|
def wait_until_completed(self, drive='drive0', check_offset=True, wait=60.0,
|
||||||
|
error=None):
|
||||||
'''Wait for a block job to finish, returning the event'''
|
'''Wait for a block job to finish, returning the event'''
|
||||||
while True:
|
while True:
|
||||||
for event in self.vm.get_qmp_events(wait=wait):
|
for event in self.vm.get_qmp_events(wait=wait):
|
||||||
if event['event'] == 'BLOCK_JOB_COMPLETED':
|
if event['event'] == 'BLOCK_JOB_COMPLETED':
|
||||||
self.assert_qmp(event, 'data/device', drive)
|
self.assert_qmp(event, 'data/device', drive)
|
||||||
self.assert_qmp_absent(event, 'data/error')
|
if error is None:
|
||||||
if check_offset:
|
self.assert_qmp_absent(event, 'data/error')
|
||||||
self.assert_qmp(event, 'data/offset', event['data']['len'])
|
if check_offset:
|
||||||
|
self.assert_qmp(event, 'data/offset',
|
||||||
|
event['data']['len'])
|
||||||
|
else:
|
||||||
|
self.assert_qmp(event, 'data/error', error)
|
||||||
self.assert_no_active_block_jobs()
|
self.assert_no_active_block_jobs()
|
||||||
return event
|
return event
|
||||||
elif event['event'] == 'JOB_STATUS_CHANGE':
|
elif event['event'] == 'JOB_STATUS_CHANGE':
|
||||||
|
@ -837,7 +842,8 @@ class QMPTestCase(unittest.TestCase):
|
||||||
self.assert_qmp(event, 'data/type', 'mirror')
|
self.assert_qmp(event, 'data/type', 'mirror')
|
||||||
self.assert_qmp(event, 'data/offset', event['data']['len'])
|
self.assert_qmp(event, 'data/offset', event['data']['len'])
|
||||||
|
|
||||||
def complete_and_wait(self, drive='drive0', wait_ready=True):
|
def complete_and_wait(self, drive='drive0', wait_ready=True,
|
||||||
|
completion_error=None):
|
||||||
'''Complete a block job and wait for it to finish'''
|
'''Complete a block job and wait for it to finish'''
|
||||||
if wait_ready:
|
if wait_ready:
|
||||||
self.wait_ready(drive=drive)
|
self.wait_ready(drive=drive)
|
||||||
|
@ -845,7 +851,7 @@ class QMPTestCase(unittest.TestCase):
|
||||||
result = self.vm.qmp('block-job-complete', device=drive)
|
result = self.vm.qmp('block-job-complete', device=drive)
|
||||||
self.assert_qmp(result, 'return', {})
|
self.assert_qmp(result, 'return', {})
|
||||||
|
|
||||||
event = self.wait_until_completed(drive=drive)
|
event = self.wait_until_completed(drive=drive, error=completion_error)
|
||||||
self.assert_qmp(event, 'data/type', 'mirror')
|
self.assert_qmp(event, 'data/type', 'mirror')
|
||||||
|
|
||||||
def pause_wait(self, job_id='job0'):
|
def pause_wait(self, job_id='job0'):
|
||||||
|
|
Loading…
Reference in a new issue