yeahuh / rpms / qemu-kvm

Forked from rpms/qemu-kvm 2 years ago
Clone
26ba25
From 6839f724393417ae25f3b5ab8bd85bf067925cc2 Mon Sep 17 00:00:00 2001
26ba25
From: Kevin Wolf <kwolf@redhat.com>
26ba25
Date: Tue, 26 Jun 2018 09:48:55 +0200
26ba25
Subject: [PATCH 147/268] iotests: Fix 219's timing
26ba25
26ba25
RH-Author: Kevin Wolf <kwolf@redhat.com>
26ba25
Message-id: <20180626094856.6924-73-kwolf@redhat.com>
26ba25
Patchwork-id: 81111
26ba25
O-Subject: [RHV-7.6 qemu-kvm-rhev PATCH v2 72/73] iotests: Fix 219's timing
26ba25
Bugzilla: 1513543
26ba25
RH-Acked-by: Jeffrey Cody <jcody@redhat.com>
26ba25
RH-Acked-by: Max Reitz <mreitz@redhat.com>
26ba25
RH-Acked-by: Fam Zheng <famz@redhat.com>
26ba25
26ba25
From: Max Reitz <mreitz@redhat.com>
26ba25
26ba25
219 has two issues that may lead to sporadic failure, both of which are
26ba25
the result of issuing query-jobs too early after a job has been
26ba25
modified.  This can then lead to different results based on whether the
26ba25
modification has taken effect already or not.
26ba25
26ba25
First, query-jobs is issued right after the job has been created.
26ba25
Besides its current progress possibly being in any random state (which
26ba25
has already been taken care of), its total progress too is basically
26ba25
arbitrary, because the job may not yet have been able to determine it.
26ba25
This patch addresses this by just filtering the total progress, like
26ba25
what has been done for the current progress already.  However, for more
26ba25
clarity, the filtering is changed to replace the values by a string
26ba25
'FILTERED' instead of deleting them.
26ba25
26ba25
Secondly, query-jobs is issued right after a job has been resumed.  The
26ba25
job may or may not yet have had the time to actually perform any I/O,
26ba25
and thus its current progress may or may not have advanced.  To make
26ba25
sure it has indeed advanced (which is what the reference output already
26ba25
assumes), keep querying it until it has.
26ba25
26ba25
Signed-off-by: Max Reitz <mreitz@redhat.com>
26ba25
Message-id: 20180606190628.8170-1-mreitz@redhat.com
26ba25
Reviewed-by: Eric Blake <eblake@redhat.com>
26ba25
Signed-off-by: Max Reitz <mreitz@redhat.com>
26ba25
(cherry picked from commit 83f90b535a0d5e64056c087aa4022ea35c59bcd0)
26ba25
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
26ba25
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
26ba25
---
26ba25
 tests/qemu-iotests/219     | 26 ++++++++++++++++++++------
26ba25
 tests/qemu-iotests/219.out | 10 +++++-----
26ba25
 2 files changed, 25 insertions(+), 11 deletions(-)
26ba25
26ba25
diff --git a/tests/qemu-iotests/219 b/tests/qemu-iotests/219
26ba25
index 898a26e..c03bbdb 100755
26ba25
--- a/tests/qemu-iotests/219
26ba25
+++ b/tests/qemu-iotests/219
26ba25
@@ -42,11 +42,24 @@ def test_pause_resume(vm):
26ba25
             iotests.log(vm.qmp(pause_cmd, **{pause_arg: 'job0'}))
26ba25
             pause_wait(vm, 'job0')
26ba25
             iotests.log(iotests.filter_qmp_event(vm.event_wait('JOB_STATUS_CHANGE')))
26ba25
-            iotests.log(vm.qmp('query-jobs'))
26ba25
+            result = vm.qmp('query-jobs')
26ba25
+            iotests.log(result)
26ba25
+
26ba25
+            old_progress = result['return'][0]['current-progress']
26ba25
+            total_progress = result['return'][0]['total-progress']
26ba25
 
26ba25
             iotests.log(vm.qmp(resume_cmd, **{resume_arg: 'job0'}))
26ba25
             iotests.log(iotests.filter_qmp_event(vm.event_wait('JOB_STATUS_CHANGE')))
26ba25
-            iotests.log(vm.qmp('query-jobs'))
26ba25
+            if old_progress < total_progress:
26ba25
+                # Wait for the job to advance
26ba25
+                while result['return'][0]['current-progress'] == old_progress:
26ba25
+                    result = vm.qmp('query-jobs')
26ba25
+                iotests.log(result)
26ba25
+            else:
26ba25
+                # Already reached the end, so the job cannot advance
26ba25
+                # any further; therefore, the query-jobs result can be
26ba25
+                # logged immediately
26ba25
+                iotests.log(vm.qmp('query-jobs'))
26ba25
 
26ba25
 def test_job_lifecycle(vm, job, job_args, has_ready=False):
26ba25
     iotests.log('')
26ba25
@@ -58,12 +71,13 @@ def test_job_lifecycle(vm, job, job_args, has_ready=False):
26ba25
     iotests.log(vm.qmp(job, job_id='job0', **job_args))
26ba25
 
26ba25
     # Depending on the storage, the first request may or may not have completed
26ba25
-    # yet, so filter out the progress. Later query-job calls don't need the
26ba25
-    # filtering because the progress is made deterministic by the block job
26ba25
-    # speed
26ba25
+    # yet (and the total progress may not have been fully determined yet), so
26ba25
+    # filter out the progress. Later query-job calls don't need the filtering
26ba25
+    # because the progress is made deterministic by the block job speed
26ba25
     result = vm.qmp('query-jobs')
26ba25
     for j in result['return']:
