Skip to contentSkip to conversation

iotests: improve pause_job

PATCH Applied Vladimir Sementsov-Ogievskiy 2 participants 2 messages Jun 1, 2018

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 iotests: improve pause_job

It's possible, that job was finished during waiting. In this case we will see error message "Timeout waiting for job to pause" which is not very informative. So, let's check during waiting iteration that the job exists.

---
 tests/qemu-iotests/iotests.py | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)
tests/qemu-iotests/iotests.py +7 -2
index 28159d837a..fa16f7b4f0 100644
@@ -513,9 +513,14 @@ class QMPTestCase(unittest.TestCase):
         with Timeout(1, "Timeout waiting for job to pause"):
             while True:
                 result = self.vm.qmp('query-block-jobs')
+                found = False
                 for job in result['return']:
-                    if job['device'] == job_id and job['paused'] == True and job['busy'] == False:
-                        return job
+                    if job['device'] == job_id:
+                        found = True
+                        if job['paused'] == True and job['busy'] == False:
+                            return job
+                        break
+                assert found
 
     def pause_job(self, job_id='job0', wait=True):
         result = self.vm.qmp('block-job-pause', device=job_id)
Signature · 1 line
2.11.1
Applied
#1 lore raw
Quoted 9 lines · Vladimir Sementsov-Ogievskiy

It's possible, that job was finished during waiting. In this case we will see error message "Timeout waiting for job to pause" which is not very informative. So, let's check during waiting iteration that the job exists.

---
 tests/qemu-iotests/iotests.py | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

Thanks, applied to my block branch:

https://github.com/XanClic/qemu/commits/block

Max