Re: [PATCH v7 44/47] iotests: Add filter commit test cases
On 27.07.20 19:45, Andrey Shinkevich wrote: > On 25.06.2020 18:22, Max Reitz wrote: >> This patch adds some tests on how commit copes with filter nodes. >> >> Signed-off-by: Max Reitz >> --- >> tests/qemu-iotests/040 | 177 + >> tests/qemu-iotests/040.out | 4 +- >> 2 files changed, 179 insertions(+), 2 deletions(-) >> >> diff --git a/tests/qemu-iotests/040 b/tests/qemu-iotests/040 >> index 32c82b4ec6..e7fa244738 100755 >> --- a/tests/qemu-iotests/040 >> +++ b/tests/qemu-iotests/040 >> @@ -713,6 +713,183 @@ class TestErrorHandling(iotests.QMPTestCase): >> self.assertTrue(iotests.compare_images(mid_img, backing_img, >> fmt2='raw'), >> 'target image does not match source after >> commit') >> +class TestCommitWithFilters(iotests.QMPTestCase): >> + img0 = os.path.join(iotests.test_dir, '0.img') >> + img1 = os.path.join(iotests.test_dir, '1.img') >> + img2 = os.path.join(iotests.test_dir, '2.img') >> + img3 = os.path.join(iotests.test_dir, '3.img') >> + >> + def do_test_io(self, read_or_write): > > > The method defenition could be moved down after the ones of setUp() and > tearDown(). Yes, but it’s used by setUp(), so I thought maybe it’s nicer to place it first. >> + for index, pattern_file in enumerate(self.pattern_files): >> + result = qemu_io('-f', iotests.imgfmt, >> + '-c', '{} -P {} {}M >> 1M'.format(read_or_write, >> + index + >> 1, index), > > > The Python3 format string f'{rad_or_write} ..' might be used instead of > the .format one. Ah, sure. The test is a bit older already, from when we didn’t yet use format strings as often in the iotests. :) >> + pattern_file) >> + self.assertFalse('Pattern verification failed' in result) >> + >> + def setUp(self): > > ... > > > Reviewed-by: Andrey Shinkevich > > signature.asc Description: OpenPGP digital signature
Re: [PATCH v7 44/47] iotests: Add filter commit test cases
On 25.06.2020 18:22, Max Reitz wrote: This patch adds some tests on how commit copes with filter nodes. Signed-off-by: Max Reitz --- tests/qemu-iotests/040 | 177 + tests/qemu-iotests/040.out | 4 +- 2 files changed, 179 insertions(+), 2 deletions(-) diff --git a/tests/qemu-iotests/040 b/tests/qemu-iotests/040 index 32c82b4ec6..e7fa244738 100755 --- a/tests/qemu-iotests/040 +++ b/tests/qemu-iotests/040 @@ -713,6 +713,183 @@ class TestErrorHandling(iotests.QMPTestCase): self.assertTrue(iotests.compare_images(mid_img, backing_img, fmt2='raw'), 'target image does not match source after commit') +class TestCommitWithFilters(iotests.QMPTestCase): +img0 = os.path.join(iotests.test_dir, '0.img') +img1 = os.path.join(iotests.test_dir, '1.img') +img2 = os.path.join(iotests.test_dir, '2.img') +img3 = os.path.join(iotests.test_dir, '3.img') + +def do_test_io(self, read_or_write): The method defenition could be moved down after the ones of setUp() and tearDown(). +for index, pattern_file in enumerate(self.pattern_files): +result = qemu_io('-f', iotests.imgfmt, + '-c', '{} -P {} {}M 1M'.format(read_or_write, +index + 1, index), The Python3 format string f'{rad_or_write} ..' might be used instead of the .format one. Andrey + pattern_file) +self.assertFalse('Pattern verification failed' in result) + +def setUp(self): ... Reviewed-by: Andrey Shinkevich
[PATCH v7 44/47] iotests: Add filter commit test cases
This patch adds some tests on how commit copes with filter nodes. Signed-off-by: Max Reitz --- tests/qemu-iotests/040 | 177 + tests/qemu-iotests/040.out | 4 +- 2 files changed, 179 insertions(+), 2 deletions(-) diff --git a/tests/qemu-iotests/040 b/tests/qemu-iotests/040 index 32c82b4ec6..e7fa244738 100755 --- a/tests/qemu-iotests/040 +++ b/tests/qemu-iotests/040 @@ -713,6 +713,183 @@ class TestErrorHandling(iotests.QMPTestCase): self.assertTrue(iotests.compare_images(mid_img, backing_img, fmt2='raw'), 'target image does not match source after commit') +class TestCommitWithFilters(iotests.QMPTestCase): +img0 = os.path.join(iotests.test_dir, '0.img') +img1 = os.path.join(iotests.test_dir, '1.img') +img2 = os.path.join(iotests.test_dir, '2.img') +img3 = os.path.join(iotests.test_dir, '3.img') + +def do_test_io(self, read_or_write): +for index, pattern_file in enumerate(self.pattern_files): +result = qemu_io('-f', iotests.imgfmt, + '-c', '{} -P {} {}M 1M'.format(read_or_write, +index + 1, index), + pattern_file) +self.assertFalse('Pattern verification failed' in result) + +def setUp(self): +qemu_img('create', '-f', iotests.imgfmt, self.img0, '64M') +qemu_img('create', '-f', iotests.imgfmt, self.img1, '64M') +qemu_img('create', '-f', iotests.imgfmt, self.img2, '64M') +qemu_img('create', '-f', iotests.imgfmt, self.img3, '64M') + +# Distributions of the patterns in the files; this is checked +# by tearDown() and should be changed by the test cases as is +# necessary +self.pattern_files = [self.img0, self.img1, self.img2, self.img3] + +self.do_test_io('write') + +self.vm = iotests.VM() +self.vm.launch() + +result = self.vm.qmp('object-add', qom_type='throttle-group', id='tg') +self.assert_qmp(result, 'return', {}) + +result = self.vm.qmp('blockdev-add', **{ +'node-name': 'top-filter', +'driver': 'throttle', +'throttle-group': 'tg', +'file': { +'node-name': 'cow-3', +'driver': iotests.imgfmt, +'file': { +'driver': 'file', +'filename': self.img3 +}, +'backing': { +'node-name': 'cow-2', +'driver': iotests.imgfmt, +'file': { +'driver': 'file', +'filename': self.img2 +}, +'backing': { +'node-name': 'cow-1', +'driver': iotests.imgfmt, +'file': { +'driver': 'file', +'filename': self.img1 +}, +'backing': { +'node-name': 'bottom-filter', +'driver': 'throttle', +'throttle-group': 'tg', +'file': { +'node-name': 'cow-0', +'driver': iotests.imgfmt, +'file': { +'driver': 'file', +'filename': self.img0 +} +} +} +} +} +} +}) +self.assert_qmp(result, 'return', {}) + +def tearDown(self): +self.vm.shutdown() +self.do_test_io('read') + +os.remove(self.img3) +os.remove(self.img2) +os.remove(self.img1) +os.remove(self.img0) + +# Filters make for funny filenames, so we cannot just use +# self.imgX to get them +def get_filename(self, node): +return self.vm.node_info(node)['image']['filename'] + +def test_filterless_commit(self): +result = self.vm.qmp('block-commit', + job_id='commit', + device='top-filter', + top_node='cow-2', + base_node='cow-1') +self.assert_qmp(result, 'return', {}) +self.wait_until_completed(drive='commit') + +self.assertIsNotNone(self.vm.node_info('cow-3')) +self.assertIsNone(self.vm.node_info('cow-2')) +self.assertIsNotNone(self.vm.node_info('cow-1')) + +# 2 has been comitted into 1 +self.pattern_files[2] = self.img1 + +def