ae23c9
From ee9edb4c02451eec077a7a6afc5ddb1b343e8ef6 Mon Sep 17 00:00:00 2001
ae23c9
From: Kevin Wolf <kwolf@redhat.com>
ae23c9
Date: Tue, 26 Jun 2018 09:48:56 +0200
ae23c9
Subject: [PATCH 148/268] iotests: improve pause_job
ae23c9
ae23c9
RH-Author: Kevin Wolf <kwolf@redhat.com>
ae23c9
Message-id: <20180626094856.6924-74-kwolf@redhat.com>
ae23c9
Patchwork-id: 81118
ae23c9
O-Subject: [RHV-7.6 qemu-kvm-rhev PATCH v2 73/73] iotests: improve pause_job
ae23c9
Bugzilla: 1513543
ae23c9
RH-Acked-by: Jeffrey Cody <jcody@redhat.com>
ae23c9
RH-Acked-by: Max Reitz <mreitz@redhat.com>
ae23c9
RH-Acked-by: Fam Zheng <famz@redhat.com>
ae23c9
ae23c9
From: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
ae23c9
ae23c9
It's possible, that job was finished during waiting. In this case we
ae23c9
will see error message "Timeout waiting for job to pause" which is not
ae23c9
very informative. So, let's check during waiting iteration that the job
ae23c9
exists.
ae23c9
ae23c9
Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
ae23c9
Message-id: 20180601115923.17159-1-vsementsov@virtuozzo.com
ae23c9
Signed-off-by: Max Reitz <mreitz@redhat.com>
ae23c9
(cherry picked from commit c1bac161bb7ad27243776e90971c51cc38c2e1b6)
ae23c9
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
ae23c9
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
ae23c9
---
ae23c9
 tests/qemu-iotests/iotests.py | 9 +++++++--
ae23c9
 1 file changed, 7 insertions(+), 2 deletions(-)
ae23c9
ae23c9
diff --git a/tests/qemu-iotests/iotests.py b/tests/qemu-iotests/iotests.py
ae23c9
index 0dbfbfd..4e67fbb 100644
ae23c9
--- a/tests/qemu-iotests/iotests.py
ae23c9
+++ b/tests/qemu-iotests/iotests.py
ae23c9
@@ -591,9 +591,14 @@ class QMPTestCase(unittest.TestCase):
ae23c9
         with Timeout(1, "Timeout waiting for job to pause"):
ae23c9
             while True:
ae23c9
                 result = self.vm.qmp('query-block-jobs')
ae23c9
+                found = False
ae23c9
                 for job in result['return']:
ae23c9
-                    if job['device'] == job_id and job['paused'] == True and job['busy'] == False:
ae23c9
-                        return job
ae23c9
+                    if job['device'] == job_id:
ae23c9
+                        found = True
ae23c9
+                        if job['paused'] == True and job['busy'] == False:
ae23c9
+                            return job
ae23c9
+                        break
ae23c9
+                assert found
ae23c9
 
ae23c9
     def pause_job(self, job_id='job0', wait=True):
ae23c9
         result = self.vm.qmp('block-job-pause', device=job_id)
ae23c9
-- 
ae23c9
1.8.3.1
ae23c9