iotests skipping
cover iotests skipping
Hi all!
This series adds a bit more support for iotests skipping due to format whitelisting. Not pretend to be something complete. It just lay in its folder I don't know how much time, I forgot to send it.
Still, now I've rebased it on master, let's take them, they are useful.
Vladimir Sementsov-Ogievskiy (8):
iotests: handle tmpfs
iotests/082: require bochs
iotests/148: use skip_if_unsupported
iotests/041: drop self.assert_no_active_block_jobs() iotests/055: refactor compressed backup to vmdk iotests/055: skip vmdk target tests if vmdk is not whitelisted iotests/109: mark required formats as required to support whitelisting iotests/113: mark bochs as required to support whitelisting
tests/qemu-iotests/041 | 8 ---- tests/qemu-iotests/055 | 74 ++++++++++++++++++++---------------- tests/qemu-iotests/055.out | 4 +- tests/qemu-iotests/082 | 1 + tests/qemu-iotests/091 | 2 +- tests/qemu-iotests/109 | 1 + tests/qemu-iotests/113 | 4 +- tests/qemu-iotests/148 | 1 + tests/qemu-iotests/common.rc | 37 +++++++++++++++++- 9 files changed, 84 insertions(+), 48 deletions(-)
Signature · 1 line
2.21.0
PATCH 1/8 iotests: handle tmpfs
Some tests requires O_DIRECT, or want it by default. Introduce smarter O_DIRECT handling:
- Check O_DIRECT in common.rc, if it is requested by selected cache-mode.
- Support second fall-through argument in _default_cache_mode
--- tests/qemu-iotests/091 | 2 +- tests/qemu-iotests/common.rc | 37 ++++++++++++++++++++++++++++++++++-- 2 files changed, 36 insertions(+), 3 deletions(-)
tests/qemu-iotests/091 +1 -1
@@ -46,8 +46,8 @@ trap "_cleanup; exit \$status" 0 1 2 3 15 _supported_fmt qcow2 _supported_proto file _supported_os Linux -_default_cache_mode none _supported_cache_modes writethrough none writeback +_default_cache_mode none writeback size=1G
tests/qemu-iotests/common.rc +35 -2
@@ -673,11 +673,44 @@ _supported_cache_modes() _notrun "not suitable for cache mode: $CACHEMODE" } +# Check whether the filesystem supports O_DIRECT +_check_o_direct() +{ + $QEMU_IMG create -f raw "$TEST_IMG".test_o_direct 1M > /dev/null + out=$($QEMU_IO -f raw -t none -c quit "$TEST_IMG".test_o_direct 2>&1) + rm -f "$TEST_IMG".test_o_direct + + [[ "$out" != *"O_DIRECT"* ]] +} + +_require_o_direct() +{ + if ! _check_o_direct; then + _notrun "file system on $TEST_DIR does not support O_DIRECT" + fi +} + +_check_cache_mode() +{ + if [ $CACHEMODE == "none" ] || [ $CACHEMODE == "directsync" ]; then + _require_o_direct + fi +} + +_check_cache_mode + +# $1 - cache mode to use by default +# $2 - (optional) cache mode to use by default if O_DIRECT is not supported _default_cache_mode() { if $CACHEMODE_IS_DEFAULT; then - CACHEMODE="$1" - QEMU_IO="$QEMU_IO --cache $1" + if [ -z "$2" ] || _check_o_direct; then + CACHEMODE="$1" + else + CACHEMODE="$2" + fi + QEMU_IO="$QEMU_IO --cache $CACHEMODE" + _check_cache_mode return fi }
Signature · 1 line
2.21.0
PATCH 2/8 iotests/082: require bochs
In reply to Vladimir Sementsov-OgievskiyTest fails if bochs not whitelisted, so, skip it in this case.
--- tests/qemu-iotests/082 | 1 + 1 file changed, 1 insertion(+)
tests/qemu-iotests/082 +1 -0
@@ -38,6 +38,7 @@ trap "_cleanup; exit \$status" 0 1 2 3 15 _supported_fmt qcow2 _supported_proto file nfs +_require_drivers bochs run_qemu_img() {
Signature · 1 line
2.21.0
PATCH 3/8 iotests/148: use skip_if_unsupported
In reply to Vladimir Sementsov-OgievskiySkip test-case with quorum if quorum is not whitelisted.
--- tests/qemu-iotests/148 | 1 + 1 file changed, 1 insertion(+)
tests/qemu-iotests/148 +1 -0
@@ -47,6 +47,7 @@ sector = "%d" ''' % bad_sector) file.close() + @iotests.skip_if_unsupported(['quorum']) def setUp(self): driveopts = ['driver=quorum', 'vote-threshold=2'] driveopts.append('read-pattern=%s' % self.read_pattern)
Signature · 1 line
2.21.0
PATCH 4/8 iotests/041: drop self.assert_no_active_block_jobs()
In reply to Vladimir Sementsov-OgievskiyDrop check for no block-jobs: it's obvious that there no jobs immediately after vm.launch().
--- tests/qemu-iotests/041 | 8 -------- 1 file changed, 8 deletions(-)
tests/qemu-iotests/041 +0 -8
@@ -904,8 +904,6 @@ class TestRepairQuorum(iotests.QMPTestCase): pass def test_complete(self): - self.assert_no_active_block_jobs() - result = self.vm.qmp('drive-mirror', job_id='job0', device='quorum0', sync='full', node_name="repair0", replaces="img1", target=quorum_repair_img, format=iotests.imgfmt)
@@ -919,8 +917,6 @@ class TestRepairQuorum(iotests.QMPTestCase): 'target image does not match source after mirroring') def test_cancel(self): - self.assert_no_active_block_jobs() - result = self.vm.qmp('drive-mirror', job_id='job0', device='quorum0', sync='full', node_name="repair0", replaces="img1", target=quorum_repair_img, format=iotests.imgfmt)
@@ -932,8 +928,6 @@ class TestRepairQuorum(iotests.QMPTestCase): self.assert_has_block_node(None, quorum_img3) def test_cancel_after_ready(self): - self.assert_no_active_block_jobs() - result = self.vm.qmp('drive-mirror', job_id='job0', device='quorum0', sync='full', node_name="repair0", replaces="img1", target=quorum_repair_img, format=iotests.imgfmt)
@@ -948,8 +942,6 @@ class TestRepairQuorum(iotests.QMPTestCase): 'target image does not match source after mirroring') def test_pause(self): - self.assert_no_active_block_jobs() - result = self.vm.qmp('drive-mirror', job_id='job0', device='quorum0', sync='full', node_name="repair0", replaces="img1", target=quorum_repair_img, format=iotests.imgfmt)
Signature · 1 line
2.21.0
PATCH 5/8 iotests/055: refactor compressed backup to vmdk
In reply to Vladimir Sementsov-OgievskiyInstead of looping in each test, let's better refactor vmdk target case as a subclass.
--- tests/qemu-iotests/055 | 70 ++++++++++++++++++++------------------ tests/qemu-iotests/055.out | 4 +-- 2 files changed, 39 insertions(+), 35 deletions(-)
tests/qemu-iotests/055 +37 -33
@@ -450,10 +450,9 @@ class TestSingleTransaction(iotests.QMPTestCase): self.assert_no_active_block_jobs() -class TestDriveCompression(iotests.QMPTestCase): +class TestCompressedToQcow2(iotests.QMPTestCase): image_len = 64 * 1024 * 1024 # MB - fmt_supports_compression = [{'type': 'qcow2', 'args': ()}, - {'type': 'vmdk', 'args': ('-o', 'subformat=streamOptimized')}] + target_fmt = {'type': 'qcow2', 'args': ()} def tearDown(self): self.vm.shutdown()
@@ -463,18 +462,19 @@ class TestDriveCompression(iotests.QMPTestCase): except OSError: pass - def do_prepare_drives(self, fmt, args, attach_target): + def do_prepare_drives(self, attach_target): self.vm = iotests.VM().add_drive('blkdebug::' + test_img) - qemu_img('create', '-f', fmt, blockdev_target_img, - str(TestDriveCompression.image_len), *args) + qemu_img('create', '-f', self.target_fmt['type'], blockdev_target_img, + str(self.image_len), *self.target_fmt['args']) if attach_target: - self.vm.add_drive(blockdev_target_img, format=fmt, interface="none") + self.vm.add_drive(blockdev_target_img, + format=self.target_fmt['type'], interface="none") self.vm.launch() - def do_test_compress_complete(self, cmd, format, attach_target, **args): - self.do_prepare_drives(format['type'], format['args'], attach_target) + def do_test_compress_complete(self, cmd, attach_target, **args): + self.do_prepare_drives(attach_target) self.assert_no_active_block_jobs()
@@ -485,21 +485,21 @@ class TestDriveCompression(iotests.QMPTestCase): self.vm.shutdown() self.assertTrue(iotests.compare_images(test_img, blockdev_target_img, - iotests.imgfmt, format['type']), + iotests.imgfmt, + self.target_fmt['type']), 'target image does not match source after backup') def test_complete_compress_drive_backup(self): - for format in TestDriveCompression.fmt_supports_compression: - self.do_test_compress_complete('drive-backup', format, False, - target=blockdev_target_img, mode='existing') + self.do_test_compress_complete('drive-backup', False, + target=blockdev_target_img, + mode='existing') def test_complete_compress_blockdev_backup(self): - for format in TestDriveCompression.fmt_supports_compression: - self.do_test_compress_complete('blockdev-backup', format, True, - target='drive1') + self.do_test_compress_complete('blockdev-backup', + True, target='drive1') - def do_test_compress_cancel(self, cmd, format, attach_target, **args): - self.do_prepare_drives(format['type'], format['args'], attach_target) + def do_test_compress_cancel(self, cmd, attach_target, **args): + self.do_prepare_drives(attach_target) self.assert_no_active_block_jobs()
@@ -513,17 +513,16 @@ class TestDriveCompression(iotests.QMPTestCase): self.vm.shutdown() def test_compress_cancel_drive_backup(self): - for format in TestDriveCompression.fmt_supports_compression: - self.do_test_compress_cancel('drive-backup', format, False, - target=blockdev_target_img, mode='existing') + self.do_test_compress_cancel('drive-backup', False, + target=blockdev_target_img, + mode='existing') def test_compress_cancel_blockdev_backup(self): - for format in TestDriveCompression.fmt_supports_compression: - self.do_test_compress_cancel('blockdev-backup', format, True, - target='drive1') + self.do_test_compress_cancel('blockdev-backup', True, + target='drive1') - def do_test_compress_pause(self, cmd, format, attach_target, **args): - self.do_prepare_drives(format['type'], format['args'], attach_target) + def do_test_compress_pause(self, cmd, attach_target, **args): + self.do_prepare_drives(attach_target) self.assert_no_active_block_jobs()
@@ -549,18 +548,23 @@ class TestDriveCompression(iotests.QMPTestCase): self.vm.shutdown() self.assertTrue(iotests.compare_images(test_img, blockdev_target_img, - iotests.imgfmt, format['type']), + iotests.imgfmt, + self.target_fmt['type']), 'target image does not match source after backup') def test_compress_pause_drive_backup(self): - for format in TestDriveCompression.fmt_supports_compression: - self.do_test_compress_pause('drive-backup', format, False, - target=blockdev_target_img, mode='existing') + self.do_test_compress_pause('drive-backup', False, + target=blockdev_target_img, + mode='existing') def test_compress_pause_blockdev_backup(self): - for format in TestDriveCompression.fmt_supports_compression: - self.do_test_compress_pause('blockdev-backup', format, True, - target='drive1') + self.do_test_compress_pause('blockdev-backup', True, + target='drive1') + + +class TestCompressedToVmdk(TestCompressedToQcow2): + target_fmt = {'type': 'vmdk', 'args': ('-o', 'subformat=streamOptimized')} + if __name__ == '__main__': iotests.main(supported_fmts=['raw', 'qcow2'],
tests/qemu-iotests/055.out +2 -2
@@ -1,5 +1,5 @@ -.............................. +.................................... ---------------------------------------------------------------------- -Ran 30 tests +Ran 36 tests OK
Signature · 1 line
2.21.0
PATCH 6/8 iotests/055: skip vmdk target tests if vmdk is not whitelisted
In reply to Vladimir Sementsov-Ogievskiy--- tests/qemu-iotests/055 | 4 ++++ 1 file changed, 4 insertions(+)
tests/qemu-iotests/055 +4 -0
@@ -565,6 +565,10 @@ class TestCompressedToQcow2(iotests.QMPTestCase): class TestCompressedToVmdk(TestCompressedToQcow2): target_fmt = {'type': 'vmdk', 'args': ('-o', 'subformat=streamOptimized')} + @iotests.skip_if_unsupported(['vmdk']) + def setUp(self): + pass + if __name__ == '__main__': iotests.main(supported_fmts=['raw', 'qcow2'],
Signature · 1 line
2.21.0
PATCH 7/8 iotests/109: mark required formats as required to support whitelisting
In reply to Vladimir Sementsov-Ogievskiy--- tests/qemu-iotests/109 | 1 + 1 file changed, 1 insertion(+)
tests/qemu-iotests/109 +1 -0
@@ -42,6 +42,7 @@ trap "_cleanup; exit \$status" 0 1 2 3 15 _supported_fmt raw _supported_proto file _supported_os Linux +_require_drivers qcow qcow2 qed vdi vmdk vpc qemu_comm_method=qmp
Signature · 1 line
2.21.0
PATCH 8/8 iotests/113: mark bochs as required to support whitelisting
In reply to Vladimir Sementsov-Ogievskiy--- tests/qemu-iotests/113 | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
tests/qemu-iotests/113 +2 -2
@@ -37,8 +37,8 @@ trap "_cleanup; exit \$status" 0 1 2 3 15 . ./common.rc . ./common.filter -# Some of these test cases use bochs, but others do use raw, so this -# is only half a lie. +# Some of these test cases use bochs, but others do use raw +_require_drivers bochs _supported_fmt raw _supported_proto file _supported_os Linux
Signature · 1 line
2.21.0
Kevin Wolf
AppliedAm 30.04.2020 um 14:47 hat Vladimir Sementsov-Ogievskiy geschrieben:
Quoted 7 lines
Hi all!
This series adds a bit more support for iotests skipping due to format whitelisting. Not pretend to be something complete. It just lay in its folder I don't know how much time, I forgot to send it.
Still, now I've rebased it on master, let's take them, they are useful.
I agree. They are certainly not complete by any means, but let's just take what we already have.
Thanks, applied to the block branch.
Kevin
Quoted 7 lines · Kevin Wolf
Am 30.04.2020 um 14:47 hat Vladimir Sementsov-Ogievskiy geschrieben:
Quoted 6 lines
Hi all!
This series adds a bit more support for iotests skipping due to format whitelisting. Not pretend to be something complete. It just lay in its folder I don't know how much time, I forgot to send it.
Quoted 7 lines
Quoted 1 line
Still, now I've rebased it on master, let's take them, they are useful.
I agree. They are certainly not complete by any means, but let's just take what we already have.
Thanks, applied to the block branch.
Great! Thank you!
Signature · 2 lines
Best regards, Vladimir