iotests: 124: Don't reopen qcow2 file
cover iotests: 124: Don't reopen qcow2 file
Kevin caught me being Naughty, and because I don't want Santa to be mad at me, I have corrected my ways.
Split iotest 124 into two classes so that the iotest that requires a blkdebug filter from the get-go can forego the standard setUp routine and just do it correct the first time.
Does this warrant three patches? Not really, but to make the code motion nice to look at, I had to split it out that way.
--js
________________________________________________________________________________
For convenience, this branch is available at:
https://github.com/jnsnow/qemu.git branch block-iotest-124-qcow2-locking
https://github.com/jnsnow/qemu/tree/block-iotest-124-qcow2-locking
This version is tagged block-iotest-124-qcow2-locking-v1:
https://github.com/jnsnow/qemu/releases/tag/block-iotest-124-qcow2-locking-v1
John Snow (3):
iotests: 124: Split into two test classes
iotests: 124: move incremental failure test
iotests: 124: don't reopen qcow2
tests/qemu-iotests/124 | 148 +++++++++++++++++++++++++++---------------------- 1 file changed, 81 insertions(+), 67 deletions(-)
Signature · 1 line
2.4.3
PATCH 1/3 iotests: 124: Split into two test classes
Split it into an abstract test class and an implementation class.
The split is primarily to facilitate more flexible setUp variations for other kinds of tests without having to rewrite or shuffle around all of these helpers.
See the following two patches for more of the "why."
--- tests/qemu-iotests/124 | 35 ++++++++++++++++++++++------------- 1 file changed, 22 insertions(+), 13 deletions(-)
tests/qemu-iotests/124 +22 -13
@@ -91,24 +91,31 @@ class Bitmap: try_remove(image) -class TestIncrementalBackup(iotests.QMPTestCase): - def setUp(self): +class TestIncrementalBackupBase(iotests.QMPTestCase): + def __init__(self, *args): + super(TestIncrementalBackupBase, self).__init__(*args) self.bitmaps = list() self.files = list() self.drives = list() self.vm = iotests.VM() self.err_img = os.path.join(iotests.test_dir, 'err.%s' % iotests.imgfmt) + + def setUp(self): # Create a base image with a distinctive patterning drive0 = self.add_node('drive0') self.img_create(drive0['file'], drive0['fmt']) self.vm.add_drive(drive0['file']) - io_write_patterns(drive0['file'], (('0x41', 0, 512), - ('0xd5', '1M', '32k'), - ('0xdc', '32M', '124k'))) + self.write_default_pattern(drive0['file']) self.vm.launch() + def write_default_pattern(self, target): + io_write_patterns(target, (('0x41', 0, 512), + ('0xd5', '1M', '32k'), + ('0xdc', '32M', '124k'))) + + def add_node(self, node_id, fmt=iotests.imgfmt, path=None, backup=None): if path is None: path = os.path.join(iotests.test_dir, '%s.%s' % (node_id, fmt))
@@ -259,6 +266,16 @@ class TestIncrementalBackup(iotests.QMPTestCase): self.check_backups() + def tearDown(self): + self.vm.shutdown() + for bitmap in self.bitmaps: + bitmap.cleanup() + for filename in self.files: + try_remove(filename) + + + +class TestIncrementalBackup(TestIncrementalBackupBase): def test_incremental_simple(self): ''' Test: Create and verify three incremental backups.
@@ -531,13 +548,5 @@ class TestIncrementalBackup(iotests.QMPTestCase): granularity=64000) - def tearDown(self): - self.vm.shutdown() - for bitmap in self.bitmaps: - bitmap.cleanup() - for filename in self.files: - try_remove(filename) - - if __name__ == '__main__': iotests.main(supported_fmts=['qcow2'])
Signature · 1 line
2.4.3
PATCH 2/3 iotests: 124: move incremental failure test
In reply to John SnowCode motion only, in preparation for adjusting
the setUp procedure for this test.
--- tests/qemu-iotests/124 | 117 +++++++++++++++++++++++++------------------------ 1 file changed, 60 insertions(+), 57 deletions(-)
tests/qemu-iotests/124 +60 -57
@@ -344,63 +344,6 @@ class TestIncrementalBackup(TestIncrementalBackupBase): self.check_backups() - def test_incremental_failure(self): - '''Test: Verify backups made after a failure are correct. - - Simulate a failure during an incremental backup block job, - emulate additional writes, then create another incremental backup - afterwards and verify that the backup created is correct. - ''' - - # Create a blkdebug interface to this img as 'drive1', - # but don't actually create a new image. - drive1 = self.add_node('drive1', self.drives[0]['fmt'], - path=self.drives[0]['file'], - backup=self.drives[0]['backup']) - result = self.vm.qmp('blockdev-add', options={ - 'id': drive1['id'], - 'driver': drive1['fmt'], - 'file': { - 'driver': 'blkdebug', - 'image': { - 'driver': 'file', - 'filename': drive1['file'] - }, - 'set-state': [{ - 'event': 'flush_to_disk', - 'state': 1, - 'new_state': 2 - }], - 'inject-error': [{ - 'event': 'read_aio', - 'errno': 5, - 'state': 2, - 'immediately': False, - 'once': True - }], - } - }) - self.assert_qmp(result, 'return', {}) - - self.create_anchor_backup(self.drives[0]) - self.add_bitmap('bitmap0', drive1) - # Note: at this point, during a normal execution, - # Assume that the VM resumes and begins issuing IO requests here. - - self.hmp_io_writes(drive1['id'], (('0xab', 0, 512), - ('0xfe', '16M', '256k'), - ('0x64', '32736k', '64k'))) - - result = self.create_incremental(validate=False) - self.assertFalse(result) - self.hmp_io_writes(drive1['id'], (('0x9a', 0, 512), - ('0x55', '8M', '352k'), - ('0x78', '15872k', '1M'))) - self.create_incremental() - self.vm.shutdown() - self.check_backups() - - def test_transaction_failure(self): '''Test: Verify backups made from a transaction that partially fails.
@@ -548,5 +491,65 @@ class TestIncrementalBackup(TestIncrementalBackupBase): granularity=64000) +class TestIncrementalBackupBlkdebug(TestIncrementalBackupBase): + '''Incremental backup tests that utilize a BlkDebug filter on drive0.''' + + def test_incremental_failure(self): + '''Test: Verify backups made after a failure are correct. + + Simulate a failure during an incremental backup block job, + emulate additional writes, then create another incremental backup + afterwards and verify that the backup created is correct. + ''' + + # Create a blkdebug interface to this img as 'drive1', + # but don't actually create a new image. + drive1 = self.add_node('drive1', self.drives[0]['fmt'], + path=self.drives[0]['file'], + backup=self.drives[0]['backup']) + result = self.vm.qmp('blockdev-add', options={ + 'id': drive1['id'], + 'driver': drive1['fmt'], + 'file': { + 'driver': 'blkdebug', + 'image': { + 'driver': 'file', + 'filename': drive1['file'] + }, + 'set-state': [{ + 'event': 'flush_to_disk', + 'state': 1, + 'new_state': 2 + }], + 'inject-error': [{ + 'event': 'read_aio', + 'errno': 5, + 'state': 2, + 'immediately': False, + 'once': True + }], + } + }) + self.assert_qmp(result, 'return', {}) + + self.create_anchor_backup(self.drives[0]) + self.add_bitmap('bitmap0', drive1) + # Note: at this point, during a normal execution, + # Assume that the VM resumes and begins issuing IO requests here. + + self.hmp_io_writes(drive1['id'], (('0xab', 0, 512), + ('0xfe', '16M', '256k'), + ('0x64', '32736k', '64k'))) + + result = self.create_incremental(validate=False) + self.assertFalse(result) + self.hmp_io_writes(drive1['id'], (('0x9a', 0, 512), + ('0x55', '8M', '352k'), + ('0x78', '15872k', '1M'))) + self.create_incremental() + self.vm.shutdown() + self.check_backups() + + if __name__ == '__main__': iotests.main(supported_fmts=['qcow2'])
Signature · 1 line
2.4.3
PATCH 3/3 iotests: 124: don't reopen qcow2
In reply to John SnowDon't create two interfaces to the same drive in the recently moved failure test.
--- tests/qemu-iotests/124 | 26 ++++++++++++++------------ 1 file changed, 14 insertions(+), 12 deletions(-)
tests/qemu-iotests/124 +14 -12
@@ -494,6 +494,12 @@ class TestIncrementalBackup(TestIncrementalBackupBase): class TestIncrementalBackupBlkdebug(TestIncrementalBackupBase): '''Incremental backup tests that utilize a BlkDebug filter on drive0.''' + def setUp(self): + drive0 = self.add_node('drive0') + self.img_create(drive0['file'], drive0['fmt']) + self.write_default_pattern(drive0['file']) + self.vm.launch() + def test_incremental_failure(self): '''Test: Verify backups made after a failure are correct.
@@ -502,19 +508,15 @@ class TestIncrementalBackupBlkdebug(TestIncrementalBackupBase): afterwards and verify that the backup created is correct. ''' - # Create a blkdebug interface to this img as 'drive1', - # but don't actually create a new image. - drive1 = self.add_node('drive1', self.drives[0]['fmt'], - path=self.drives[0]['file'], - backup=self.drives[0]['backup']) + drive0 = self.drives[0] result = self.vm.qmp('blockdev-add', options={ - 'id': drive1['id'], - 'driver': drive1['fmt'], + 'id': drive0['id'], + 'driver': drive0['fmt'], 'file': { 'driver': 'blkdebug', 'image': { 'driver': 'file', - 'filename': drive1['file'] + 'filename': drive0['file'] }, 'set-state': [{ 'event': 'flush_to_disk',
@@ -532,18 +534,18 @@ class TestIncrementalBackupBlkdebug(TestIncrementalBackupBase): }) self.assert_qmp(result, 'return', {}) - self.create_anchor_backup(self.drives[0]) - self.add_bitmap('bitmap0', drive1) + self.create_anchor_backup(drive0) + self.add_bitmap('bitmap0', drive0) # Note: at this point, during a normal execution, # Assume that the VM resumes and begins issuing IO requests here. - self.hmp_io_writes(drive1['id'], (('0xab', 0, 512), + self.hmp_io_writes(drive0['id'], (('0xab', 0, 512), ('0xfe', '16M', '256k'), ('0x64', '32736k', '64k'))) result = self.create_incremental(validate=False) self.assertFalse(result) - self.hmp_io_writes(drive1['id'], (('0x9a', 0, 512), + self.hmp_io_writes(drive0['id'], (('0x9a', 0, 512), ('0x55', '8M', '352k'), ('0x78', '15872k', '1M'))) self.create_incremental()
Signature · 1 line
2.4.3
Kevin Wolf
AppliedAm 02.12.2015 um 00:16 hat John Snow geschrieben:
Quoted 9 lines
Kevin caught me being Naughty, and because I don't want Santa to be mad at me, I have corrected my ways.
Split iotest 124 into two classes so that the iotest that requires a blkdebug filter from the get-go can forego the standard setUp routine and just do it correct the first time.
Does this warrant three patches? Not really, but to make the code motion nice to look at, I had to split it out that way.
Thanks, applied to block-next.
Kevin