diff options
| author | Russell Bryant <rbryant@redhat.com> | 2012-05-17 16:15:29 -0400 |
|---|---|---|
| committer | Russell Bryant <rbryant@redhat.com> | 2012-05-17 16:17:56 -0400 |
| commit | 8fbde4936df0c3521704dfc8629bb94579277f79 (patch) | |
| tree | 9d6de5095d6fb222d684b01041a0c2e98b043b2d | |
| parent | 12ea7e4ded9f71624721aae638abb822e1f538f8 (diff) | |
Add unit test coverage for bug 1000261.
The fix for bug 1000261 updated some parsing code to handle updated
output from qemu-img. This test case exercises this parsing code.
Change-Id: I5c9592478823464317cc6d521b3240913e4ded92
| -rw-r--r-- | nova/tests/test_libvirt.py | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/nova/tests/test_libvirt.py b/nova/tests/test_libvirt.py index db804acee..42dfdbfa7 100644 --- a/nova/tests/test_libvirt.py +++ b/nova/tests/test_libvirt.py @@ -2426,6 +2426,29 @@ disk size: 4.4M''', '')) libvirt_utils.fetch_image(context, target, image_id, user_id, project_id) + def test_get_disk_backing_file(self): + with_actual_path = False + + def fake_execute(*args, **kwargs): + if with_actual_path: + return ("some\n" + "output\n" + "backing file: /foo/bar/baz (actual path: /a/b/c)\n" + "...\n"), '' + else: + return ("some\n" + "output\n" + "backing file: /foo/bar/baz\n" + "...\n"), '' + + self.stubs.Set(utils, 'execute', fake_execute) + + out = libvirt_utils.get_disk_backing_file('') + self.assertEqual(out, 'baz') + with_actual_path = True + out = libvirt_utils.get_disk_backing_file('') + self.assertEqual(out, 'c') + class LibvirtConnectionTestCase(test.TestCase): """Test for nova.virt.libvirt.connection.LibvirtConnection.""" |
