Blame SOURCES/kvm-iotests-Fix-219-s-timing.patch

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