Merge "Add unit test for extract_snapshot with compression enabled"

This commit is contained in:
Jenkins 2016-12-19 17:38:02 +00:00 committed by Gerrit Code Review
commit c691a18acd
1 changed files with 12 additions and 3 deletions

View File

@ -494,9 +494,12 @@ disk size: 4.4M
dest_format='raw', out_format='raw'):
libvirt_utils.extract_snapshot('/path/to/disk/image', src_format,
'/extracted/snap', dest_format)
mock_execute.assert_called_once_with(
'qemu-img', 'convert', '-f', src_format, '-O', out_format,
'/path/to/disk/image', '/extracted/snap')
qemu_img_cmd = ('qemu-img', 'convert', '-f',
src_format, '-O', out_format)
if CONF.libvirt.snapshot_compression and dest_format == "qcow2":
qemu_img_cmd += ('-c',)
qemu_img_cmd += ('/path/to/disk/image', '/extracted/snap')
mock_execute.assert_called_once_with(*qemu_img_cmd)
@mock.patch.object(utils, 'execute')
def test_extract_snapshot_raw(self, mock_execute):
@ -511,6 +514,12 @@ disk size: 4.4M
self._do_test_extract_snapshot(mock_execute,
dest_format='qcow2', out_format='qcow2')
@mock.patch.object(utils, 'execute')
def test_extract_snapshot_qcow2_and_compression(self, mock_execute):
self.flags(snapshot_compression=True, group='libvirt')
self._do_test_extract_snapshot(mock_execute,
dest_format='qcow2', out_format='qcow2')
@mock.patch.object(utils, 'execute')
def test_extract_snapshot_parallels(self, mock_execute):
self._do_test_extract_snapshot(mock_execute,