From e43a3de368395691cf91d39be7ba63e3cc723013 Mon Sep 17 00:00:00 2001 From: Kevin Wolf Date: Thu, 31 Jul 2014 16:03:42 -0500 Subject: [CHANGE 20/31] qemu-iotests: Backport 030 To: rhvirt-patches@redhat.com, jen@redhat.com RH-Author: Kevin Wolf Message-id: <1406822631-6570-21-git-send-email-kwolf@redhat.com> Patchwork-id: 60377 O-Subject: [RHEL-6.6 qemu-kvm PATCH v3 20/29] qemu-iotests: Backport 030 Bugzilla: 1122410 RH-Acked-by: Stefan Hajnoczi RH-Acked-by: Jeffrey Cody RH-Acked-by: Max Reitz The tests needs the following adjustments for RHEL 6: * blkdebug doesn't work without a config file, using /dev/null. * Block jobs cannot be paused and don't support on-error. Remove test cases that require these features. * qemu uses specific errors instead of GenericError (and no, they don't always make sense) Signed-off-by: Kevin Wolf Signed-off-by: jen --- tests/qemu-iotests/030 | 289 +-------------------------------------------- tests/qemu-iotests/030.out | 4 +- 2 files changed, 6 insertions(+), 287 deletions(-) diff --git a/tests/qemu-iotests/030 b/tests/qemu-iotests/030 index 8ce2373..f09de9f 100755 --- a/tests/qemu-iotests/030 +++ b/tests/qemu-iotests/030 @@ -35,7 +35,7 @@ class TestSingleDrive(iotests.QMPTestCase): 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("blkdebug::" + test_img) + self.vm = iotests.VM().add_drive("blkdebug:/dev/null:" + test_img) self.vm.launch() def tearDown(self): @@ -59,37 +59,6 @@ class TestSingleDrive(iotests.QMPTestCase): qemu_io('-c', 'map', test_img), 'image file map does not match backing file after streaming') - 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', {}) - - result = self.vm.qmp('block-job-pause', device='drive0') - self.assert_qmp(result, 'return', {}) - - time.sleep(1) - result = self.vm.qmp('query-block-jobs') - offset = self.dictpath(result, 'return[0]/offset') - - time.sleep(1) - result = self.vm.qmp('query-block-jobs') - self.assert_qmp(result, 'return[0]/offset', offset) - - result = self.vm.qmp('block-job-resume', device='drive0') - self.assert_qmp(result, 'return', {}) - - self.vm.resume_drive('drive0') - self.wait_until_completed() - - self.assert_no_active_block_jobs() - self.vm.shutdown() - - self.assertEqual(qemu_io('-c', 'map', backing_img), - qemu_io('-c', 'map', test_img), - 'image file map does not match backing file after streaming') - def test_stream_partial(self): self.assert_no_active_block_jobs() @@ -133,256 +102,6 @@ class TestSmallerBackingFile(iotests.QMPTestCase): self.assert_no_active_block_jobs() self.vm.shutdown() -class TestErrors(iotests.QMPTestCase): - image_len = 2 * 1024 * 1024 # MB - - # this should match STREAM_BUFFER_SIZE/512 in block/stream.c - STREAM_BUFFER_SIZE = 512 * 1024 - - def create_blkdebug_file(self, name, event, errno): - file = open(name, 'w') - file.write(''' -[inject-error] -state = "1" -event = "%s" -errno = "%d" -immediately = "off" -once = "on" -sector = "%d" - -[set-state] -state = "1" -event = "%s" -new_state = "2" - -[set-state] -state = "2" -event = "%s" -new_state = "1" -''' % (event, errno, self.STREAM_BUFFER_SIZE / 512, event, event)) - file.close() - -class TestEIO(TestErrors): - def setUp(self): - self.blkdebug_file = backing_img + ".blkdebug" - iotests.create_image(backing_img, TestErrors.image_len) - self.create_blkdebug_file(self.blkdebug_file, "read_aio", 5) - qemu_img('create', '-f', iotests.imgfmt, - '-o', 'backing_file=blkdebug:%s:%s,backing_fmt=raw' - % (self.blkdebug_file, backing_img), - test_img) - self.vm = iotests.VM().add_drive(test_img) - self.vm.launch() - - def tearDown(self): - self.vm.shutdown() - os.remove(test_img) - os.remove(backing_img) - os.remove(self.blkdebug_file) - - def test_report(self): - self.assert_no_active_block_jobs() - - result = self.vm.qmp('block-stream', device='drive0') - self.assert_qmp(result, 'return', {}) - - completed = False - error = False - while not completed: - for event in self.vm.get_qmp_events(wait=True): - if event['event'] == 'BLOCK_JOB_ERROR': - self.assert_qmp(event, 'data/device', 'drive0') - self.assert_qmp(event, 'data/operation', 'read') - error = True - elif event['event'] == 'BLOCK_JOB_COMPLETED': - self.assertTrue(error, 'job completed unexpectedly') - self.assert_qmp(event, 'data/type', 'stream') - self.assert_qmp(event, 'data/device', 'drive0') - self.assert_qmp(event, 'data/error', 'Input/output error') - self.assert_qmp(event, 'data/offset', self.STREAM_BUFFER_SIZE) - self.assert_qmp(event, 'data/len', self.image_len) - completed = True - - self.assert_no_active_block_jobs() - self.vm.shutdown() - - def test_ignore(self): - self.assert_no_active_block_jobs() - - result = self.vm.qmp('block-stream', device='drive0', on_error='ignore') - self.assert_qmp(result, 'return', {}) - - error = False - completed = False - while not completed: - for event in self.vm.get_qmp_events(wait=True): - if event['event'] == 'BLOCK_JOB_ERROR': - self.assert_qmp(event, 'data/device', 'drive0') - self.assert_qmp(event, 'data/operation', 'read') - result = self.vm.qmp('query-block-jobs') - self.assert_qmp(result, 'return[0]/paused', False) - error = True - elif event['event'] == 'BLOCK_JOB_COMPLETED': - self.assertTrue(error, 'job completed unexpectedly') - self.assert_qmp(event, 'data/type', 'stream') - self.assert_qmp(event, 'data/device', 'drive0') - self.assert_qmp(event, 'data/error', 'Input/output error') - self.assert_qmp(event, 'data/offset', self.image_len) - self.assert_qmp(event, 'data/len', self.image_len) - completed = True - - self.assert_no_active_block_jobs() - self.vm.shutdown() - - def test_stop(self): - self.assert_no_active_block_jobs() - - result = self.vm.qmp('block-stream', device='drive0', on_error='stop') - self.assert_qmp(result, 'return', {}) - - error = False - completed = False - while not completed: - for event in self.vm.get_qmp_events(wait=True): - if event['event'] == 'BLOCK_JOB_ERROR': - self.assert_qmp(event, 'data/device', 'drive0') - self.assert_qmp(event, 'data/operation', 'read') - - result = self.vm.qmp('query-block-jobs') - self.assert_qmp(result, 'return[0]/paused', True) - self.assert_qmp(result, 'return[0]/offset', self.STREAM_BUFFER_SIZE) - self.assert_qmp(result, 'return[0]/io-status', 'failed') - - result = self.vm.qmp('block-job-resume', device='drive0') - self.assert_qmp(result, 'return', {}) - - result = self.vm.qmp('query-block-jobs') - self.assert_qmp(result, 'return[0]/paused', False) - self.assert_qmp(result, 'return[0]/io-status', 'ok') - error = True - elif event['event'] == 'BLOCK_JOB_COMPLETED': - self.assertTrue(error, 'job completed unexpectedly') - self.assert_qmp(event, 'data/type', 'stream') - self.assert_qmp(event, 'data/device', 'drive0') - self.assert_qmp_absent(event, 'data/error') - self.assert_qmp(event, 'data/offset', self.image_len) - self.assert_qmp(event, 'data/len', self.image_len) - completed = True - - self.assert_no_active_block_jobs() - self.vm.shutdown() - - def test_enospc(self): - self.assert_no_active_block_jobs() - - result = self.vm.qmp('block-stream', device='drive0', on_error='enospc') - self.assert_qmp(result, 'return', {}) - - completed = False - error = False - while not completed: - for event in self.vm.get_qmp_events(wait=True): - if event['event'] == 'BLOCK_JOB_ERROR': - self.assert_qmp(event, 'data/device', 'drive0') - self.assert_qmp(event, 'data/operation', 'read') - error = True - elif event['event'] == 'BLOCK_JOB_COMPLETED': - self.assertTrue(error, 'job completed unexpectedly') - self.assert_qmp(event, 'data/type', 'stream') - self.assert_qmp(event, 'data/device', 'drive0') - self.assert_qmp(event, 'data/error', 'Input/output error') - self.assert_qmp(event, 'data/offset', self.STREAM_BUFFER_SIZE) - self.assert_qmp(event, 'data/len', self.image_len) - completed = True - - self.assert_no_active_block_jobs() - self.vm.shutdown() - -class TestENOSPC(TestErrors): - def setUp(self): - self.blkdebug_file = backing_img + ".blkdebug" - iotests.create_image(backing_img, TestErrors.image_len) - self.create_blkdebug_file(self.blkdebug_file, "read_aio", 28) - qemu_img('create', '-f', iotests.imgfmt, - '-o', 'backing_file=blkdebug:%s:%s,backing_fmt=raw' - % (self.blkdebug_file, backing_img), - test_img) - self.vm = iotests.VM().add_drive(test_img) - self.vm.launch() - - def tearDown(self): - self.vm.shutdown() - os.remove(test_img) - os.remove(backing_img) - os.remove(self.blkdebug_file) - - def test_enospc(self): - self.assert_no_active_block_jobs() - - result = self.vm.qmp('block-stream', device='drive0', on_error='enospc') - self.assert_qmp(result, 'return', {}) - - error = False - completed = False - while not completed: - for event in self.vm.get_qmp_events(wait=True): - if event['event'] == 'BLOCK_JOB_ERROR': - self.assert_qmp(event, 'data/device', 'drive0') - self.assert_qmp(event, 'data/operation', 'read') - - result = self.vm.qmp('query-block-jobs') - self.assert_qmp(result, 'return[0]/paused', True) - self.assert_qmp(result, 'return[0]/offset', self.STREAM_BUFFER_SIZE) - self.assert_qmp(result, 'return[0]/io-status', 'nospace') - - result = self.vm.qmp('block-job-resume', device='drive0') - self.assert_qmp(result, 'return', {}) - - result = self.vm.qmp('query-block-jobs') - self.assert_qmp(result, 'return[0]/paused', False) - self.assert_qmp(result, 'return[0]/io-status', 'ok') - error = True - elif event['event'] == 'BLOCK_JOB_COMPLETED': - self.assertTrue(error, 'job completed unexpectedly') - self.assert_qmp(event, 'data/type', 'stream') - self.assert_qmp(event, 'data/device', 'drive0') - self.assert_qmp_absent(event, 'data/error') - self.assert_qmp(event, 'data/offset', self.image_len) - self.assert_qmp(event, 'data/len', self.image_len) - completed = True - - self.assert_no_active_block_jobs() - self.vm.shutdown() - -class TestStreamStop(iotests.QMPTestCase): - image_len = 8 * 1024 * 1024 * 1024 # GB - - def setUp(self): - qemu_img('create', backing_img, str(TestStreamStop.image_len)) - 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("blkdebug::" + test_img) - self.vm.launch() - - def tearDown(self): - self.vm.shutdown() - os.remove(test_img) - os.remove(backing_img) - - 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', {}) - - time.sleep(0.1) - events = self.vm.get_qmp_events(wait=False) - self.assertEqual(events, [], 'unexpected QMP event: %s' % events) - - self.cancel_and_wait(resume=True) - class TestSetSpeed(iotests.QMPTestCase): image_len = 80 * 1024 * 1024 # MB @@ -391,7 +110,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('blkdebug::' + test_img) + self.vm = iotests.VM().add_drive('blkdebug:/dev/null:' + test_img) self.vm.launch() def tearDown(self): @@ -451,7 +170,7 @@ class TestSetSpeed(iotests.QMPTestCase): self.assert_no_active_block_jobs() result = self.vm.qmp('block-stream', device='drive0', speed=-1) - self.assert_qmp(result, 'error/class', 'GenericError') + self.assert_qmp(result, 'error/class', 'DeviceInUse') self.assert_no_active_block_jobs() @@ -459,7 +178,7 @@ class TestSetSpeed(iotests.QMPTestCase): self.assert_qmp(result, 'return', {}) result = self.vm.qmp('block-job-set-speed', device='drive0', speed=-1) - self.assert_qmp(result, 'error/class', 'GenericError') + self.assert_qmp(result, 'error/class', 'NotSupported') self.cancel_and_wait() diff --git a/tests/qemu-iotests/030.out b/tests/qemu-iotests/030.out index fa16b5c..3f8a935 100644 --- a/tests/qemu-iotests/030.out +++ b/tests/qemu-iotests/030.out @@ -1,5 +1,5 @@ -............. +...... ---------------------------------------------------------------------- -Ran 13 tests +Ran 6 tests OK -- 1.9.3