[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL 16/32] tests: add migrate-during-backup
From: |
Hanna Reitz |
Subject: |
[PULL 16/32] tests: add migrate-during-backup |
Date: |
Wed, 15 Sep 2021 19:53:02 +0200 |
From: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
Add a simple test which tries to run migration during backup.
bdrv_inactivate_all() should fail. But due to bug (see next commit with
fix) it doesn't, nodes are inactivated and continued backup crashes
on assertion "assert(!(bs->open_flags & BDRV_O_INACTIVE));" in
bdrv_co_write_req_prepare().
Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
Message-Id: <20210911120027.8063-2-vsementsov@virtuozzo.com>
Signed-off-by: Hanna Reitz <hreitz@redhat.com>
---
.../qemu-iotests/tests/migrate-during-backup | 97 +++++++++++++++++++
.../tests/migrate-during-backup.out | 5 +
2 files changed, 102 insertions(+)
create mode 100755 tests/qemu-iotests/tests/migrate-during-backup
create mode 100644 tests/qemu-iotests/tests/migrate-during-backup.out
diff --git a/tests/qemu-iotests/tests/migrate-during-backup
b/tests/qemu-iotests/tests/migrate-during-backup
new file mode 100755
index 0000000000..1046904c5a
--- /dev/null
+++ b/tests/qemu-iotests/tests/migrate-during-backup
@@ -0,0 +1,97 @@
+#!/usr/bin/env python3
+# group: migration disabled
+#
+# Copyright (c) 2021 Virtuozzo International GmbH
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+#
+
+import os
+import iotests
+from iotests import qemu_img_create, qemu_io
+
+
+disk_a = os.path.join(iotests.test_dir, 'disk_a')
+disk_b = os.path.join(iotests.test_dir, 'disk_b')
+size = '1M'
+mig_file = os.path.join(iotests.test_dir, 'mig_file')
+mig_cmd = 'exec: cat > ' + mig_file
+
+
+class TestMigrateDuringBackup(iotests.QMPTestCase):
+ def tearDown(self):
+ self.vm.shutdown()
+ os.remove(disk_a)
+ os.remove(disk_b)
+ os.remove(mig_file)
+
+ def setUp(self):
+ qemu_img_create('-f', iotests.imgfmt, disk_a, size)
+ qemu_img_create('-f', iotests.imgfmt, disk_b, size)
+ qemu_io('-c', f'write 0 {size}', disk_a)
+
+ self.vm = iotests.VM().add_drive(disk_a)
+ self.vm.launch()
+ result = self.vm.qmp('blockdev-add', {
+ 'node-name': 'target',
+ 'driver': iotests.imgfmt,
+ 'file': {
+ 'driver': 'file',
+ 'filename': disk_b
+ }
+ })
+ self.assert_qmp(result, 'return', {})
+
+ def test_migrate(self):
+ result = self.vm.qmp('blockdev-backup', device='drive0',
+ target='target', sync='full',
+ speed=1, x_perf={
+ 'max-workers': 1,
+ 'max-chunk': 64 * 1024
+ })
+ self.assert_qmp(result, 'return', {})
+
+ result = self.vm.qmp('job-pause', id='drive0')
+ self.assert_qmp(result, 'return', {})
+
+ result = self.vm.qmp('migrate-set-capabilities',
+ capabilities=[{'capability': 'events',
+ 'state': True}])
+ self.assert_qmp(result, 'return', {})
+ result = self.vm.qmp('migrate', uri=mig_cmd)
+ self.assert_qmp(result, 'return', {})
+
+ e = self.vm.events_wait((('MIGRATION',
+ {'data': {'status': 'completed'}}),
+ ('MIGRATION',
+ {'data': {'status': 'failed'}})))
+
+ # Don't assert that e is 'failed' now: this way we'll miss
+ # possible crash when backup continues :)
+
+ result = self.vm.qmp('block-job-set-speed', device='drive0',
+ speed=0)
+ self.assert_qmp(result, 'return', {})
+ result = self.vm.qmp('job-resume', id='drive0')
+ self.assert_qmp(result, 'return', {})
+
+ # For future: if something changes so that both migration
+ # and backup pass, let's not miss that moment, as it may
+ # be a bug as well as improvement.
+ self.assert_qmp(e, 'data/status', 'failed')
+
+
+if __name__ == '__main__':
+ iotests.main(supported_fmts=['qcow2'],
+ supported_protocols=['file'])
diff --git a/tests/qemu-iotests/tests/migrate-during-backup.out
b/tests/qemu-iotests/tests/migrate-during-backup.out
new file mode 100644
index 0000000000..ae1213e6f8
--- /dev/null
+++ b/tests/qemu-iotests/tests/migrate-during-backup.out
@@ -0,0 +1,5 @@
+.
+----------------------------------------------------------------------
+Ran 1 tests
+
+OK
--
2.31.1
- [PULL 07/32] block/iscsi: Do not force-cap *pnum, (continued)
- [PULL 07/32] block/iscsi: Do not force-cap *pnum, Hanna Reitz, 2021/09/15
- [PULL 09/32] iotests: Fix use-{list,dict}-literal warnings, Hanna Reitz, 2021/09/15
- [PULL 13/32] mirror-top-perms: Fix AbnormalShutdown path, Hanna Reitz, 2021/09/15
- [PULL 08/32] iotests: Fix unspecified-encoding pylint warnings, Hanna Reitz, 2021/09/15
- [PULL 15/32] block/mirror: fix NULL pointer dereference in mirror_wait_on_conflicts(), Hanna Reitz, 2021/09/15
- [PULL 10/32] iotests/297: Drop 169 and 199 from the skip list, Hanna Reitz, 2021/09/15
- [PULL 14/32] iotests/297: Cover tests/, Hanna Reitz, 2021/09/15
- [PULL 17/32] block: bdrv_inactivate_recurse(): check for permissions and fix crash, Hanna Reitz, 2021/09/15
- [PULL 12/32] migrate-bitmaps-test: Fix pylint warnings, Hanna Reitz, 2021/09/15
- [PULL 11/32] migrate-bitmaps-postcopy-test: Fix pylint warnings, Hanna Reitz, 2021/09/15
- [PULL 16/32] tests: add migrate-during-backup,
Hanna Reitz <=
- [PULL 19/32] qcow2: refactor handle_dependencies() loop body, Hanna Reitz, 2021/09/15
- [PULL 18/32] simplebench: add img_bench_templater.py, Hanna Reitz, 2021/09/15
- [PULL 21/32] qemu-img: Allow target be aligned to sector size, Hanna Reitz, 2021/09/15
- [PULL 20/32] qcow2: handle_dependencies(): relax conflict detection, Hanna Reitz, 2021/09/15
- [PULL 22/32] qcow2-refcount: improve style of check_refcounts_l2(), Hanna Reitz, 2021/09/15
- [PULL 23/32] qcow2: compressed read: simplify cluster descriptor passing, Hanna Reitz, 2021/09/15
- [PULL 25/32] qcow2-refcount: introduce fix_l2_entry_by_zero(), Hanna Reitz, 2021/09/15
- [PULL 24/32] qcow2: introduce qcow2_parse_compressed_l2_entry() helper, Hanna Reitz, 2021/09/15
- [PULL 26/32] qcow2-refcount: fix_l2_entry_by_zero(): also zero L2 entry bitmap, Hanna Reitz, 2021/09/15
- [PULL 27/32] qcow2-refcount: check_refcounts_l2(): check l2_bitmap, Hanna Reitz, 2021/09/15