qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Hanna Reitz <hreitz@redhat.com>
To: qemu-block@nongnu.org
Cc: Kevin Wolf <kwolf@redhat.com>,
	Peter Maydell <peter.maydell@linaro.org>,
	Hanna Reitz <hreitz@redhat.com>,
	qemu-devel@nongnu.org
Subject: [PULL 4/4] iotests: Fix status checks
Date: Tue, 29 Mar 2022 16:58:49 +0200	[thread overview]
Message-ID: <20220329145849.121051-5-hreitz@redhat.com> (raw)
In-Reply-To: <20220329145849.121051-1-hreitz@redhat.com>

An iotest's 'paused' condition is fickle; it will be reported as true
whenever the job is drained, for example, or when it is in the process
of completing.

030 and 041 contain such checks, we should replace them by checking the
job status instead.  (As was done for 129 in commit f9a6256b48f29c2816
for the 'busy' condition.)

Additionally, when we want to test that a job is paused on error, we
might want to give it some time to actually switch to the paused state.
Do that by waiting on the corresponding JOB_STATUS_CHANGE event.  (But
only if they are not already paused; the loops these places are in fetch
all VM events, so they may have already fetched that event from the
queue.)

Signed-off-by: Hanna Reitz <hreitz@redhat.com>
Message-Id: <20220324180221.24508-1-hreitz@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
---
 tests/qemu-iotests/030 | 25 ++++++++++++++++++++-----
 tests/qemu-iotests/041 | 26 +++++++++++++++++++-------
 2 files changed, 39 insertions(+), 12 deletions(-)

diff --git a/tests/qemu-iotests/030 b/tests/qemu-iotests/030
index 14112835ed..18eddcc734 100755
--- a/tests/qemu-iotests/030
+++ b/tests/qemu-iotests/030
@@ -724,7 +724,8 @@ class TestEIO(TestErrors):
                     if result == {'return': []}:
                         # Job finished too quickly
                         continue
-                    self.assert_qmp(result, 'return[0]/paused', False)
+                    self.assertIn(result['return'][0]['status'],
+                                  ['running', 'pending', 'aborting', 'concluded'])
                 elif event['event'] == 'BLOCK_JOB_COMPLETED':
                     self.assertTrue(error, 'job completed unexpectedly')
                     self.assert_qmp(event, 'data/type', 'stream')
@@ -754,8 +755,14 @@ class TestEIO(TestErrors):
                     self.assert_qmp(event, 'data/device', 'drive0')
                     self.assert_qmp(event, 'data/operation', 'read')
 
+                    if self.vm.qmp('query-block-jobs')['return'][0]['status'] != 'paused':
+                        self.vm.events_wait([(
+                            'JOB_STATUS_CHANGE',
+                            {'data': {'id': 'drive0', 'status': 'paused'}}
+                        )])
+
                     result = self.vm.qmp('query-block-jobs')
-                    self.assert_qmp(result, 'return[0]/paused', True)
+                    self.assert_qmp(result, 'return[0]/status', 'paused')
                     self.assert_qmp(result, 'return[0]/offset', self.STREAM_BUFFER_SIZE)
                     self.assert_qmp(result, 'return[0]/io-status', 'failed')
 
@@ -766,7 +773,8 @@ class TestEIO(TestErrors):
                     if result == {'return': []}:
                         # Race; likely already finished. Check.
                         continue
-                    self.assert_qmp(result, 'return[0]/paused', False)
+                    self.assertIn(result['return'][0]['status'],
+                                  ['running', 'pending', 'aborting', 'concluded'])
                     self.assert_qmp(result, 'return[0]/io-status', 'ok')
                 elif event['event'] == 'BLOCK_JOB_COMPLETED':
                     self.assertTrue(error, 'job completed unexpectedly')
@@ -843,8 +851,14 @@ class TestENOSPC(TestErrors):
                     self.assert_qmp(event, 'data/operation', 'read')
                     error = True
 
+                    if self.vm.qmp('query-block-jobs')['return'][0]['status'] != 'paused':
+                        self.vm.events_wait([(
+                            'JOB_STATUS_CHANGE',
+                            {'data': {'id': 'drive0', 'status': 'paused'}}
+                        )])
+
                     result = self.vm.qmp('query-block-jobs')
-                    self.assert_qmp(result, 'return[0]/paused', True)
+                    self.assert_qmp(result, 'return[0]/status', 'paused')
                     self.assert_qmp(result, 'return[0]/offset', self.STREAM_BUFFER_SIZE)
                     self.assert_qmp(result, 'return[0]/io-status', 'nospace')
 
@@ -855,7 +869,8 @@ class TestENOSPC(TestErrors):
                     if result == {'return': []}:
                         # Race; likely already finished. Check.
                         continue
-                    self.assert_qmp(result, 'return[0]/paused', False)
+                    self.assertIn(result['return'][0]['status'],
+                                  ['running', 'pending', 'aborting', 'concluded'])
                     self.assert_qmp(result, 'return[0]/io-status', 'ok')
                 elif event['event'] == 'BLOCK_JOB_COMPLETED':
                     self.assertTrue(error, 'job completed unexpectedly')
