All of lore.kernel.org
 help / color / mirror / Atom feed
From: Max Reitz <mreitz@redhat.com>
To: Fam Zheng <famz@redhat.com>, qemu-devel@nongnu.org
Cc: Kevin Wolf <kwolf@redhat.com>,
	qemu-block@nongnu.org, Jeff Cody <jcody@redhat.com>,
	Markus Armbruster <armbru@redhat.com>,
	Stefan Hajnoczi <stefanha@redhat.com>,
	pbonzini@redhat.com
Subject: Re: [Qemu-devel] [PATCH 6/6] iotests: Add test cases for blockdev-mirror
Date: Wed, 24 Jun 2015 19:10:11 +0200	[thread overview]
Message-ID: <558AE473.1020500@redhat.com> (raw)
In-Reply-To: <1433816027-32588-7-git-send-email-famz@redhat.com>

On 09.06.2015 04:13, Fam Zheng wrote:
> Signed-off-by: Fam Zheng <famz@redhat.com>
> ---
>   tests/qemu-iotests/041     | 100 +++++++++++++++++++++++++++++++++++----------
>   tests/qemu-iotests/041.out |   4 +-
>   2 files changed, 80 insertions(+), 24 deletions(-)
>
> diff --git a/tests/qemu-iotests/041 b/tests/qemu-iotests/041
> index 59a8f73..922f53c 100755
> --- a/tests/qemu-iotests/041
> +++ b/tests/qemu-iotests/041
> @@ -65,8 +65,23 @@ class ImageMirroringTestCase(iotests.QMPTestCase):
>           event = self.wait_until_completed(drive=drive)
>           self.assert_qmp(event, 'data/type', 'mirror')
>   
> +    def blockdev_add(self, filename, drive_id=None, node_name=None):
> +        options = {'driver': iotests.imgfmt,
> +                   'file': {
> +                       'filename': filename,
> +                       'driver': 'file'}}
> +        if drive_id:
> +            options['id'] = drive_id
> +        if node_name:
> +            options['node-name'] = node_name
> +        result = self.vm.qmp('blockdev-add', options=options)
> +        self.assert_qmp(result, 'return', {})
> +
>   class TestSingleDrive(ImageMirroringTestCase):
>       image_len = 1 * 1024 * 1024 # MB
> +    qmp_cmd = 'drive-mirror'
> +    qmp_target = target_img
> +    not_found_error = 'DeviceNotFound'
>   
>       def setUp(self):
>           iotests.create_image(backing_img, self.image_len)
> @@ -86,8 +101,8 @@ class TestSingleDrive(ImageMirroringTestCase):
>       def test_complete(self):
>           self.assert_no_active_block_jobs()
>   
> -        result = self.vm.qmp('drive-mirror', device='drive0', sync='full',
> -                             target=target_img)
> +        result = self.vm.qmp(self.qmp_cmd, device='drive0', sync='full',
> +                             target=self.qmp_target)
>           self.assert_qmp(result, 'return', {})
>   
>           self.complete_and_wait()
> @@ -100,8 +115,8 @@ class TestSingleDrive(ImageMirroringTestCase):
>       def test_cancel(self):
>           self.assert_no_active_block_jobs()
>   
> -        result = self.vm.qmp('drive-mirror', device='drive0', sync='full',
> -                             target=target_img)
> +        result = self.vm.qmp(self.qmp_cmd, device='drive0', sync='full',
> +                             target=self.qmp_target)
>           self.assert_qmp(result, 'return', {})
>   
>           self.cancel_and_wait(force=True)
> @@ -112,8 +127,8 @@ class TestSingleDrive(ImageMirroringTestCase):
>       def test_cancel_after_ready(self):
>           self.assert_no_active_block_jobs()
>   
> -        result = self.vm.qmp('drive-mirror', device='drive0', sync='full',
> -                             target=target_img)
> +        result = self.vm.qmp(self.qmp_cmd, device='drive0', sync='full',
> +                             target=self.qmp_target)
>           self.assert_qmp(result, 'return', {})
>   
>           self.wait_ready_and_cancel()
> @@ -126,8 +141,8 @@ class TestSingleDrive(ImageMirroringTestCase):
>       def test_pause(self):
>           self.assert_no_active_block_jobs()
>   
> -        result = self.vm.qmp('drive-mirror', device='drive0', sync='full',
> -                             target=target_img)
> +        result = self.vm.qmp(self.qmp_cmd, device='drive0', sync='full',
> +                             target=self.qmp_target)
>           self.assert_qmp(result, 'return', {})
>   
>           result = self.vm.qmp('block-job-pause', device='drive0')
> @@ -153,8 +168,8 @@ class TestSingleDrive(ImageMirroringTestCase):
>           self.assert_no_active_block_jobs()
>   
>           # A small buffer is rounded up automatically
> -        result = self.vm.qmp('drive-mirror', device='drive0', sync='full',
> -                             buf_size=4096, target=target_img)
> +        result = self.vm.qmp(self.qmp_cmd, device='drive0', sync='full',
> +                             buf_size=4096, target=self.qmp_target)
>           self.assert_qmp(result, 'return', {})
>   
>           self.complete_and_wait()
> @@ -169,8 +184,8 @@ class TestSingleDrive(ImageMirroringTestCase):
>   
>           qemu_img('create', '-f', iotests.imgfmt, '-o', 'cluster_size=%d,size=%d'
>                           % (self.image_len, self.image_len), target_img)
> -        result = self.vm.qmp('drive-mirror', device='drive0', sync='full',
> -                             buf_size=65536, mode='existing', target=target_img)
> +        result = self.vm.qmp(self.qmp_cmd, device='drive0', sync='full',
> +                             buf_size=65536, mode='existing', target=self.qmp_target)
>           self.assert_qmp(result, 'return', {})
>   
>           self.complete_and_wait()
> @@ -185,8 +200,8 @@ class TestSingleDrive(ImageMirroringTestCase):
>   
>           qemu_img('create', '-f', iotests.imgfmt, '-o', 'cluster_size=%d,backing_file=%s'
>                           % (self.image_len, backing_img), target_img)
> -        result = self.vm.qmp('drive-mirror', device='drive0', sync='full',
> -                             mode='existing', target=target_img)
> +        result = self.vm.qmp(self.qmp_cmd, device='drive0', sync='full',
> +                             mode='existing', target=self.qmp_target)
>           self.assert_qmp(result, 'return', {})
>   
>           self.complete_and_wait()
> @@ -197,30 +212,72 @@ class TestSingleDrive(ImageMirroringTestCase):
>                           'target image does not match source after mirroring')
>   
>       def test_medium_not_found(self):
> -        result = self.vm.qmp('drive-mirror', device='ide1-cd0', sync='full',
> -                             target=target_img)
> +        result = self.vm.qmp(self.qmp_cmd, device='ide1-cd0', sync='full',
> +                             target=self.qmp_target)
>           self.assert_qmp(result, 'error/class', 'GenericError')
>   
>       def test_image_not_found(self):
> -        result = self.vm.qmp('drive-mirror', device='drive0', sync='full',
> -                             mode='existing', target=target_img)
> +        result = self.vm.qmp(self.qmp_cmd, device='drive0', sync='full',
> +                             mode='existing', target=self.qmp_target)
>           self.assert_qmp(result, 'error/class', 'GenericError')
>   
>       def test_device_not_found(self):
> -        result = self.vm.qmp('drive-mirror', device='nonexistent', sync='full',
> -                             target=target_img)
> -        self.assert_qmp(result, 'error/class', 'DeviceNotFound')
> +        result = self.vm.qmp(self.qmp_cmd, device='nonexistent', sync='full',
> +                             target=self.qmp_target)
> +        self.assert_qmp(result, 'error/class', self.not_found_error)
> +
> +class TestSingleBlockdev(TestSingleDrive):
> +    qmp_cmd = 'blockdev-mirror'
> +    qmp_target = 'drive1'
> +    not_found_error = 'GenericError'
> +
> +    def setUp(self):
> +        TestSingleDrive.setUp(self)
> +        qemu_img('create', '-f', iotests.imgfmt, '-o', 'backing_file=%s' % backing_img, target_img)
> +        self.blockdev_add(target_img, node_name='drive1')
> +
> +    test_large_cluster = None
> +    test_image_not_found = None
> +    test_small_buffer2 = None
> +
> +class TestBlockdevAttached(ImageMirroringTestCase):
> +    image_len = 1 * 1024 * 1024 # MB
> +
> +    def setUp(self):
> +        iotests.create_image(backing_img, self.image_len)
> +        qemu_img('create', '-f', iotests.imgfmt, '-o', 'backing_file=%s' % backing_img, test_img)
> +        qemu_img('create', '-f', iotests.imgfmt, '-o', 'backing_file=%s' % backing_img, target_img)
> +        self.vm = iotests.VM().add_drive(test_img)
> +        self.vm.launch()
> +
> +    def tearDown(self):
> +        self.vm.shutdown()
> +        os.remove(test_img)
> +        os.remove(target_img)
> +
> +    def test_blockdev_attached(self):
> +        self.assert_no_active_block_jobs()
> +        self.blockdev_add(target_img, drive_id='drive1')
> +        result = self.vm.qmp('blockdev-mirror', device='drive0', sync='full',
> +                             target='drive1')
> +        self.assert_qmp(result, 'error/class', 'GenericError')
>   
>   class TestSingleDriveZeroLength(TestSingleDrive):
>       image_len = 0
>       test_small_buffer2 = None
>       test_large_cluster = None
>   
> +class TestSingleBlockdevZeroLength(TestSingleBlockdev):
> +    image_len = 0
> +
>   class TestSingleDriveUnalignedLength(TestSingleDrive):
>       image_len = 1025 * 1024
>       test_small_buffer2 = None
>       test_large_cluster = None
>   
> +class TestSingleBlockdevUnalignedLength(TestSingleBlockdev):
> +    image_len = 1025 * 1024
> +
>   class TestMirrorNoBacking(ImageMirroringTestCase):
>       image_len = 2 * 1024 * 1024 # MB
>   
> @@ -949,6 +1006,5 @@ class TestRepairQuorum(ImageMirroringTestCase):
>           # TODO: a better test requiring some QEMU infrastructure will be added
>           #       to check that this file is really driven by quorum
>           self.vm.shutdown()
> -