26ba25
-        del j['current-progress']
26ba25
+        j['current-progress'] = 'FILTERED'
26ba25
+        j['total-progress'] = 'FILTERED'
26ba25
     iotests.log(result)
26ba25
 
26ba25
     # undefined -> created -> running
26ba25
diff --git a/tests/qemu-iotests/219.out b/tests/qemu-iotests/219.out
26ba25
index 346801b..6dc07bc 100644
26ba25
--- a/tests/qemu-iotests/219.out
26ba25
+++ b/tests/qemu-iotests/219.out
26ba25
@@ -3,7 +3,7 @@ Launching VM...
26ba25
 
26ba25
 Starting block job: drive-mirror (auto-finalize: True; auto-dismiss: True)
26ba25
 {u'return': {}}
26ba25
-{u'return': [{u'status': u'running', u'total-progress': 4194304, u'id': u'job0', u'type': u'mirror'}]}
26ba25
+{u'return': [{u'status': u'running', u'current-progress': 'FILTERED', u'total-progress': 'FILTERED', u'id': u'job0', u'type': u'mirror'}]}
26ba25
 {u'timestamp': {u'seconds': 'SECS', u'microseconds': 'USECS'}, u'data': {u'status': u'created', u'id': u'job0'}, u'event': u'JOB_STATUS_CHANGE'}
26ba25
 {u'timestamp': {u'seconds': 'SECS', u'microseconds': 'USECS'}, u'data': {u'status': u'running', u'id': u'job0'}, u'event': u'JOB_STATUS_CHANGE'}
26ba25
 
26ba25
@@ -93,7 +93,7 @@ Waiting for PENDING state...
26ba25
 
26ba25
 Starting block job: drive-backup (auto-finalize: True; auto-dismiss: True)
26ba25
 {u'return': {}}
26ba25
-{u'return': [{u'status': u'running', u'total-progress': 4194304, u'id': u'job0', u'type': u'backup'}]}
26ba25
+{u'return': [{u'status': u'running', u'current-progress': 'FILTERED', u'total-progress': 'FILTERED', u'id': u'job0', u'type': u'backup'}]}
26ba25
 {u'timestamp': {u'seconds': 'SECS', u'microseconds': 'USECS'}, u'data': {u'status': u'created', u'id': u'job0'}, u'event': u'JOB_STATUS_CHANGE'}
26ba25
 {u'timestamp': {u'seconds': 'SECS', u'microseconds': 'USECS'}, u'data': {u'status': u'running', u'id': u'job0'}, u'event': u'JOB_STATUS_CHANGE'}
26ba25
 
26ba25
@@ -144,7 +144,7 @@ Waiting for PENDING state...
26ba25
 
26ba25
 Starting block job: drive-backup (auto-finalize: True; auto-dismiss: False)
26ba25
 {u'return': {}}
26ba25
-{u'return': [{u'status': u'running', u'total-progress': 4194304, u'id': u'job0', u'type': u'backup'}]}
26ba25
+{u'return': [{u'status': u'running', u'current-progress': 'FILTERED', u'total-progress': 'FILTERED', u'id': u'job0', u'type': u'backup'}]}
26ba25
 {u'timestamp': {u'seconds': 'SECS', u'microseconds': 'USECS'}, u'data': {u'status': u'created', u'id': u'job0'}, u'event': u'JOB_STATUS_CHANGE'}
26ba25
 {u'timestamp': {u'seconds': 'SECS', u'microseconds': 'USECS'}, u'data': {u'status': u'running', u'id': u'job0'}, u'event': u'JOB_STATUS_CHANGE'}
26ba25
 
26ba25
@@ -203,7 +203,7 @@ Waiting for PENDING state...
26ba25
 
26ba25
 Starting block job: drive-backup (auto-finalize: False; auto-dismiss: True)
26ba25
 {u'return': {}}
26ba25
-{u'return': [{u'status': u'running', u'total-progress': 4194304, u'id': u'job0', u'type': u'backup'}]}
26ba25
+{u'return': [{u'status': u'running', u'current-progress': 'FILTERED', u'total-progress': 'FILTERED', u'id': u'job0', u'type': u'backup'}]}
26ba25
 {u'timestamp': {u'seconds': 'SECS', u'microseconds': 'USECS'}, u'data': {u'status': u'created', u'id': u'job0'}, u'event': u'JOB_STATUS_CHANGE'}
26ba25
 {u'timestamp': {u'seconds': 'SECS', u'microseconds': 'USECS'}, u'data': {u'status': u'running', u'id': u'job0'}, u'event': u'JOB_STATUS_CHANGE'}
26ba25
 
26ba25
@@ -262,7 +262,7 @@ Waiting for PENDING state...
26ba25
 
26ba25
 Starting block job: drive-backup (auto-finalize: False; auto-dismiss: False)
26ba25
 {u'return': {}}
26ba25
-{u'return': [{u'status': u'running', u'total-progress': 4194304, u'id': u'job0', u'type': u'backup'}]}
26ba25
+{u'return': [{u'status': u'running', u'current-progress': 'FILTERED', u'total-progress': 'FILTERED', u'id': u'job0', u'type': u'backup'}]}
26ba25
 {u'timestamp': {u'seconds': 'SECS', u'microseconds': 'USECS'}, u'data': {u'status': u'created', u'id': u'job0'}, u'event': u'JOB_STATUS_CHANGE'}
26ba25
 {u'timestamp': {u'seconds': 'SECS', u'microseconds': 'USECS'}, u'data': {u'status': u'running', u'id': u'job0'}, u'event': u'JOB_STATUS_CHANGE'}
26ba25
 
26ba25
-- 
26ba25
1.8.3.1
26ba25