diff --git a/tests/qemu-iotests/041 b/tests/qemu-iotests/041
index 3e16acee56..8429958bf0 100755
--- a/tests/qemu-iotests/041
+++ b/tests/qemu-iotests/041
@@ -529,7 +529,7 @@ new_state = "1"
         self.assert_qmp(event, 'data/device', 'drive0')
         self.assert_qmp(event, 'data/operation', 'read')
         result = self.vm.qmp('query-block-jobs')
-        self.assert_qmp(result, 'return[0]/paused', False)
+        self.assertIn(result['return'][0]['status'], ['running', 'ready'])
         self.complete_and_wait()
 
     def test_large_cluster(self):
@@ -555,7 +555,7 @@ new_state = "1"
         self.assert_qmp(event, 'data/device', 'drive0')
         self.assert_qmp(event, 'data/operation', 'read')
         result = self.vm.qmp('query-block-jobs')
-        self.assert_qmp(result, 'return[0]/paused', False)
+        self.assertIn(result['return'][0]['status'], ['running', 'ready'])
         self.complete_and_wait()
         self.vm.shutdown()
 
@@ -580,8 +580,14 @@ new_state = "1"
                     self.assert_qmp(event, 'data/device', 'drive0')
                     self.assert_qmp(event, 'data/operation', 'read')
 
+                    if self.vm.qmp('query-block-jobs')['return'][0]['status'] != 'paused':
+                        self.vm.events_wait([(
+                            'JOB_STATUS_CHANGE',
+                            {'data': {'id': 'drive0', 'status': 'paused'}}
+                        )])
+
                     result = self.vm.qmp('query-block-jobs')
-                    self.assert_qmp(result, 'return[0]/paused', True)
+                    self.assert_qmp(result, 'return[0]/status', 'paused')
                     self.assert_qmp(result, 'return[0]/io-status', 'failed')
 
                     result = self.vm.qmp('block-job-resume', device='drive0')
@@ -593,7 +599,7 @@ new_state = "1"
                     ready = True
 
         result = self.vm.qmp('query-block-jobs')
-        self.assert_qmp(result, 'return[0]/paused', False)
+        self.assert_qmp(result, 'return[0]/status', 'ready')
         self.assert_qmp(result, 'return[0]/io-status', 'ok')
 
         self.complete_and_wait(wait_ready=False)
@@ -686,7 +692,7 @@ new_state = "1"
         self.assert_qmp(event, 'data/device', 'drive0')
         self.assert_qmp(event, 'data/operation', 'write')
         result = self.vm.qmp('query-block-jobs')
-        self.assert_qmp(result, 'return[0]/paused', False)
+        self.assertIn(result['return'][0]['status'], ['running', 'ready'])
         self.complete_and_wait()
 
     def test_stop_write(self):
@@ -705,15 +711,21 @@ new_state = "1"
                     self.assert_qmp(event, 'data/device', 'drive0')
                     self.assert_qmp(event, 'data/operation', 'write')
 
+                    if self.vm.qmp('query-block-jobs')['return'][0]['status'] != 'paused':
+                        self.vm.events_wait([(
+                            'JOB_STATUS_CHANGE',
+                            {'data': {'id': 'drive0', 'status': 'paused'}}
+                        )])
+
                     result = self.vm.qmp('query-block-jobs')
-                    self.assert_qmp(result, 'return[0]/paused', True)
+                    self.assert_qmp(result, 'return[0]/status', 'paused')
                     self.assert_qmp(result, 'return[0]/io-status', 'failed')
 
                     result = self.vm.qmp('block-job-resume', device='drive0')
                     self.assert_qmp(result, 'return', {})
 
                     result = self.vm.qmp('query-block-jobs')
-                    self.assert_qmp(result, 'return[0]/paused', False)
+                    self.assertIn(result['return'][0]['status'], ['running', 'ready'])
                     self.assert_qmp(result, 'return[0]/io-status', 'ok')
                     error = True
                 elif event['event'] == 'BLOCK_JOB_READY':
-- 
2.35.1



  parent reply	other threads:[~2022-03-29 15:01 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-03-29 14:58 [PULL 0/4] Block patches for 7.0-rc2 Hanna Reitz
2022-03-29 14:58 ` [PULL 1/4] iotests: update test owner contact information Hanna Reitz
2022-03-29 14:58 ` [PULL 2/4] main-loop: Disable GLOBAL_STATE_CODE() assertions Hanna Reitz
2022-03-29 14:58 ` [PULL 3/4] block/stream: Drain subtree around graph change Hanna Reitz
2022-03-29 14:58 ` Hanna Reitz [this message]
2022-03-29 21:20 ` [PULL 0/4] Block patches for 7.0-rc2 Peter Maydell

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20220329145849.121051-5-hreitz@redhat.com \
    --to=hreitz@redhat.com \
    --cc=kwolf@redhat.com \
    --cc=peter.maydell@linaro.org \
    --cc=qemu-block@nongnu.org \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).