diff mbox

[11/11] qemu-iotests: test overlapping block-stream operations

Message ID 0faf3d82dca9bf334d99f761e84874cb36fa466b.1431523498.git.berto@igalia.com
State New
Headers show

Commit Message

Alberto Garcia May 13, 2015, 1:27 p.m. UTC
This test case checks that it's not possible to perform two
block-stream operations if there are nodes involved in both.

Signed-off-by: Alberto Garcia <berto@igalia.com>
Reviewed-by: Max Reitz <mreitz@redhat.com>
---
 tests/qemu-iotests/030     | 27 +++++++++++++++++++++++++++
 tests/qemu-iotests/030.out |  4 ++--
 2 files changed, 29 insertions(+), 2 deletions(-)

Comments

Fam Zheng May 15, 2015, 2:56 a.m. UTC | #1
On Wed, 05/13 16:27, Alberto Garcia wrote:
> This test case checks that it's not possible to perform two
> block-stream operations if there are nodes involved in both.
> 
> Signed-off-by: Alberto Garcia <berto@igalia.com>
> Reviewed-by: Max Reitz <mreitz@redhat.com>
> ---
>  tests/qemu-iotests/030     | 27 +++++++++++++++++++++++++++
>  tests/qemu-iotests/030.out |  4 ++--
>  2 files changed, 29 insertions(+), 2 deletions(-)
> 
> diff --git a/tests/qemu-iotests/030 b/tests/qemu-iotests/030
> index c199cef..f898c92 100755
> --- a/tests/qemu-iotests/030
> +++ b/tests/qemu-iotests/030
> @@ -225,6 +225,33 @@ class TestParallelOps(iotests.QMPTestCase):
>                               qemu_io('-f', iotests.imgfmt, '-c', 'map', self.imgs[i-1]),
>                               'image file map does not match backing file after streaming')
>  
> +    # Test that it's not possible to perform two block-stream
> +    # operations if there are nodes involved in both.
> +    def test_stream_overlapping(self):
> +        self.assert_no_active_block_jobs()
> +
> +        # Set a speed limit to make sure that this job blocks the rest
> +        result = self.vm.qmp('block-stream', device='node4', base=self.imgs[0], speed=32768)
> +        self.assert_qmp(result, 'return', {})
> +
> +        result = self.vm.qmp('block-stream', device='node5', base=self.imgs[1])
> +        self.assert_qmp(result, 'error/class', 'GenericError')
> +
> +        result = self.vm.qmp('block-stream', device='node3', base=self.imgs[2])
> +        self.assert_qmp(result, 'error/class', 'GenericError')
> +
> +        result = self.vm.qmp('block-stream', device='node4')
> +        self.assert_qmp(result, 'error/class', 'GenericError')
> +
> +        # If node4 is the active node, the id of the block job is drive0
> +        if self.num_imgs == 5:

Isn't self.num_imgs a constant (9) ?

Fam

> +            self.wait_until_completed(drive='drive0')
> +        else:
> +            self.wait_until_completed(drive='node4')
> +        self.assert_no_active_block_jobs()
> +
> +        self.vm.shutdown()
> +
>  class TestSmallerBackingFile(iotests.QMPTestCase):
>      backing_len = 1 * 1024 * 1024 # MB
>      image_len = 2 * backing_len
> diff --git a/tests/qemu-iotests/030.out b/tests/qemu-iotests/030.out
> index b6f2576..52d796e 100644
> --- a/tests/qemu-iotests/030.out
> +++ b/tests/qemu-iotests/030.out
> @@ -1,5 +1,5 @@
> -................
> +.................
>  ----------------------------------------------------------------------
> -Ran 16 tests
> +Ran 17 tests
>  
>  OK
> -- 
> 2.1.4
> 
>
Alberto Garcia May 15, 2015, 8:58 a.m. UTC | #2
On Fri 15 May 2015 04:56:09 AM CEST, Fam Zheng wrote:

>> +        # If node4 is the active node, the id of the block job is drive0
>> +        if self.num_imgs == 5:
>
> Isn't self.num_imgs a constant (9) ?

Yes, but the number is arbitrary. The idea is to let users change it if
they want to, so the test case must be prepared for that.

Berto
Fam Zheng May 15, 2015, 9:18 a.m. UTC | #3
On Fri, 05/15 10:58, Alberto Garcia wrote:
> On Fri 15 May 2015 04:56:09 AM CEST, Fam Zheng wrote:
> 
> >> +        # If node4 is the active node, the id of the block job is drive0
> >> +        if self.num_imgs == 5:
> >
> > Isn't self.num_imgs a constant (9) ?
> 
> Yes, but the number is arbitrary. The idea is to let users change it if
> they want to, so the test case must be prepared for that.
> 

They have to change the code to get a different value, no? This is unreachable
code as is and IMO even if you're not as considerate on this, whoever changes
num_ops should make sure code that uses it still works. This is bikeshedding,
this is a great series, so even if you insist,

Reviewed-by: Fam Zheng <famz@redhat.com>
diff mbox

Patch

diff --git a/tests/qemu-iotests/030 b/tests/qemu-iotests/030
index c199cef..f898c92 100755
--- a/tests/qemu-iotests/030
+++ b/tests/qemu-iotests/030
@@ -225,6 +225,33 @@  class TestParallelOps(iotests.QMPTestCase):
                              qemu_io('-f', iotests.imgfmt, '-c', 'map', self.imgs[i-1]),
                              'image file map does not match backing file after streaming')
 
+    # Test that it's not possible to perform two block-stream
+    # operations if there are nodes involved in both.
+    def test_stream_overlapping(self):
+        self.assert_no_active_block_jobs()
+
+        # Set a speed limit to make sure that this job blocks the rest
+        result = self.vm.qmp('block-stream', device='node4', base=self.imgs[0], speed=32768)
+        self.assert_qmp(result, 'return', {})
+
+        result = self.vm.qmp('block-stream', device='node5', base=self.imgs[1])
+        self.assert_qmp(result, 'error/class', 'GenericError')
+
+        result = self.vm.qmp('block-stream', device='node3', base=self.imgs[2])
+        self.assert_qmp(result, 'error/class', 'GenericError')
+
+        result = self.vm.qmp('block-stream', device='node4')
+        self.assert_qmp(result, 'error/class', 'GenericError')
+
+        # If node4 is the active node, the id of the block job is drive0
+        if self.num_imgs == 5:
+            self.wait_until_completed(drive='drive0')
+        else:
+            self.wait_until_completed(drive='node4')
+        self.assert_no_active_block_jobs()
+
+        self.vm.shutdown()
+
 class TestSmallerBackingFile(iotests.QMPTestCase):
     backing_len = 1 * 1024 * 1024 # MB
     image_len = 2 * backing_len
diff --git a/tests/qemu-iotests/030.out b/tests/qemu-iotests/030.out
index b6f2576..52d796e 100644
--- a/tests/qemu-iotests/030.out
+++ b/tests/qemu-iotests/030.out
@@ -1,5 +1,5 @@ 
-................
+.................
 ----------------------------------------------------------------------
-Ran 16 tests
+Ran 17 tests
 
 OK