summaryrefslogtreecommitdiffstats
path: root/nova/tests
diff options
context:
space:
mode:
authorJenkins <jenkins@review.openstack.org>2013-06-08 01:17:18 +0000
committerGerrit Code Review <review@openstack.org>2013-06-08 01:17:18 +0000
commite0142d0f63bf64a07db3bd3b840fc2072d2e6ca3 (patch)
tree375cdadf8c1b20229b94352887213a292bcdf983 /nova/tests
parent08d6c1dd3d8819a73c35c2c59ac5e50224fb9a73 (diff)
parentdacb187fcd685c15fd084fdfce8c5e165130ff54 (diff)
downloadnova-e0142d0f63bf64a07db3bd3b840fc2072d2e6ca3.tar.gz
nova-e0142d0f63bf64a07db3bd3b840fc2072d2e6ca3.tar.xz
nova-e0142d0f63bf64a07db3bd3b840fc2072d2e6ca3.zip
Merge "Call virt.driver.destroy before deallocating network."
Diffstat (limited to 'nova/tests')
-rw-r--r--nova/tests/compute/test_compute.py30
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)