summaryrefslogtreecommitdiffstats
path: root/nova/tests
diff options
context:
space:
mode:
authorsridevik <koushiksridevi8@gmail.com>2013-06-20 10:20:06 -0500
committersridevik <koushiksridevi8@gmail.com>2013-06-20 23:05:36 -0500
commit2cb31123302a1ec8c8dec0cb2ac288a2e3b19c68 (patch)
tree9db9019e3c2e2a5dbc37efbe3018a30917857870 /nova/tests
parent75ead3a2a37efbc6a4fdea7e492ca41cdd559a8c (diff)
XenApi virt driver should throw exception on failure
Virt xenapi driver does not throw InstancePowerOffFailure exception on a failure while destroying an instance. _shutdown_instance in compute manager expects InstancePowerOffFailure and reraises it. This ensures that instances are not wrongly marked as deleted. Change-Id: Id57f48a00202bd5ed3125f8e4396a51c12e142cb Fixes: bug #1190076
Diffstat (limited to 'nova/tests')
-rw-r--r--nova/tests/virt/xenapi/test_vmops.py11
-rw-r--r--nova/tests/virt/xenapi/test_xenapi.py5
2 files changed, 16 insertions, 0 deletions
diff --git a/nova/tests/virt/xenapi/test_vmops.py b/nova/tests/virt/xenapi/test_vmops.py
index 674d84882..d2b5477eb 100644
--- a/nova/tests/virt/xenapi/test_vmops.py
+++ b/nova/tests/virt/xenapi/test_vmops.py
@@ -171,6 +171,17 @@ class VMOpsTestCase(test.TestCase):
self.assertEqual(self.make_plugin_call_count, 1)
+ def test_destroy_raises_when_shutdown_fails(self):
+ vm_ref = "vm_reference"
+ fake_instance = "instance"
+
+ self.mox.StubOutWithMock(vm_utils, 'hard_shutdown_vm')
+ vm_utils.hard_shutdown_vm(self._session, fake_instance,
+ vm_ref).AndReturn(False)
+ self.mox.ReplayAll()
+ self.assertRaises(exception.InstancePowerOffFailure,
+ self._vmops._destroy, fake_instance, vm_ref)
+
class GetConsoleOutputTestCase(stubs.XenAPITestBase):
def setUp(self):
diff --git a/nova/tests/virt/xenapi/test_xenapi.py b/nova/tests/virt/xenapi/test_xenapi.py
index 91d4f0770..c0b50797d 100644
--- a/nova/tests/virt/xenapi/test_xenapi.py
+++ b/nova/tests/virt/xenapi/test_xenapi.py
@@ -787,6 +787,11 @@ class XenAPIVMTestCase(stubs.XenAPITestBase):
Verifies that the VM and VDIs created are properly cleaned up.
"""
+ def fake_hard_shutdown_vm(session, instance, vm_ref):
+ return True
+
+ self.stubs.Set(vm_utils, 'hard_shutdown_vm',
+ fake_hard_shutdown_vm)
stubs.stubout_attach_disks(self.stubs)
vdi_recs_start = self._list_vdis()
start_vms = self._list_vms()