All of lore.kernel.org
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH for-2.6 0/3] iotests: 124: Don't reopen qcow2 file
@ 2015-12-01 23:16 John Snow
  2015-12-01 23:16 ` [Qemu-devel] [PATCH for-2.6 1/3] iotests: 124: Split into two test classes John Snow
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: John Snow @ 2015-12-01 23:16 UTC (permalink / raw)
  To: qemu-block; +Cc: kwolf, John Snow, qemu-devel

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(-)

-- 
2.4.3

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [Qemu-devel] [PATCH for-2.6 1/3] iotests: 124: Split into two test classes
  2015-12-01 23:16 [Qemu-devel] [PATCH for-2.6 0/3] iotests: 124: Don't reopen qcow2 file John Snow
@ 2015-12-01 23:16 ` John Snow
  2015-12-01 23:16 ` [Qemu-devel] [PATCH for-2.6 2/3] iotests: 124: move incremental failure test John Snow
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 5+ messages in thread
From: John Snow @ 2015-12-01 23:16 UTC (permalink / raw)
  To: qemu-block; +Cc: kwolf, John Snow, qemu-devel

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."

Signed-off-by: John Snow <jsnow@redhat.com>
---
 tests/qemu-iotests/124 | 35 ++++++++++++++++++++++-------------
 1 file changed, 22 insertions(+), 13 deletions(-)

diff --git a/tests/qemu-iotests/124 b/tests/qemu-iotests/124
index c928f01..778bfdd 100644
--- a/tests/qemu-iotests/124
+++ b/tests/qemu-iotests/124
@@ -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'])
-- 
2.4.3

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [Qemu-devel] [PATCH for-2.6 2/3] iotests: 124: move incremental failure test
  2015-12-01 23:16 [Qemu-devel] [PATCH for-2.6 0/3] iotests: 124: Don't reopen qcow2 file John Snow
  2015-12-01 23:16 ` [Qemu-devel] [PATCH for-2.6 1/3] iotests: 124: Split into two test classes John Snow
@ 2015-12-01 23:16 ` John Snow
  2015-12-01 23:16 ` [Qemu-devel] [PATCH for-2.6 3/3] iotests: 124: don't reopen qcow2 John Snow
  2015-12-02 12:43 ` [Qemu-devel] [PATCH for-2.6 0/3] iotests: 124: Don't reopen qcow2 file Kevin Wolf
  3 siblings, 0 replies; 5+ messages in thread
From: John Snow @ 2015-12-01 23:16 UTC (permalink / raw)
  To: qemu-block; +Cc: kwolf, John Snow, qemu-devel

Code motion only, in preparation for adjusting
the setUp procedure for this test.

Signed-off-by: John Snow <jsnow@redhat.com>
---
 tests/qemu-iotests/124 | 117 +++++++++++++++++++++++++------------------------
 1 file changed, 60 insertions(+), 57 deletions(-)

diff --git a/tests/qemu-iotests/124 b/tests/qemu-iotests/124
index 778bfdd..2a0119d 100644
--- a/tests/qemu-iotests/124
+++ b/tests/qemu-iotests/124
@@ -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'])
-- 
2.4.3

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [Qemu-devel] [PATCH for-2.6 3/3] iotests: 124: don't reopen qcow2
  2015-12-01 23:16 [Qemu-devel] [PATCH for-2.6 0/3] iotests: 124: Don't reopen qcow2 file John Snow
  2015-12-01 23:16 ` [Qemu-devel] [PATCH for-2.6 1/3] iotests: 124: Split into two test classes John Snow
  2015-12-01 23:16 ` [Qemu-devel] [PATCH for-2.6 2/3] iotests: 124: move incremental failure test John Snow
@ 2015-12-01 23:16 ` John Snow
  2015-12-02 12:43 ` [Qemu-devel] [PATCH for-2.6 0/3] iotests: 124: Don't reopen qcow2 file Kevin Wolf
  3 siblings, 0 replies; 5+ messages in thread
From: John Snow @ 2015-12-01 23:16 UTC (permalink / raw)
  To: qemu-block; +Cc: kwolf, John Snow, qemu-devel

Don't create two interfaces to the same drive in the recently moved
failure test.

Signed-off-by: John Snow <jsnow@redhat.com>
---
 tests/qemu-iotests/124 | 26 ++++++++++++++------------
 1 file changed, 14 insertions(+), 12 deletions(-)

diff --git a/tests/qemu-iotests/124 b/tests/qemu-iotests/124
index 2a0119d..7d33422 100644
--- a/tests/qemu-iotests/124
+++ b/tests/qemu-iotests/124
@@ -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()
-- 
2.4.3

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [Qemu-devel] [PATCH for-2.6 0/3] iotests: 124: Don't reopen qcow2 file
  2015-12-01 23:16 [Qemu-devel] [PATCH for-2.6 0/3] iotests: 124: Don't reopen qcow2 file John Snow
                   ` (2 preceding siblings ...)
  2015-12-01 23:16 ` [Qemu-devel] [PATCH for-2.6 3/3] iotests: 124: don't reopen qcow2 John Snow
@ 2015-12-02 12:43 ` Kevin Wolf
  3 siblings, 0 replies; 5+ messages in thread
From: Kevin Wolf @ 2015-12-02 12:43 UTC (permalink / raw)
  To: John Snow; +Cc: qemu-devel, qemu-block

Am 02.12.2015 um 00:16 hat John Snow geschrieben:
> 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

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2015-12-02 12:43 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-12-01 23:16 [Qemu-devel] [PATCH for-2.6 0/3] iotests: 124: Don't reopen qcow2 file John Snow
2015-12-01 23:16 ` [Qemu-devel] [PATCH for-2.6 1/3] iotests: 124: Split into two test classes John Snow
2015-12-01 23:16 ` [Qemu-devel] [PATCH for-2.6 2/3] iotests: 124: move incremental failure test John Snow
2015-12-01 23:16 ` [Qemu-devel] [PATCH for-2.6 3/3] iotests: 124: don't reopen qcow2 John Snow
2015-12-02 12:43 ` [Qemu-devel] [PATCH for-2.6 0/3] iotests: 124: Don't reopen qcow2 file Kevin Wolf

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.