iotests: add pause_wait

Split out the pause command into the actual pause and the wait.
Not every usage presently needs to resubmit a pause request.

The intent with the next commit will be to explicitly disallow
redundant or meaningless pause/resume requests, so the tests
need to become more judicious to reflect that.

Signed-off-by: John Snow <jsnow@redhat.com>
Reviewed-by: Kevin Wolf <kwolf@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
This commit is contained in:
John Snow 2018-03-10 03:27:31 -05:00 committed by Kevin Wolf
parent c9de40505f
commit f03d9d243f
3 changed files with 16 additions and 19 deletions

View File

@ -86,11 +86,9 @@ class TestSingleDrive(iotests.QMPTestCase):
result = self.vm.qmp('block-stream', device='drive0')
self.assert_qmp(result, 'return', {})
result = self.vm.qmp('block-job-pause', device='drive0')
self.assert_qmp(result, 'return', {})
self.pause_job('drive0', wait=False)
self.vm.resume_drive('drive0')
self.pause_job('drive0')
self.pause_wait('drive0')
result = self.vm.qmp('query-block-jobs')
offset = self.dictpath(result, 'return[0]/offset')

View File

@ -86,11 +86,9 @@ class TestSingleDrive(iotests.QMPTestCase):
target=target, sync='full')
self.assert_qmp(result, 'return', {})
result = self.vm.qmp('block-job-pause', device='drive0')
self.assert_qmp(result, 'return', {})
self.pause_job('drive0', wait=False)
self.vm.resume_drive('drive0')
self.pause_job('drive0')
self.pause_wait('drive0')
result = self.vm.qmp('query-block-jobs')
offset = self.dictpath(result, 'return[0]/offset')
@ -303,13 +301,12 @@ class TestSingleTransaction(iotests.QMPTestCase):
])
self.assert_qmp(result, 'return', {})
result = self.vm.qmp('block-job-pause', device='drive0')
self.assert_qmp(result, 'return', {})
self.pause_job('drive0', wait=False)
result = self.vm.qmp('block-job-set-speed', device='drive0', speed=0)
self.assert_qmp(result, 'return', {})
self.pause_job('drive0')
self.pause_wait('drive0')
result = self.vm.qmp('query-block-jobs')
offset = self.dictpath(result, 'return[0]/offset')
@ -534,11 +531,9 @@ class TestDriveCompression(iotests.QMPTestCase):
result = self.vm.qmp(cmd, device='drive0', sync='full', compress=True, **args)
self.assert_qmp(result, 'return', {})
result = self.vm.qmp('block-job-pause', device='drive0')
self.assert_qmp(result, 'return', {})
self.pause_job('drive0', wait=False)
self.vm.resume_drive('drive0')
self.pause_job('drive0')
self.pause_wait('drive0')
result = self.vm.qmp('query-block-jobs')
offset = self.dictpath(result, 'return[0]/offset')

View File

@ -506,10 +506,7 @@ class QMPTestCase(unittest.TestCase):
event = self.wait_until_completed(drive=drive)
self.assert_qmp(event, 'data/type', 'mirror')
def pause_job(self, job_id='job0'):
result = self.vm.qmp('block-job-pause', device=job_id)
self.assert_qmp(result, 'return', {})
def pause_wait(self, job_id='job0'):
with Timeout(1, "Timeout waiting for job to pause"):
while True:
result = self.vm.qmp('query-block-jobs')
@ -517,6 +514,13 @@ class QMPTestCase(unittest.TestCase):
if job['device'] == job_id and job['paused'] == True and job['busy'] == False:
return job
def pause_job(self, job_id='job0', wait=True):
result = self.vm.qmp('block-job-pause', device=job_id)
self.assert_qmp(result, 'return', {})
if wait:
return self.pause_wait(job_id)
return result
def notrun(reason):
'''Skip this test suite'''