Amador Pahim has uploaded a new change for review. Change subject: tests: "-T src_cache" option in "qemu-img convert" command ......................................................................
tests: "-T src_cache" option in "qemu-img convert" command Follow up patch with the tests for the qemu-img convert "-T src_cache" option. Change-Id: Ie385dda479424dee147d0a917388b662dbb0cecd Signed-off-by: Amador Pahim <[email protected]> --- M tests/qemuimgTests.py 1 file changed, 92 insertions(+), 28 deletions(-) git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/74/36374/1 diff --git a/tests/qemuimgTests.py b/tests/qemuimgTests.py index df21040..3e6c1e6 100644 --- a/tests/qemuimgTests.py +++ b/tests/qemuimgTests.py @@ -167,8 +167,10 @@ self.assertEqual(cmd, expected) return 0, '', '' - with FakeCmd(utils, 'watchCmd', convert): - qemuimg.convert('src', 'dst', True) + with MonkeyPatchScope([(qemuimg, '_supports_src_cache', + self.supported('convert', False))]): + with FakeCmd(utils, 'watchCmd', convert): + qemuimg.convert('src', 'dst', True) def test_qcow2_compat_unsupported(self): def convert(cmd, **kw): @@ -177,10 +179,12 @@ self.assertEqual(cmd, expected) return 0, '', '' - with MonkeyPatchScope([(qemuimg, '_supports_qcow2_compat', + with MonkeyPatchScope([(qemuimg, '_supports_src_cache', self.supported('convert', False))]): - with FakeCmd(utils, 'watchCmd', convert): - qemuimg.convert('src', 'dst', True, dstFormat='qcow2') + with MonkeyPatchScope([(qemuimg, '_supports_qcow2_compat', + self.supported('convert', False))]): + with FakeCmd(utils, 'watchCmd', convert): + qemuimg.convert('src', 'dst', True, dstFormat='qcow2') def test_qcow2_compat_supported(self): def convert(cmd, **kw): @@ -189,10 +193,12 @@ self.assertEqual(cmd, expected) return 0, '', '' - with MonkeyPatchScope([(qemuimg, '_supports_qcow2_compat', - self.supported('convert', True))]): - with FakeCmd(utils, 'watchCmd', convert): - qemuimg.convert('src', 'dst', True, dstFormat='qcow2') + with MonkeyPatchScope([(qemuimg, '_supports_src_cache', + self.supported('convert', False))]): + with MonkeyPatchScope([(qemuimg, '_supports_qcow2_compat', + self.supported('convert', True))]): + with FakeCmd(utils, 'watchCmd', convert): + qemuimg.convert('src', 'dst', True, dstFormat='qcow2') def test_qcow2_no_backing_file(self): def convert(cmd, **kw): @@ -201,10 +207,12 @@ self.assertEqual(cmd, expected) return 0, '', '' - with MonkeyPatchScope([(qemuimg, '_supports_qcow2_compat', - self.supported('convert', True))]): - with FakeCmd(utils, 'watchCmd', convert): - qemuimg.convert('src', 'dst', None, dstFormat='qcow2') + with MonkeyPatchScope([(qemuimg, '_supports_src_cache', + self.supported('convert', False))]): + with MonkeyPatchScope([(qemuimg, '_supports_qcow2_compat', + self.supported('convert', True))]): + with FakeCmd(utils, 'watchCmd', convert): + qemuimg.convert('src', 'dst', None, dstFormat='qcow2') def test_qcow2_backing_file(self): def convert(cmd, **kw): @@ -214,11 +222,13 @@ self.assertEqual(cmd, expected) return 0, '', '' - with MonkeyPatchScope([(qemuimg, '_supports_qcow2_compat', - self.supported('convert', True))]): - with FakeCmd(utils, 'watchCmd', convert): - qemuimg.convert('src', 'dst', None, dstFormat='qcow2', - backing='bak') + with MonkeyPatchScope([(qemuimg, '_supports_src_cache', + self.supported('convert', False))]): + with MonkeyPatchScope([(qemuimg, '_supports_qcow2_compat', + self.supported('convert', True))]): + with FakeCmd(utils, 'watchCmd', convert): + qemuimg.convert('src', 'dst', None, dstFormat='qcow2', + backing='bak') def test_qcow2_backing_format(self): def convert(cmd, **kw): @@ -227,11 +237,13 @@ self.assertEqual(cmd, expected) return 0, '', '' - with MonkeyPatchScope([(qemuimg, '_supports_qcow2_compat', - self.supported('convert', True))]): - with FakeCmd(utils, 'watchCmd', convert): - qemuimg.convert('src', 'dst', None, dstFormat='qcow2', - backingFormat='qcow2') + with MonkeyPatchScope([(qemuimg, '_supports_src_cache', + self.supported('convert', False))]): + with MonkeyPatchScope([(qemuimg, '_supports_qcow2_compat', + self.supported('convert', True))]): + with FakeCmd(utils, 'watchCmd', convert): + qemuimg.convert('src', 'dst', None, dstFormat='qcow2', + backingFormat='qcow2') def test_qcow2_backing_file_and_format(self): def convert(cmd, **kw): @@ -241,11 +253,13 @@ self.assertEqual(cmd, expected) return 0, '', '' - with MonkeyPatchScope([(qemuimg, '_supports_qcow2_compat', - self.supported('convert', True))]): - with FakeCmd(utils, 'watchCmd', convert): - qemuimg.convert('src', 'dst', None, dstFormat='qcow2', - backing='bak', backingFormat='qcow2') + with MonkeyPatchScope([(qemuimg, '_supports_src_cache', + self.supported('convert', False))]): + with MonkeyPatchScope([(qemuimg, '_supports_qcow2_compat', + self.supported('convert', True))]): + with FakeCmd(utils, 'watchCmd', convert): + qemuimg.convert('src', 'dst', None, dstFormat='qcow2', + backing='bak', backingFormat='qcow2') def test_qcow2_compat(self, **kw): def call(cmd, **kw): @@ -269,6 +283,56 @@ with FakeCmd(utils, 'execCmd', unsupported): self.assertFalse(qemuimg._supports_qcow2_compat('convert')) + def test_src_cache_supported(self): + def convert(cmd, **kw): + expected = [QEMU_IMG, 'convert', '-t', 'none', '-T', 'none', + 'src', 'dst'] + self.assertEqual(cmd, expected) + return 0, '', '' + + with MonkeyPatchScope([(qemuimg, '_supports_src_cache', + self.supported('convert', True))]): + with FakeCmd(utils, 'watchCmd', convert): + qemuimg.convert('src', 'dst', True) + + def test_src_cache_unsupported(self): + def convert(cmd, **kw): + expected = [QEMU_IMG, 'convert', '-t', 'none', 'src', 'dst'] + self.assertEqual(cmd, expected) + return 0, '', '' + + with MonkeyPatchScope([(qemuimg, '_supports_src_cache', + self.supported('convert', False))]): + with FakeCmd(utils, 'watchCmd', convert): + qemuimg.convert('src', 'dst', True) + + def test_src_cache_compat(self, **kw): + def call(cmd, **kw): + expected = [QEMU_IMG, '--help'] + self.assertEqual(cmd, expected) + return 0, '', '' + + def supported(cmd, **kw): + return 0, ' compare [-f fmt] [-F fmt] [-T src_cache] ...\n' \ + ' convert [-c] [-p] [-q] [-n] [-f fmt] [-t cache] ' \ + '[-T src_cache] [-O output_fmt] ...\n' \ + ' info [-f fmt] [--output=ofmt] ...\n', '' + + def unsupported(cmd, **kw): + return 0, ' compare [-f fmt] [-F fmt] ...\n' \ + ' convert [-c] [-p] [-q] [-n] [-f fmt] [-t cache] ' \ + '[-O output_fmt] ...\n' \ + ' info [-f fmt] [--output=ofmt] ...\n', '' + + with FakeCmd(utils, 'execCmd', call): + qemuimg._supports_src_cache('convert') + + with FakeCmd(utils, 'execCmd', supported): + self.assertTrue(qemuimg._supports_src_cache('convert')) + + with FakeCmd(utils, 'execCmd', unsupported): + self.assertFalse(qemuimg._supports_src_cache('convert')) + def supported(self, command, result): def check(arg): self.assertEqual(command, arg) -- To view, visit http://gerrit.ovirt.org/36374 To unsubscribe, visit http://gerrit.ovirt.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: Ie385dda479424dee147d0a917388b662dbb0cecd Gerrit-PatchSet: 1 Gerrit-Project: vdsm Gerrit-Branch: master Gerrit-Owner: Amador Pahim <[email protected]> _______________________________________________ vdsm-patches mailing list [email protected] https://lists.fedorahosted.org/mailman/listinfo/vdsm-patches
