From ad7fcf225e126d2a719c04019c4daa1616d2159e Mon Sep 17 00:00:00 2001 From: Derek Higgins Date: Fri, 4 Nov 2011 00:25:34 +0000 Subject: Undefine libvirt saved instances Fixes bug 814561 Adding a call to managedSaveRemove if the instance has a saved instance, so they are now undefined in addition to running instances during destroy With test case Also added myself to Authors Change-Id: If93e8ac6972116152f38e187bd1a61c652855814 --- nova/tests/test_libvirt.py | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'nova/tests') diff --git a/nova/tests/test_libvirt.py b/nova/tests/test_libvirt.py index 28af606bc..d0ca361ad 100644 --- a/nova/tests/test_libvirt.py +++ b/nova/tests/test_libvirt.py @@ -1063,6 +1063,25 @@ class LibvirtConnTestCase(test.TestCase): instance = db.instance_create(self.context, self.test_instance) conn.destroy(instance, {}) + @test.skip_if(missing_libvirt(), "Test requires libvirt") + def test_destroy_saved(self): + """Ensure destroy calls managedSaveRemove for saved instance""" + mock = self.mox.CreateMock(libvirt.virDomain) + mock.destroy() + mock.hasManagedSaveImage(0).AndReturn(1) + mock.managedSaveRemove(0) + mock.undefine() + + self.mox.ReplayAll() + + def fake_lookup_by_name(instance_name): + return mock + + conn = connection.LibvirtConnection(False) + self.stubs.Set(conn, '_lookup_by_name', fake_lookup_by_name) + instance = {"name": "instancename", "id": "instanceid"} + conn.destroy(instance, []) + class HostStateTestCase(test.TestCase): -- cgit