diff options
| author | Jenkins <jenkins@review.openstack.org> | 2013-04-23 19:37:46 +0000 |
|---|---|---|
| committer | Gerrit Code Review <review@openstack.org> | 2013-04-23 19:37:46 +0000 |
| commit | 5a604b5924dae368da4b6561550bb430e3239ca3 (patch) | |
| tree | 99f7e93413b161cf33b21c88cdc3ac839f1ba217 /nova/tests | |
| parent | c59514eca02b0eef55648f418abcba8fd8bc7d70 (diff) | |
| parent | 40692574bbdefbdfa4a6f3366bec524fd4612400 (diff) | |
Merge "If rescue fails don't error the instance"
Diffstat (limited to 'nova/tests')
| -rw-r--r-- | nova/tests/compute/test_compute.py | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/nova/tests/compute/test_compute.py b/nova/tests/compute/test_compute.py index dbd72a797..4f843bc05 100644 --- a/nova/tests/compute/test_compute.py +++ b/nova/tests/compute/test_compute.py @@ -22,6 +22,7 @@ import base64 import copy import datetime import sys +import testtools import time import traceback import uuid @@ -1265,6 +1266,33 @@ class ComputeTestCase(BaseTestCase): self.compute.terminate_instance(self.context, instance=instance) + def test_rescue_handle_err(self): + # If the driver fails to rescue, instance state should remain the same + # and the exception should be converted to InstanceNotRescuable + instance = jsonutils.to_primitive(self._create_fake_instance()) + self.mox.StubOutWithMock(self.compute, '_get_rescue_image_ref') + self.mox.StubOutWithMock(nova.virt.fake.FakeDriver, 'rescue') + + self.compute._get_rescue_image_ref( + mox.IgnoreArg(), instance).AndReturn('resc_image_ref') + nova.virt.fake.FakeDriver.rescue( + mox.IgnoreArg(), instance, [], mox.IgnoreArg(), 'password' + ).AndRaise(RuntimeError("Try again later")) + + self.mox.ReplayAll() + + expected_message = ('Instance %s cannot be rescued: ' + 'Driver Error: Try again later' % instance['uuid']) + instance['vm_state'] = 'some_random_state' + + with testtools.ExpectedException( + exception.InstanceNotRescuable, expected_message): + self.compute.rescue_instance( + self.context, instance=instance, + rescue_password='password') + + self.assertEqual('some_random_state', instance['vm_state']) + def test_power_on(self): # Ensure instance can be powered on. |
