aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorFam Zheng <famz@redhat.com>2013-11-20 10:01:56 +0800
committerKevin Wolf <kwolf@redhat.com>2013-11-29 13:40:37 +0100
commitb59b3d57737a0d40450f8232abd89e8986387402 (patch)
tree74fb1ebaa4d95c0e5c3cbab2aaad04e8d5f7259b /tests
parent3cf53c771406ad360117f30e61b24635df0e9b50 (diff)
qemu-iotests: Make test case 030, 040 and 055 deterministic
Pause the drive and start the block job, so we won't miss the block job. Signed-off-by: Fam Zheng <famz@redhat.com> Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
Diffstat (limited to 'tests')
-rwxr-xr-xtests/qemu-iotests/03016
-rwxr-xr-xtests/qemu-iotests/0404
-rwxr-xr-xtests/qemu-iotests/05514
3 files changed, 25 insertions, 9 deletions
diff --git a/tests/qemu-iotests/030 b/tests/qemu-iotests/030
index d0f96ea0e1..59a34f76f5 100755
--- a/tests/qemu-iotests/030
+++ b/tests/qemu-iotests/030
@@ -34,6 +34,7 @@ class TestSingleDrive(iotests.QMPTestCase):
iotests.create_image(backing_img, TestSingleDrive.image_len)
qemu_img('create', '-f', iotests.imgfmt, '-o', 'backing_file=%s' % backing_img, mid_img)
qemu_img('create', '-f', iotests.imgfmt, '-o', 'backing_file=%s' % mid_img, test_img)
+ qemu_io('-c', 'write -P 0x1 0 512', backing_img)
self.vm = iotests.VM().add_drive(test_img)
self.vm.launch()
@@ -69,6 +70,7 @@ class TestSingleDrive(iotests.QMPTestCase):
def test_stream_pause(self):
self.assert_no_active_block_jobs()
+ self.vm.pause_drive('drive0')
result = self.vm.qmp('block-stream', device='drive0')
self.assert_qmp(result, 'return', {})
@@ -86,6 +88,7 @@ class TestSingleDrive(iotests.QMPTestCase):
result = self.vm.qmp('block-job-resume', device='drive0')
self.assert_qmp(result, 'return', {})
+ self.vm.resume_drive('drive0')
completed = False
while not completed:
for event in self.vm.get_qmp_events(wait=True):
@@ -391,7 +394,7 @@ class TestStreamStop(iotests.QMPTestCase):
qemu_io('-c', 'write -P 0x1 0 32M', backing_img)
qemu_img('create', '-f', iotests.imgfmt, '-o', 'backing_file=%s' % backing_img, test_img)
qemu_io('-c', 'write -P 0x1 32M 32M', test_img)
- self.vm = iotests.VM().add_drive(test_img)
+ self.vm = iotests.VM().add_drive("blkdebug::" + test_img)
self.vm.launch()
def tearDown(self):
@@ -402,6 +405,7 @@ class TestStreamStop(iotests.QMPTestCase):
def test_stream_stop(self):
self.assert_no_active_block_jobs()
+ self.vm.pause_drive('drive0')
result = self.vm.qmp('block-stream', device='drive0')
self.assert_qmp(result, 'return', {})
@@ -409,7 +413,7 @@ class TestStreamStop(iotests.QMPTestCase):
events = self.vm.get_qmp_events(wait=False)
self.assertEqual(events, [], 'unexpected QMP event: %s' % events)
- self.cancel_and_wait()
+ self.cancel_and_wait(resume=True)
class TestSetSpeed(iotests.QMPTestCase):
image_len = 80 * 1024 * 1024 # MB
@@ -419,7 +423,7 @@ class TestSetSpeed(iotests.QMPTestCase):
qemu_io('-c', 'write -P 0x1 0 32M', backing_img)
qemu_img('create', '-f', iotests.imgfmt, '-o', 'backing_file=%s' % backing_img, test_img)
qemu_io('-c', 'write -P 0x1 32M 32M', test_img)
- self.vm = iotests.VM().add_drive(test_img)
+ self.vm = iotests.VM().add_drive('blkdebug::' + test_img)
self.vm.launch()
def tearDown(self):
@@ -453,6 +457,7 @@ class TestSetSpeed(iotests.QMPTestCase):
def test_set_speed(self):
self.assert_no_active_block_jobs()
+ self.vm.pause_drive('drive0')
result = self.vm.qmp('block-stream', device='drive0')
self.assert_qmp(result, 'return', {})
@@ -469,7 +474,8 @@ class TestSetSpeed(iotests.QMPTestCase):
self.assert_qmp(result, 'return[0]/device', 'drive0')
self.assert_qmp(result, 'return[0]/speed', 8 * 1024 * 1024)
- self.cancel_and_wait()
+ self.cancel_and_wait(resume=True)
+ self.vm.pause_drive('drive0')
# Check setting speed in block-stream works
result = self.vm.qmp('block-stream', device='drive0', speed=4 * 1024 * 1024)
@@ -479,7 +485,7 @@ class TestSetSpeed(iotests.QMPTestCase):
self.assert_qmp(result, 'return[0]/device', 'drive0')
self.assert_qmp(result, 'return[0]/speed', 4 * 1024 * 1024)
- self.cancel_and_wait()
+ self.cancel_and_wait(resume=True)
def test_set_speed_invalid(self):
self.assert_no_active_block_jobs()
diff --git a/tests/qemu-iotests/040 b/tests/qemu-iotests/040
index 0e85136ae6..18dcd61ef2 100755
--- a/tests/qemu-iotests/040
+++ b/tests/qemu-iotests/040
@@ -228,6 +228,7 @@ class TestSetSpeed(ImageCommitTestCase):
qemu_img('create', backing_img, str(TestSetSpeed.image_len))
qemu_img('create', '-f', iotests.imgfmt, '-o', 'backing_file=%s' % backing_img, mid_img)
qemu_img('create', '-f', iotests.imgfmt, '-o', 'backing_file=%s' % mid_img, test_img)
+ qemu_io('-c', 'write -P 0x1 0 512', test_img)
self.vm = iotests.VM().add_drive(test_img)
self.vm.launch()
@@ -240,6 +241,7 @@ class TestSetSpeed(ImageCommitTestCase):
def test_set_speed(self):
self.assert_no_active_commit()
+ self.vm.pause_drive('drive0')
result = self.vm.qmp('block-commit', device='drive0', top=mid_img, speed=1024 * 1024)
self.assert_qmp(result, 'return', {})
@@ -248,7 +250,7 @@ class TestSetSpeed(ImageCommitTestCase):
self.assert_qmp(result, 'return[0]/device', 'drive0')
self.assert_qmp(result, 'return[0]/speed', 1024 * 1024)
- self.cancel_and_wait()
+ self.cancel_and_wait(resume=True)
if __name__ == '__main__':
diff --git a/tests/qemu-iotests/055 b/tests/qemu-iotests/055
index 44bb025687..451b67ddfb 100755
--- a/tests/qemu-iotests/055
+++ b/tests/qemu-iotests/055
@@ -63,6 +63,7 @@ class TestSingleDrive(iotests.QMPTestCase):
def test_pause(self):
self.assert_no_active_block_jobs()
+ self.vm.pause_drive('drive0')
result = self.vm.qmp('drive-backup', device='drive0',
target=target_img, sync='full')
self.assert_qmp(result, 'return', {})
@@ -70,6 +71,7 @@ class TestSingleDrive(iotests.QMPTestCase):
result = self.vm.qmp('block-job-pause', device='drive0')
self.assert_qmp(result, 'return', {})
+ self.vm.resume_drive('drive0')
time.sleep(1)
result = self.vm.qmp('query-block-jobs')
offset = self.dictpath(result, 'return[0]/offset')
@@ -113,6 +115,7 @@ class TestSetSpeed(iotests.QMPTestCase):
def setUp(self):
qemu_img('create', '-f', iotests.imgfmt, test_img, str(TestSetSpeed.image_len))
+ qemu_io('-c', 'write -P1 0 512', test_img)
self.vm = iotests.VM().add_drive(test_img)
self.vm.launch()
@@ -124,6 +127,7 @@ class TestSetSpeed(iotests.QMPTestCase):
def test_set_speed(self):
self.assert_no_active_block_jobs()
+ self.vm.pause_drive('drive0')
result = self.vm.qmp('drive-backup', device='drive0',
target=target_img, sync='full')
self.assert_qmp(result, 'return', {})
@@ -141,10 +145,11 @@ class TestSetSpeed(iotests.QMPTestCase):
self.assert_qmp(result, 'return[0]/device', 'drive0')
self.assert_qmp(result, 'return[0]/speed', 8 * 1024 * 1024)
- event = self.cancel_and_wait()
+ event = self.cancel_and_wait(resume=True)
self.assert_qmp(event, 'data/type', 'backup')
# Check setting speed in drive-backup works
+ self.vm.pause_drive('drive0')
result = self.vm.qmp('drive-backup', device='drive0',
target=target_img, sync='full', speed=4*1024*1024)
self.assert_qmp(result, 'return', {})
@@ -153,7 +158,7 @@ class TestSetSpeed(iotests.QMPTestCase):
self.assert_qmp(result, 'return[0]/device', 'drive0')
self.assert_qmp(result, 'return[0]/speed', 4 * 1024 * 1024)
- event = self.cancel_and_wait()
+ event = self.cancel_and_wait(resume=True)
self.assert_qmp(event, 'data/type', 'backup')
def test_set_speed_invalid(self):
@@ -165,6 +170,7 @@ class TestSetSpeed(iotests.QMPTestCase):
self.assert_no_active_block_jobs()
+ self.vm.pause_drive('drive0')
result = self.vm.qmp('drive-backup', device='drive0',
target=target_img, sync='full')
self.assert_qmp(result, 'return', {})
@@ -172,7 +178,7 @@ class TestSetSpeed(iotests.QMPTestCase):
result = self.vm.qmp('block-job-set-speed', device='drive0', speed=-1)
self.assert_qmp(result, 'error/class', 'GenericError')
- event = self.cancel_and_wait()
+ event = self.cancel_and_wait(resume=True)
self.assert_qmp(event, 'data/type', 'backup')
class TestSingleTransaction(iotests.QMPTestCase):
@@ -214,6 +220,7 @@ class TestSingleTransaction(iotests.QMPTestCase):
def test_pause(self):
self.assert_no_active_block_jobs()
+ self.vm.pause_drive('drive0')
result = self.vm.qmp('transaction', actions=[{
'type': 'drive-backup',
'data': { 'device': 'drive0',
@@ -226,6 +233,7 @@ class TestSingleTransaction(iotests.QMPTestCase):
result = self.vm.qmp('block-job-pause', device='drive0')
self.assert_qmp(result, 'return', {})
+ self.vm.resume_drive('drive0')
time.sleep(1)
result = self.vm.qmp('query-block-jobs')
offset = self.dictpath(result, 'return[0]/offset')