|
|
9ae3a8 |
From 823ad14cd80063cf09ca5efc2c1d7c584f44a1be Mon Sep 17 00:00:00 2001
|
|
|
9ae3a8 |
From: Fam Zheng <famz@redhat.com>
|
|
|
9ae3a8 |
Date: Fri, 17 Jan 2014 03:08:02 +0100
|
|
|
9ae3a8 |
Subject: [PATCH 19/34] qemu-iotests: Update test cases for commit active
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
RH-Author: Fam Zheng <famz@redhat.com>
|
|
|
9ae3a8 |
Message-id: <1389928083-8921-18-git-send-email-famz@redhat.com>
|
|
|
9ae3a8 |
Patchwork-id: 56779
|
|
|
9ae3a8 |
O-Subject: [RHEL-7 qemu-kvm PATCH 17/18] qemu-iotests: Update test cases for commit active
|
|
|
9ae3a8 |
Bugzilla: 1041301
|
|
|
9ae3a8 |
RH-Acked-by: Jeffrey Cody <jcody@redhat.com>
|
|
|
9ae3a8 |
RH-Acked-by: Kevin Wolf <kwolf@redhat.com>
|
|
|
9ae3a8 |
RH-Acked-by: Stefan Hajnoczi <stefanha@redhat.com>
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
Factor out commit test common logic into super class, and update test
|
|
|
9ae3a8 |
of committing the active image.
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
Signed-off-by: Fam Zheng <famz@redhat.com>
|
|
|
9ae3a8 |
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
|
|
|
9ae3a8 |
(cherry picked from commit 4de43470f2f35762b4b3e6a59b4aed55e239024a)
|
|
|
9ae3a8 |
Signed-off-by: Fam Zheng <famz@redhat.com>
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
Conflicts:
|
|
|
9ae3a8 |
tests/qemu-iotests/040
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
Conflict because "b59b3d5 qemu-iotests: Make test case 030, 040 and 055
|
|
|
9ae3a8 |
deterministic" and "2499a09 qemu-iotests: make create_image() common"
|
|
|
9ae3a8 |
are not backported yet.
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
Signed-off-by: Fam Zheng <famz@redhat.com>
|
|
|
9ae3a8 |
---
|
|
|
9ae3a8 |
tests/qemu-iotests/040 | 74 ++++++++++++++++++++++----------------------------
|
|
|
9ae3a8 |
1 file changed, 32 insertions(+), 42 deletions(-)
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
|
|
|
9ae3a8 |
---
|
|
|
9ae3a8 |
tests/qemu-iotests/040 | 74 ++++++++++++++++++++---------------------------
|
|
|
9ae3a8 |
1 files changed, 32 insertions(+), 42 deletions(-)
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
diff --git a/tests/qemu-iotests/040 b/tests/qemu-iotests/040
|
|
|
9ae3a8 |
index aad535a..f210fb7 100755
|
|
|
9ae3a8 |
--- a/tests/qemu-iotests/040
|
|
|
9ae3a8 |
+++ b/tests/qemu-iotests/040
|
|
|
9ae3a8 |
@@ -63,6 +63,28 @@ class ImageCommitTestCase(iotests.QMPTestCase):
|
|
|
9ae3a8 |
i = i + 512
|
|
|
9ae3a8 |
file.close()
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
+ def run_commit_test(self, top, base):
|
|
|
9ae3a8 |
+ self.assert_no_active_commit()
|
|
|
9ae3a8 |
+ result = self.vm.qmp('block-commit', device='drive0', top=top, base=base)
|
|
|
9ae3a8 |
+ self.assert_qmp(result, 'return', {})
|
|
|
9ae3a8 |
+
|
|
|
9ae3a8 |
+ completed = False
|
|
|
9ae3a8 |
+ while not completed:
|
|
|
9ae3a8 |
+ for event in self.vm.get_qmp_events(wait=True):
|
|
|
9ae3a8 |
+ if event['event'] == 'BLOCK_JOB_COMPLETED':
|
|
|
9ae3a8 |
+ self.assert_qmp(event, 'data/type', 'commit')
|
|
|
9ae3a8 |
+ self.assert_qmp(event, 'data/device', 'drive0')
|
|
|
9ae3a8 |
+ self.assert_qmp(event, 'data/offset', self.image_len)
|
|
|
9ae3a8 |
+ self.assert_qmp(event, 'data/len', self.image_len)
|
|
|
9ae3a8 |
+ completed = True
|
|
|
9ae3a8 |
+ elif event['event'] == 'BLOCK_JOB_READY':
|
|
|
9ae3a8 |
+ self.assert_qmp(event, 'data/type', 'commit')
|
|
|
9ae3a8 |
+ self.assert_qmp(event, 'data/device', 'drive0')
|
|
|
9ae3a8 |
+ self.assert_qmp(event, 'data/len', self.image_len)
|
|
|
9ae3a8 |
+ self.vm.qmp('block-job-complete', device='drive0')
|
|
|
9ae3a8 |
+
|
|
|
9ae3a8 |
+ self.assert_no_active_commit()
|
|
|
9ae3a8 |
+ self.vm.shutdown()
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
class TestSingleDrive(ImageCommitTestCase):
|
|
|
9ae3a8 |
image_len = 1 * 1024 * 1024
|
|
|
9ae3a8 |
@@ -84,23 +106,7 @@ class TestSingleDrive(ImageCommitTestCase):
|
|
|
9ae3a8 |
os.remove(backing_img)
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
def test_commit(self):
|
|
|
9ae3a8 |
- self.assert_no_active_commit()
|
|
|
9ae3a8 |
- result = self.vm.qmp('block-commit', device='drive0', top='%s' % mid_img)
|
|
|
9ae3a8 |
- self.assert_qmp(result, 'return', {})
|
|
|
9ae3a8 |
-
|
|
|
9ae3a8 |
- completed = False
|
|
|
9ae3a8 |
- while not completed:
|
|
|
9ae3a8 |
- for event in self.vm.get_qmp_events(wait=True):
|
|
|
9ae3a8 |
- if event['event'] == 'BLOCK_JOB_COMPLETED':
|
|
|
9ae3a8 |
- self.assert_qmp(event, 'data/type', 'commit')
|
|
|
9ae3a8 |
- self.assert_qmp(event, 'data/device', 'drive0')
|
|
|
9ae3a8 |
- self.assert_qmp(event, 'data/offset', self.image_len)
|
|
|
9ae3a8 |
- self.assert_qmp(event, 'data/len', self.image_len)
|
|
|
9ae3a8 |
- completed = True
|
|
|
9ae3a8 |
-
|
|
|
9ae3a8 |
- self.assert_no_active_commit()
|
|
|
9ae3a8 |
- self.vm.shutdown()
|
|
|
9ae3a8 |
-
|
|
|
9ae3a8 |
+ self.run_commit_test(mid_img, backing_img)
|
|
|
9ae3a8 |
self.assertEqual(-1, qemu_io('-c', 'read -P 0xab 0 524288', backing_img).find("verification failed"))
|
|
|
9ae3a8 |
self.assertEqual(-1, qemu_io('-c', 'read -P 0xef 524288 524288', backing_img).find("verification failed"))
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
@@ -127,10 +133,9 @@ class TestSingleDrive(ImageCommitTestCase):
|
|
|
9ae3a8 |
self.assert_qmp(result, 'error/desc', 'Base \'badfile\' not found')
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
def test_top_is_active(self):
|
|
|
9ae3a8 |
- self.assert_no_active_commit()
|
|
|
9ae3a8 |
- result = self.vm.qmp('block-commit', device='drive0', top='%s' % test_img, base='%s' % backing_img)
|
|
|
9ae3a8 |
- self.assert_qmp(result, 'error/class', 'GenericError')
|
|
|
9ae3a8 |
- self.assert_qmp(result, 'error/desc', 'Top image as the active layer is currently unsupported')
|
|
|
9ae3a8 |
+ self.run_commit_test(test_img, backing_img)
|
|
|
9ae3a8 |
+ self.assertEqual(-1, qemu_io('-c', 'read -P 0xab 0 524288', backing_img).find("verification failed"))
|
|
|
9ae3a8 |
+ self.assertEqual(-1, qemu_io('-c', 'read -P 0xef 524288 524288', backing_img).find("verification failed"))
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
def test_top_and_base_reversed(self):
|
|
|
9ae3a8 |
self.assert_no_active_commit()
|
|
|
9ae3a8 |
@@ -191,23 +196,7 @@ class TestRelativePaths(ImageCommitTestCase):
|
|
|
9ae3a8 |
raise
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
def test_commit(self):
|
|
|
9ae3a8 |
- self.assert_no_active_commit()
|
|
|
9ae3a8 |
- result = self.vm.qmp('block-commit', device='drive0', top='%s' % self.mid_img)
|
|
|
9ae3a8 |
- self.assert_qmp(result, 'return', {})
|
|
|
9ae3a8 |
-
|
|
|
9ae3a8 |
- completed = False
|
|
|
9ae3a8 |
- while not completed:
|
|
|
9ae3a8 |
- for event in self.vm.get_qmp_events(wait=True):
|
|
|
9ae3a8 |
- if event['event'] == 'BLOCK_JOB_COMPLETED':
|
|
|
9ae3a8 |
- self.assert_qmp(event, 'data/type', 'commit')
|
|
|
9ae3a8 |
- self.assert_qmp(event, 'data/device', 'drive0')
|
|
|
9ae3a8 |
- self.assert_qmp(event, 'data/offset', self.image_len)
|
|
|
9ae3a8 |
- self.assert_qmp(event, 'data/len', self.image_len)
|
|
|
9ae3a8 |
- completed = True
|
|
|
9ae3a8 |
-
|
|
|
9ae3a8 |
- self.assert_no_active_commit()
|
|
|
9ae3a8 |
- self.vm.shutdown()
|
|
|
9ae3a8 |
-
|
|
|
9ae3a8 |
+ self.run_commit_test(self.mid_img, self.backing_img)
|
|
|
9ae3a8 |
self.assertEqual(-1, qemu_io('-c', 'read -P 0xab 0 524288', self.backing_img_abs).find("verification failed"))
|
|
|
9ae3a8 |
self.assertEqual(-1, qemu_io('-c', 'read -P 0xef 524288 524288', self.backing_img_abs).find("verification failed"))
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
@@ -234,10 +223,9 @@ class TestRelativePaths(ImageCommitTestCase):
|
|
|
9ae3a8 |
self.assert_qmp(result, 'error/desc', 'Base \'badfile\' not found')
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
def test_top_is_active(self):
|
|
|
9ae3a8 |
- self.assert_no_active_commit()
|
|
|
9ae3a8 |
- result = self.vm.qmp('block-commit', device='drive0', top='%s' % self.test_img, base='%s' % self.backing_img)
|
|
|
9ae3a8 |
- self.assert_qmp(result, 'error/class', 'GenericError')
|
|
|
9ae3a8 |
- self.assert_qmp(result, 'error/desc', 'Top image as the active layer is currently unsupported')
|
|
|
9ae3a8 |
+ self.run_commit_test(self.test_img, self.backing_img)
|
|
|
9ae3a8 |
+ self.assertEqual(-1, qemu_io('-c', 'read -P 0xab 0 524288', self.backing_img_abs).find("verification failed"))
|
|
|
9ae3a8 |
+ self.assertEqual(-1, qemu_io('-c', 'read -P 0xef 524288 524288', self.backing_img_abs).find("verification failed"))
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
def test_top_and_base_reversed(self):
|
|
|
9ae3a8 |
self.assert_no_active_commit()
|
|
|
9ae3a8 |
@@ -253,6 +241,8 @@ class TestSetSpeed(ImageCommitTestCase):
|
|
|
9ae3a8 |
qemu_img('create', backing_img, str(TestSetSpeed.image_len))
|
|
|
9ae3a8 |
qemu_img('create', '-f', iotests.imgfmt, '-o', 'backing_file=%s' % backing_img, mid_img)
|
|
|
9ae3a8 |
qemu_img('create', '-f', iotests.imgfmt, '-o', 'backing_file=%s' % mid_img, test_img)
|
|
|
9ae3a8 |
+ qemu_io('-c', 'write -P 0x1 0 512', test_img)
|
|
|
9ae3a8 |
+ qemu_io('-c', 'write -P 0xef 524288 524288', mid_img)
|
|
|
9ae3a8 |
self.vm = iotests.VM().add_drive(test_img)
|
|
|
9ae3a8 |
self.vm.launch()
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
--
|
|
|
9ae3a8 |
1.7.1
|
|
|
9ae3a8 |
|