Intentional?

Without this hunk:

Reviewed-by: Max Reitz <mreitz@redhat.com>

>   if __name__ == '__main__':
>       iotests.main(supported_fmts=['qcow2', 'qed'])
> diff --git a/tests/qemu-iotests/041.out b/tests/qemu-iotests/041.out
> index 24093bc..b67d050 100644
> --- a/tests/qemu-iotests/041.out
> +++ b/tests/qemu-iotests/041.out
> @@ -1,5 +1,5 @@
> -......................................................
> +............................................................................
>   ----------------------------------------------------------------------
> -Ran 54 tests
> +Ran 76 tests
>   
>   OK

      reply	other threads:[~2015-06-24 17:10 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-06-09  2:13 [Qemu-devel] [PATCH 0/6] qmp: Add blockdev-mirror Fam Zheng
2015-06-09  2:13 ` [Qemu-devel] [PATCH 1/6] block: Add blocker on mirror target Fam Zheng
2015-06-24 16:14   ` Max Reitz
2015-06-25  2:27     ` Fam Zheng
2015-06-09  2:13 ` [Qemu-devel] [PATCH 2/6] block: Rename BLOCK_OP_TYPE_MIRROR to BLOCK_OP_TYPE_MIRROR_SOURCE Fam Zheng
2015-06-24 16:18   ` Max Reitz
2015-06-09  2:13 ` [Qemu-devel] [PATCH 3/6] block: Extract blockdev part of qmp_drive_mirror Fam Zheng
2015-06-24 16:34   ` Max Reitz
2015-06-25  2:33     ` Fam Zheng
2015-06-09  2:13 ` [Qemu-devel] [PATCH 4/6] block: Add check on mirror target Fam Zheng
2015-06-24 16:40   ` Max Reitz
2015-06-09  2:13 ` [Qemu-devel] [PATCH 5/6] qmp: Add blockdev-mirror command Fam Zheng
2015-06-24 17:05   ` Max Reitz
2015-06-09  2:13 ` [Qemu-devel] [PATCH 6/6] iotests: Add test cases for blockdev-mirror Fam Zheng
2015-06-24 17:10   ` Max Reitz [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=558AE473.1020500@redhat.com \
    --to=mreitz@redhat.com \
    --cc=armbru@redhat.com \
    --cc=famz@redhat.com \
    --cc=jcody@redhat.com \
    --cc=kwolf@redhat.com \
    --cc=pbonzini@redhat.com \
    --cc=qemu-block@nongnu.org \
    --cc=qemu-devel@nongnu.org \
    --cc=stefanha@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.