[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-block] [PATCH v11 13/19] qemu-iotests: Test block-stream operation
From: |
Alberto Garcia |
Subject: |
[Qemu-block] [PATCH v11 13/19] qemu-iotests: Test block-stream operations in parallel |
Date: |
Fri, 14 Oct 2016 16:08:25 +0300 |
This test case checks that it's possible to launch several stream
operations in parallel in the same snapshot chain, each one involving
a different set of nodes.
Signed-off-by: Alberto Garcia <address@hidden>
---
tests/qemu-iotests/030 | 80 ++++++++++++++++++++++++++++++++++++++++++++++
tests/qemu-iotests/030.out | 4 +--
2 files changed, 82 insertions(+), 2 deletions(-)
diff --git a/tests/qemu-iotests/030 b/tests/qemu-iotests/030
index 367ecf8..e487473 100755
--- a/tests/qemu-iotests/030
+++ b/tests/qemu-iotests/030
@@ -148,6 +148,86 @@ class TestSingleDrive(iotests.QMPTestCase):
self.assert_qmp(result, 'error/class', 'GenericError')
+class TestParallelOps(iotests.QMPTestCase):
+ num_ops = 4 # Number of parallel block-stream operations
+ num_imgs = num_ops * 2 + 1
+ image_len = num_ops * 1024 * 1024
+ imgs = []
+
+ def setUp(self):
+ opts = []
+ self.imgs = []
+
+ # Initialize file names and command-line options
+ for i in range(self.num_imgs):
+ img_depth = self.num_imgs - i - 1
+ opts.append("backing." * img_depth + "node-name=node%d" % i)
+ self.imgs.append(os.path.join(iotests.test_dir, 'img-%d.img' % i))
+
+ # Create all images
+ iotests.create_image(self.imgs[0], self.image_len)
+ for i in range(1, self.num_imgs):
+ qemu_img('create', '-f', iotests.imgfmt,
+ '-o', 'backing_file=%s' % self.imgs[i-1], self.imgs[i])
+
+ # Put data into the images we are copying data from
+ for i in range(self.num_imgs / 2):
+ img_index = i * 2 + 1
+ # Alternate between 512k and 1M.
+ # This way jobs will not finish in the same order they were created
+ num_kb = 512 + 512 * (i % 2)
+ qemu_io('-f', iotests.imgfmt,
+ '-c', 'write -P %d %d %d' % (i, i*1024*1024, num_kb *
1024),
+ self.imgs[img_index])
+
+ # Attach the drive to the VM
+ self.vm = iotests.VM()
+ self.vm.add_drive(self.imgs[-1], ','.join(opts))
+ self.vm.launch()
+
+ def tearDown(self):
+ self.vm.shutdown()
+ for img in self.imgs:
+ os.remove(img)
+
+ # Test that it's possible to run several block-stream operations
+ # in parallel in the same snapshot chain
+ def test_stream_parallel(self):
+ self.assert_no_active_block_jobs()
+
+ # Check that the maps don't match before the streaming operations
+ for i in range(2, self.num_imgs, 2):
+ self.assertNotEqual(qemu_io('-f', iotests.imgfmt, '-c', 'map',
self.imgs[i]),
+ qemu_io('-f', iotests.imgfmt, '-c', 'map',
self.imgs[i-1]),
+ 'image file map matches backing file before
streaming')
+
+ # Create all streaming jobs
+ pending_jobs = []
+ for i in range(2, self.num_imgs, 2):
+ node_name = 'node%d' % i
+ job_id = 'stream-%s' % node_name
+ pending_jobs.append(job_id)
+ result = self.vm.qmp('block-stream', device=node_name,
job_id=job_id, base=self.imgs[i-2], speed=512*1024)
+ self.assert_qmp(result, 'return', {})
+
+ # Wait for all jobs to be finished.
+ while len(pending_jobs) > 0:
+ for event in self.vm.get_qmp_events(wait=True):
+ if event['event'] == 'BLOCK_JOB_COMPLETED':
+ job_id = self.dictpath(event, 'data/device')
+ self.assertTrue(job_id in pending_jobs)
+ self.assert_qmp_absent(event, 'data/error')
+ pending_jobs.remove(job_id)
+
+ self.assert_no_active_block_jobs()
+ self.vm.shutdown()
+
+ # Check that all maps match now
+ for i in range(2, self.num_imgs, 2):
+ self.assertEqual(qemu_io('-f', iotests.imgfmt, '-c', 'map',
self.imgs[i]),
+ qemu_io('-f', iotests.imgfmt, '-c', 'map',
self.imgs[i-1]),
+ 'image file map does not match backing file after
streaming')
+
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 96961ed..b6f2576 100644
--- a/tests/qemu-iotests/030.out
+++ b/tests/qemu-iotests/030.out
@@ -1,5 +1,5 @@
-...............
+................
----------------------------------------------------------------------
-Ran 15 tests
+Ran 16 tests
OK
--
2.9.3
[Qemu-block] [PATCH v11 12/19] qemu-iotests: Test streaming to an intermediate layer, Alberto Garcia, 2016/10/14
[Qemu-block] [PATCH v11 19/19] qemu-iotests: Test the 'base-node' parameter of 'block-stream', Alberto Garcia, 2016/10/14
[Qemu-block] [PATCH v11 18/19] block: Add 'base-node' parameter to the 'block-stream' command, Alberto Garcia, 2016/10/14
[Qemu-block] [PATCH v11 08/19] block: Block all intermediate nodes in commit_active_start(), Alberto Garcia, 2016/10/14
[Qemu-block] [PATCH v11 14/19] qemu-iotests: Test overlapping stream and commit operations, Alberto Garcia, 2016/10/14
[Qemu-block] [PATCH v11 05/19] block: Use block_job_add_bdrv() in backup_start(), Alberto Garcia, 2016/10/14
[Qemu-block] [PATCH v11 13/19] qemu-iotests: Test block-stream operations in parallel,
Alberto Garcia <=
[Qemu-block] [PATCH v11 07/19] block: Block all nodes involved in the block-commit operation, Alberto Garcia, 2016/10/14
[Qemu-block] [PATCH v11 03/19] block: Add block_job_add_bdrv(), Alberto Garcia, 2016/10/14
[Qemu-block] [PATCH v11 06/19] block: Check blockers in all nodes involved in a block-commit job, Alberto Garcia, 2016/10/14
[Qemu-block] [PATCH v11 16/19] qemu-iotests: Add iotests.supports_quorum(), Alberto Garcia, 2016/10/14
[Qemu-block] [PATCH v11 04/19] block: Use block_job_add_bdrv() in mirror_start_job(), Alberto Garcia, 2016/10/14
[Qemu-block] [PATCH v11 11/19] docs: Document how to stream to an intermediate layer, Alberto Garcia, 2016/10/14
[Qemu-block] [PATCH v11 10/19] block: Add QMP support for streaming to an intermediate layer, Alberto Garcia, 2016/10/14
[Qemu-block] [PATCH v11 15/19] qemu-iotests: Test block-stream and block-commit in parallel, Alberto Garcia, 2016/10/14
[Qemu-block] [PATCH v11 09/19] block: Support streaming to an intermediate layer, Alberto Garcia, 2016/10/14
[Qemu-block] [PATCH v11 17/19] qemu-iotests: Test streaming to a Quorum child, Alberto Garcia, 2016/10/14