|
|
ae23c9 |
From 21085d2fd5cc4b08016ac4d16bb90c77bf9551e7 Mon Sep 17 00:00:00 2001
|
|
|
ae23c9 |
From: Max Reitz <mreitz@redhat.com>
|
|
|
ae23c9 |
Date: Mon, 18 Jun 2018 14:47:36 +0200
|
|
|
ae23c9 |
Subject: [PATCH 035/268] iotests: Add test for cancelling a mirror job
|
|
|
ae23c9 |
|
|
|
ae23c9 |
RH-Author: Max Reitz <mreitz@redhat.com>
|
|
|
ae23c9 |
Message-id: <20180618144736.29873-4-mreitz@redhat.com>
|
|
|
ae23c9 |
Patchwork-id: 80745
|
|
|
ae23c9 |
O-Subject: [RHV-7.6 qemu-kvm-rhev PATCH 3/3] iotests: Add test for cancelling a mirror job
|
|
|
ae23c9 |
Bugzilla: 1572856
|
|
|
ae23c9 |
RH-Acked-by: Jeffrey Cody <jcody@redhat.com>
|
|
|
ae23c9 |
RH-Acked-by: Kevin Wolf <kwolf@redhat.com>
|
|
|
ae23c9 |
RH-Acked-by: John Snow <jsnow@redhat.com>
|
|
|
ae23c9 |
|
|
|
ae23c9 |
We already have an extensive mirror test (041) which does cover
|
|
|
ae23c9 |
cancelling a mirror job, especially after it has emitted the READY
|
|
|
ae23c9 |
event. However, it does not check what exact events are emitted after
|
|
|
ae23c9 |
block-job-cancel is executed. More importantly, it does not use
|
|
|
ae23c9 |
throttling to ensure that it covers the case of block-job-cancel before
|
|
|
ae23c9 |
READY.
|
|
|
ae23c9 |
|
|
|
ae23c9 |
It would be possible to add this case to 041, but considering it is
|
|
|
ae23c9 |
already our largest test file, it makes sense to create a new file for
|
|
|
ae23c9 |
these cases.
|
|
|
ae23c9 |
|
|
|
ae23c9 |
Signed-off-by: Max Reitz <mreitz@redhat.com>
|
|
|
ae23c9 |
Message-id: 20180501220509.14152-3-mreitz@redhat.com
|
|
|
ae23c9 |
Signed-off-by: Jeff Cody <jcody@redhat.com>
|
|
|
ae23c9 |
(cherry picked from commit dc885fff972c447f51572afc4c921a26b880731b)
|
|
|
ae23c9 |
Signed-off-by: Max Reitz <mreitz@redhat.com>
|
|
|
ae23c9 |
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
|
|
|
ae23c9 |
---
|
|
|
ae23c9 |
tests/qemu-iotests/218 | 138 +++++++++++++++++++++++++++++++++++++++++++++
|
|
|
ae23c9 |
tests/qemu-iotests/218.out | 30 ++++++++++
|
|
|
ae23c9 |
tests/qemu-iotests/group | 1 +
|
|
|
ae23c9 |
3 files changed, 169 insertions(+)
|
|
|
ae23c9 |
create mode 100644 tests/qemu-iotests/218
|
|
|
ae23c9 |
create mode 100644 tests/qemu-iotests/218.out
|
|
|
ae23c9 |
|
|
|
ae23c9 |
diff --git a/tests/qemu-iotests/218 b/tests/qemu-iotests/218
|
|
|
ae23c9 |
new file mode 100644
|
|
|
ae23c9 |
index 0000000..92c331b
|
|
|
ae23c9 |
--- /dev/null
|
|
|
ae23c9 |
+++ b/tests/qemu-iotests/218
|
|
|
ae23c9 |
@@ -0,0 +1,138 @@
|
|
|
ae23c9 |
+#!/usr/bin/env python
|
|
|
ae23c9 |
+#
|
|
|
ae23c9 |
+# This test covers what happens when a mirror block job is cancelled
|
|
|
ae23c9 |
+# in various phases of its existence.
|
|
|
ae23c9 |
+#
|
|
|
ae23c9 |
+# Note that this test only checks the emitted events (i.e.
|
|
|
ae23c9 |
+# BLOCK_JOB_COMPLETED vs. BLOCK_JOB_CANCELLED), it does not compare
|
|
|
ae23c9 |
+# whether the target is in sync with the source when the
|
|
|
ae23c9 |
+# BLOCK_JOB_COMPLETED event occurs. This is covered by other tests
|
|
|
ae23c9 |
+# (such as 041).
|
|
|
ae23c9 |
+#
|
|
|
ae23c9 |
+# Copyright (C) 2018 Red Hat, Inc.
|
|
|
ae23c9 |
+#
|
|
|
ae23c9 |
+# This program is free software; you can redistribute it and/or modify
|
|
|
ae23c9 |
+# it under the terms of the GNU General Public License as published by
|
|
|
ae23c9 |
+# the Free Software Foundation; either version 2 of the License, or
|
|
|
ae23c9 |
+# (at your option) any later version.
|
|
|
ae23c9 |
+#
|
|
|
ae23c9 |
+# This program is distributed in the hope that it will be useful,
|
|
|
ae23c9 |
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
ae23c9 |
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
ae23c9 |
+# GNU General Public License for more details.
|
|
|
ae23c9 |
+#
|
|
|
ae23c9 |
+# You should have received a copy of the GNU General Public License
|
|
|
ae23c9 |
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
ae23c9 |
+#
|
|
|
ae23c9 |
+# Creator/Owner: Max Reitz <mreitz@redhat.com>
|
|
|
ae23c9 |
+
|
|
|
ae23c9 |
+import iotests
|
|
|
ae23c9 |
+from iotests import log
|
|
|
ae23c9 |
+
|
|
|
ae23c9 |
+iotests.verify_platform(['linux'])
|
|
|
ae23c9 |
+
|
|
|
ae23c9 |
+
|
|
|
ae23c9 |
+# Launches the VM, adds two null-co nodes (source and target), and
|
|
|
ae23c9 |
+# starts a blockdev-mirror job on them.
|
|
|
ae23c9 |
+#
|
|
|
ae23c9 |
+# Either both or none of speed and buf_size must be given.
|
|
|
ae23c9 |
+
|
|
|
ae23c9 |
+def start_mirror(vm, speed=None, buf_size=None):
|
|
|
ae23c9 |
+ vm.launch()
|
|
|
ae23c9 |
+
|
|
|
ae23c9 |
+ ret = vm.qmp('blockdev-add',
|
|
|
ae23c9 |
+ node_name='source',
|
|
|
ae23c9 |
+ driver='null-co',
|
|
|
ae23c9 |
+ size=1048576)
|
|
|
ae23c9 |
+ assert ret['return'] == {}
|
|
|
ae23c9 |
+
|
|
|
ae23c9 |
+ ret = vm.qmp('blockdev-add',
|
|
|
ae23c9 |
+ node_name='target',
|
|
|
ae23c9 |
+ driver='null-co',
|
|
|
ae23c9 |
+ size=1048576)
|
|
|
ae23c9 |
+ assert ret['return'] == {}
|
|
|
ae23c9 |
+
|
|
|
ae23c9 |
+ if speed is not None:
|
|
|
ae23c9 |
+ ret = vm.qmp('blockdev-mirror',
|
|
|
ae23c9 |
+ job_id='mirror',
|
|
|
ae23c9 |
+ device='source',
|
|
|
ae23c9 |
+ target='target',
|
|
|
ae23c9 |
+ sync='full',
|
|
|
ae23c9 |
+ speed=speed,
|
|
|
ae23c9 |
+ buf_size=buf_size)
|
|
|
ae23c9 |
+ else:
|
|
|
ae23c9 |
+ ret = vm.qmp('blockdev-mirror',
|
|
|
ae23c9 |
+ job_id='mirror',
|
|
|
ae23c9 |
+ device='source',
|
|
|
ae23c9 |
+ target='target',
|
|
|
ae23c9 |
+ sync='full')
|
|
|
ae23c9 |
+
|
|
|
ae23c9 |
+ assert ret['return'] == {}
|
|
|
ae23c9 |
+
|
|
|
ae23c9 |
+
|
|
|
ae23c9 |
+log('')
|
|
|
ae23c9 |
+log('=== Cancel mirror job before convergence ===')
|
|
|
ae23c9 |
+log('')
|
|
|
ae23c9 |
+
|
|
|
ae23c9 |
+log('--- force=false ---')
|
|
|
ae23c9 |
+log('')
|
|
|
ae23c9 |
+
|
|
|
ae23c9 |
+with iotests.VM() as vm:
|
|
|
ae23c9 |
+ # Low speed so it does not converge
|
|
|
ae23c9 |
+ start_mirror(vm, 65536, 65536)
|
|
|
ae23c9 |
+
|
|
|
ae23c9 |
+ log('Cancelling job')
|
|
|
ae23c9 |
+ log(vm.qmp('block-job-cancel', device='mirror', force=False))
|
|
|
ae23c9 |
+
|
|
|
ae23c9 |
+ log(vm.event_wait('BLOCK_JOB_CANCELLED'),
|
|
|
ae23c9 |
+ filters=[iotests.filter_qmp_event])
|
|
|
ae23c9 |
+
|
|
|
ae23c9 |
+log('')
|
|
|
ae23c9 |
+log('--- force=true ---')
|
|
|
ae23c9 |
+log('')
|
|
|
ae23c9 |
+
|
|
|
ae23c9 |
+with iotests.VM() as vm:
|
|
|
ae23c9 |
+ # Low speed so it does not converge
|
|
|
ae23c9 |
+ start_mirror(vm, 65536, 65536)
|
|
|
ae23c9 |
+
|
|
|
ae23c9 |
+ log('Cancelling job')
|
|
|
ae23c9 |
+ log(vm.qmp('block-job-cancel', device='mirror', force=True))
|
|
|
ae23c9 |
+
|
|
|
ae23c9 |
+ log(vm.event_wait('BLOCK_JOB_CANCELLED'),
|
|
|
ae23c9 |
+ filters=[iotests.filter_qmp_event])
|
|
|
ae23c9 |
+
|
|
|
ae23c9 |
+
|
|
|
ae23c9 |
+log('')
|
|
|
ae23c9 |
+log('=== Cancel mirror job after convergence ===')
|
|
|
ae23c9 |
+log('')
|
|
|
ae23c9 |
+
|
|
|
ae23c9 |
+log('--- force=false ---')
|
|
|
ae23c9 |
+log('')
|
|
|
ae23c9 |
+
|
|
|
ae23c9 |
+with iotests.VM() as vm:
|
|
|
ae23c9 |
+ start_mirror(vm)
|
|
|
ae23c9 |
+
|
|
|
ae23c9 |
+ log(vm.event_wait('BLOCK_JOB_READY'),
|
|
|
ae23c9 |
+ filters=[iotests.filter_qmp_event])
|
|
|
ae23c9 |
+
|
|
|
ae23c9 |
+ log('Cancelling job')
|
|
|
ae23c9 |
+ log(vm.qmp('block-job-cancel', device='mirror', force=False))
|
|
|
ae23c9 |
+
|
|
|
ae23c9 |
+ log(vm.event_wait('BLOCK_JOB_COMPLETED'),
|
|
|
ae23c9 |
+ filters=[iotests.filter_qmp_event])
|
|
|
ae23c9 |
+
|
|
|
ae23c9 |
+log('')
|
|
|
ae23c9 |
+log('--- force=true ---')
|
|
|
ae23c9 |
+log('')
|
|
|
ae23c9 |
+
|
|
|
ae23c9 |
+with iotests.VM() as vm:
|
|
|
ae23c9 |
+ start_mirror(vm)
|
|
|
ae23c9 |
+
|
|
|
ae23c9 |
+ log(vm.event_wait('BLOCK_JOB_READY'),
|
|
|
ae23c9 |
+ filters=[iotests.filter_qmp_event])
|
|
|
ae23c9 |
+
|
|
|
ae23c9 |
+ log('Cancelling job')
|
|
|
ae23c9 |
+ log(vm.qmp('block-job-cancel', device='mirror', force=True))
|
|
|
ae23c9 |
+
|
|
|
ae23c9 |
+ log(vm.event_wait('BLOCK_JOB_CANCELLED'),
|
|
|
ae23c9 |
+ filters=[iotests.filter_qmp_event])
|
|
|
ae23c9 |
diff --git a/tests/qemu-iotests/218.out b/tests/qemu-iotests/218.out
|
|
|
ae23c9 |
new file mode 100644
|
|
|
ae23c9 |
index 0000000..7dbf78e
|
|
|
ae23c9 |
--- /dev/null
|
|
|
ae23c9 |
+++ b/tests/qemu-iotests/218.out
|
|
|
ae23c9 |
@@ -0,0 +1,30 @@
|
|
|
ae23c9 |
+
|
|
|
ae23c9 |
+=== Cancel mirror job before convergence ===
|
|
|
ae23c9 |
+
|
|
|
ae23c9 |
+--- force=false ---
|
|
|
ae23c9 |
+
|
|
|
ae23c9 |
+Cancelling job
|
|
|
ae23c9 |
+{u'return': {}}
|
|
|
ae23c9 |
+{u'timestamp': {u'seconds': 'SECS', u'microseconds': 'USECS'}, u'data': {u'device': u'mirror', u'type': u'mirror', u'speed': 65536, u'len': 1048576, u'offset': 65536}, u'event': u'BLOCK_JOB_CANCELLED'}
|
|
|
ae23c9 |
+
|
|
|
ae23c9 |
+--- force=true ---
|
|
|
ae23c9 |
+
|
|
|
ae23c9 |
+Cancelling job
|
|
|
ae23c9 |
+{u'return': {}}
|
|
|
ae23c9 |
+{u'timestamp': {u'seconds': 'SECS', u'microseconds': 'USECS'}, u'data': {u'device': u'mirror', u'type': u'mirror', u'speed': 65536, u'len': 1048576, u'offset': 65536}, u'event': u'BLOCK_JOB_CANCELLED'}
|
|
|
ae23c9 |
+
|
|
|
ae23c9 |
+=== Cancel mirror job after convergence ===
|
|
|
ae23c9 |
+
|
|
|
ae23c9 |
+--- force=false ---
|
|
|
ae23c9 |
+
|
|
|
ae23c9 |
+{u'timestamp': {u'seconds': 'SECS', u'microseconds': 'USECS'}, u'data': {u'device': u'mirror', u'type': u'mirror', u'speed': 0, u'len': 1048576, u'offset': 1048576}, u'event': u'BLOCK_JOB_READY'}
|
|
|
ae23c9 |
+Cancelling job
|
|
|
ae23c9 |
+{u'return': {}}
|
|
|
ae23c9 |
+{u'timestamp': {u'seconds': 'SECS', u'microseconds': 'USECS'}, u'data': {u'device': u'mirror', u'type': u'mirror', u'speed': 0, u'len': 1048576, u'offset': 1048576}, u'event': u'BLOCK_JOB_COMPLETED'}
|
|
|
ae23c9 |
+
|
|
|
ae23c9 |
+--- force=true ---
|
|
|
ae23c9 |
+
|
|
|
ae23c9 |
+{u'timestamp': {u'seconds': 'SECS', u'microseconds': 'USECS'}, u'data': {u'device': u'mirror', u'type': u'mirror', u'speed': 0, u'len': 1048576, u'offset': 1048576}, u'event': u'BLOCK_JOB_READY'}
|
|
|
ae23c9 |
+Cancelling job
|
|
|
ae23c9 |
+{u'return': {}}
|
|
|
ae23c9 |
+{u'timestamp': {u'seconds': 'SECS', u'microseconds': 'USECS'}, u'data': {u'device': u'mirror', u'type': u'mirror', u'speed': 0, u'len': 1048576, u'offset': 1048576}, u'event': u'BLOCK_JOB_CANCELLED'}
|
|
|
ae23c9 |
diff --git a/tests/qemu-iotests/group b/tests/qemu-iotests/group
|
|
|
ae23c9 |
index 99777ec..3a89aed 100644
|
|
|
ae23c9 |
--- a/tests/qemu-iotests/group
|
|
|
ae23c9 |
+++ b/tests/qemu-iotests/group
|
|
|
ae23c9 |
@@ -212,3 +212,4 @@
|
|
|
ae23c9 |
211 rw auto quick
|
|
|
ae23c9 |
212 rw auto quick
|
|
|
ae23c9 |
213 rw auto quick
|
|
|
ae23c9 |
+218 rw auto quick
|
|
|
ae23c9 |
--
|
|
|
ae23c9 |
1.8.3.1
|
|
|
ae23c9 |
|