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