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