Skip to content

Commit

Permalink
Merge "Add unit test for extract_snapshot with compression enabled"
Browse files Browse the repository at this point in the history
  • Loading branch information
Jenkins authored and openstack-gerrit committed Dec 19, 2016
2 parents 784db5a + 7cc0576 commit c691a18
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions nova/tests/unit/virt/libvirt/test_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -494,9 +494,12 @@ def _do_test_extract_snapshot(self, mock_execute, src_format='qcow2',
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):
Expand All @@ -511,6 +514,12 @@ def test_extract_snapshot_qcow2(self, mock_execute):
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,
Expand Down

0 comments on commit c691a18

Please sign in to comment.