From nobody Sun May 5 21:40:18 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (208.118.235.17 [208.118.235.17]) by mx.zohomail.com with SMTPS id 1528311952009500.8118609147725; Wed, 6 Jun 2018 12:05:52 -0700 (PDT) Received: from localhost ([::1]:54101 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fQdkd-0004D3-5M for importer@patchew.org; Wed, 06 Jun 2018 15:05:43 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:36937) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fQdjF-0003TV-Uz for qemu-devel@nongnu.org; Wed, 06 Jun 2018 15:04:19 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fQdjD-0006Y5-VY for qemu-devel@nongnu.org; Wed, 06 Jun 2018 15:04:17 -0400 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:40800 helo=mx1.redhat.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1fQdj7-0006Va-O4; Wed, 06 Jun 2018 15:04:09 -0400 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 02A3F401EF07; Wed, 6 Jun 2018 19:04:09 +0000 (UTC) Received: from localhost (unknown [10.40.205.120]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 991B91134CA4; Wed, 6 Jun 2018 19:04:08 +0000 (UTC) From: Max Reitz To: qemu-block@nongnu.org Date: Wed, 6 Jun 2018 21:04:07 +0200 Message-Id: <20180606190407.6005-1-mreitz@redhat.com> X-Scanned-By: MIMEDefang 2.78 on 10.11.54.3 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.5]); Wed, 06 Jun 2018 19:04:09 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.5]); Wed, 06 Jun 2018 19:04:09 +0000 (UTC) for IP:'10.11.54.3' DOMAIN:'int-mx03.intmail.prod.int.rdu2.redhat.com' HELO:'smtp.corp.redhat.com' FROM:'mreitz@redhat.com' RCPT:'' X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 66.187.233.73 Subject: [Qemu-devel] [PATCH v3] iotests: Fix 219's timing X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Kevin Wolf , qemu-devel@nongnu.org, Max Reitz Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" 219 has two issues that may lead to sporadic failure, both of which are the result of issuing query-jobs too early after a job has been modified. This can then lead to different results based on whether the modification has taken effect already or not. First, query-jobs is issued right after the job has been created. Besides its current progress possibly being in any random state (which has already been taken care of), its total progress too is basically arbitrary, because the job may not yet have been able to determine it. This patch addresses this by just filtering the total progress, like what has been done for the current progress already. However, for more clarity, the filtering is changed to replace the values by a string 'FILTERED' instead of deleting them. Secondly, query-jobs is issued right after a job has been resumed. The job may or may not yet have had the time to actually perform any I/O, and thus its current progress may or may not have advanced. To make sure it has indeed advanced (which is what the reference output already assumes), keep querying it until it has. Signed-off-by: Max Reitz --- v3: Keep querying until the job has advanced instead of waiting for a fixed amount of time [Peter in v2, Eric in v1] --- tests/qemu-iotests/219 | 27 +++++++++++++++++++++------ tests/qemu-iotests/219.out | 10 +++++----- 2 files changed, 26 insertions(+), 11 deletions(-) diff --git a/tests/qemu-iotests/219 b/tests/qemu-iotests/219 index 898a26eef0..1a0329c6a0 100755 --- a/tests/qemu-iotests/219 +++ b/tests/qemu-iotests/219 @@ -20,6 +20,7 @@ # Check using the job-* QMP commands with block jobs =20 import iotests +import time =20 iotests.verify_image_format(supported_fmts=3D['qcow2']) =20 @@ -42,11 +43,24 @@ def test_pause_resume(vm): iotests.log(vm.qmp(pause_cmd, **{pause_arg: 'job0'})) pause_wait(vm, 'job0') iotests.log(iotests.filter_qmp_event(vm.event_wait('JOB_STATUS= _CHANGE'))) - iotests.log(vm.qmp('query-jobs')) + result =3D vm.qmp('query-jobs') + iotests.log(result) + + old_progress =3D result['return'][0]['current-progress'] + total_progress =3D result['return'][0]['total-progress'] =20 iotests.log(vm.qmp(resume_cmd, **{resume_arg: 'job0'})) iotests.log(iotests.filter_qmp_event(vm.event_wait('JOB_STATUS= _CHANGE'))) - iotests.log(vm.qmp('query-jobs')) + if old_progress < total_progress: + # Wait for the job to advance + while result['return'][0]['current-progress'] =3D=3D old_p= rogress: + result =3D vm.qmp('query-jobs') + iotests.log(result) + else: + # Already reached the end, so the job cannot advance + # any further; therefore, the query-jobs result can be + # logged immediately + iotests.log(vm.qmp('query-jobs')) =20 def test_job_lifecycle(vm, job, job_args, has_ready=3DFalse): iotests.log('') @@ -58,12 +72,13 @@ def test_job_lifecycle(vm, job, job_args, has_ready=3DF= alse): iotests.log(vm.qmp(job, job_id=3D'job0', **job_args)) =20 # Depending on the storage, the first request may or may not have comp= leted - # yet, so filter out the progress. Later query-job calls don't need the - # filtering because the progress is made deterministic by the block job - # speed + # yet (and the total progress may not have been fully determined yet),= so + # filter out the progress. Later query-job calls don't need the filter= ing + # because the progress is made deterministic by the block job speed result =3D vm.qmp('query-jobs') for j in result['return']: - del j['current-progress'] + j['current-progress'] =3D 'FILTERED' + j['total-progress'] =3D 'FILTERED' iotests.log(result) =20 # undefined -> created -> running diff --git a/tests/qemu-iotests/219.out b/tests/qemu-iotests/219.out index 346801b655..6dc07bc41e 100644 --- a/tests/qemu-iotests/219.out +++ b/tests/qemu-iotests/219.out @@ -3,7 +3,7 @@ Launching VM... =20 Starting block job: drive-mirror (auto-finalize: True; auto-dismiss: True) {u'return': {}} -{u'return': [{u'status': u'running', u'total-progress': 4194304, u'id': u'= job0', u'type': u'mirror'}]} +{u'return': [{u'status': u'running', u'current-progress': 'FILTERED', u'to= tal-progress': 'FILTERED', u'id': u'job0', u'type': u'mirror'}]} {u'timestamp': {u'seconds': 'SECS', u'microseconds': 'USECS'}, u'data': {u= 'status': u'created', u'id': u'job0'}, u'event': u'JOB_STATUS_CHANGE'} {u'timestamp': {u'seconds': 'SECS', u'microseconds': 'USECS'}, u'data': {u= 'status': u'running', u'id': u'job0'}, u'event': u'JOB_STATUS_CHANGE'} =20 @@ -93,7 +93,7 @@ Waiting for PENDING state... =20 Starting block job: drive-backup (auto-finalize: True; auto-dismiss: True) {u'return': {}} -{u'return': [{u'status': u'running', u'total-progress': 4194304, u'id': u'= job0', u'type': u'backup'}]} +{u'return': [{u'status': u'running', u'current-progress': 'FILTERED', u'to= tal-progress': 'FILTERED', u'id': u'job0', u'type': u'backup'}]} {u'timestamp': {u'seconds': 'SECS', u'microseconds': 'USECS'}, u'data': {u= 'status': u'created', u'id': u'job0'}, u'event': u'JOB_STATUS_CHANGE'} {u'timestamp': {u'seconds': 'SECS', u'microseconds': 'USECS'}, u'data': {u= 'status': u'running', u'id': u'job0'}, u'event': u'JOB_STATUS_CHANGE'} =20 @@ -144,7 +144,7 @@ Waiting for PENDING state... =20 Starting block job: drive-backup (auto-finalize: True; auto-dismiss: False) {u'return': {}} -{u'return': [{u'status': u'running', u'total-progress': 4194304, u'id': u'= job0', u'type': u'backup'}]} +{u'return': [{u'status': u'running', u'current-progress': 'FILTERED', u'to= tal-progress': 'FILTERED', u'id': u'job0', u'type': u'backup'}]} {u'timestamp': {u'seconds': 'SECS', u'microseconds': 'USECS'}, u'data': {u= 'status': u'created', u'id': u'job0'}, u'event': u'JOB_STATUS_CHANGE'} {u'timestamp': {u'seconds': 'SECS', u'microseconds': 'USECS'}, u'data': {u= 'status': u'running', u'id': u'job0'}, u'event': u'JOB_STATUS_CHANGE'} =20 @@ -203,7 +203,7 @@ Waiting for PENDING state... =20 Starting block job: drive-backup (auto-finalize: False; auto-dismiss: True) {u'return': {}} -{u'return': [{u'status': u'running', u'total-progress': 4194304, u'id': u'= job0', u'type': u'backup'}]} +{u'return': [{u'status': u'running', u'current-progress': 'FILTERED', u'to= tal-progress': 'FILTERED', u'id': u'job0', u'type': u'backup'}]} {u'timestamp': {u'seconds': 'SECS', u'microseconds': 'USECS'}, u'data': {u= 'status': u'created', u'id': u'job0'}, u'event': u'JOB_STATUS_CHANGE'} {u'timestamp': {u'seconds': 'SECS', u'microseconds': 'USECS'}, u'data': {u= 'status': u'running', u'id': u'job0'}, u'event': u'JOB_STATUS_CHANGE'} =20 @@ -262,7 +262,7 @@ Waiting for PENDING state... =20 Starting block job: drive-backup (auto-finalize: False; auto-dismiss: Fals= e) {u'return': {}} -{u'return': [{u'status': u'running', u'total-progress': 4194304, u'id': u'= job0', u'type': u'backup'}]} +{u'return': [{u'status': u'running', u'current-progress': 'FILTERED', u'to= tal-progress': 'FILTERED', u'id': u'job0', u'type': u'backup'}]} {u'timestamp': {u'seconds': 'SECS', u'microseconds': 'USECS'}, u'data': {u= 'status': u'created', u'id': u'job0'}, u'event': u'JOB_STATUS_CHANGE'} {u'timestamp': {u'seconds': 'SECS', u'microseconds': 'USECS'}, u'data': {u= 'status': u'running', u'id': u'job0'}, u'event': u'JOB_STATUS_CHANGE'} =20 --=20 2.17.0