diff options
Diffstat (limited to 'nova/tests')
| -rw-r--r-- | nova/tests/compute/test_compute.py | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/nova/tests/compute/test_compute.py b/nova/tests/compute/test_compute.py index fc3e0126b..724635475 100644 --- a/nova/tests/compute/test_compute.py +++ b/nova/tests/compute/test_compute.py @@ -2337,6 +2337,36 @@ class ComputeTestCase(BaseTestCase): instance=jsonutils.to_primitive(instance), bdms={}) + def test_delete_instance_keeps_net_on_power_off_fail(self): + self.mox.StubOutWithMock(self.compute.driver, 'destroy') + self.mox.StubOutWithMock(self.compute, '_deallocate_network') + exp = exception.InstancePowerOffFailure(reason='') + self.compute.driver.destroy(mox.IgnoreArg(), mox.IgnoreArg(), + mox.IgnoreArg()).AndRaise(exp) + # mox will detect if _deallocate_network gets called unexpectedly + self.mox.ReplayAll() + instance = self._create_fake_instance() + self.assertRaises(exception.InstancePowerOffFailure, + self.compute._delete_instance, + self.context, + instance=jsonutils.to_primitive(instance), + bdms={}) + + def test_delete_instance_loses_net_on_other_fail(self): + self.mox.StubOutWithMock(self.compute.driver, 'destroy') + self.mox.StubOutWithMock(self.compute, '_deallocate_network') + exp = test.TestingException() + self.compute.driver.destroy(mox.IgnoreArg(), mox.IgnoreArg(), + mox.IgnoreArg()).AndRaise(exp) + self.compute._deallocate_network(mox.IgnoreArg(), mox.IgnoreArg()) + self.mox.ReplayAll() + instance = self._create_fake_instance() + self.assertRaises(test.TestingException, + self.compute._delete_instance, + self.context, + instance=jsonutils.to_primitive(instance), + bdms={}) + def test_delete_instance_deletes_console_auth_tokens(self): instance = self._create_fake_instance() self.flags(vnc_enabled=True) |
