From 913ecb84d286413cfec3dff7cf1b1b71f93bcfce Mon Sep 17 00:00:00 2001 From: Philip Knouff Date: Mon, 5 Mar 2012 19:41:12 +0000 Subject: Raise 409 when rescuing instance in RESCUE mode fixes bud #940581 Change-Id: I8c6b600d36a35ef4e32f35b888f8f2eb8effebcd --- nova/tests/api/openstack/compute/contrib/test_rescue.py | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'nova/tests') diff --git a/nova/tests/api/openstack/compute/contrib/test_rescue.py b/nova/tests/api/openstack/compute/contrib/test_rescue.py index 9a3706173..c2c8aa28c 100644 --- a/nova/tests/api/openstack/compute/contrib/test_rescue.py +++ b/nova/tests/api/openstack/compute/contrib/test_rescue.py @@ -17,6 +17,7 @@ import json import webob from nova import compute +from nova import exception from nova import flags from nova import test from nova.tests.api.openstack import fakes @@ -68,6 +69,21 @@ class RescueTest(test.TestCase): resp_json = json.loads(resp.body) self.assertEqual(FLAGS.password_length, len(resp_json['adminPass'])) + def test_rescue_of_rescued_instance(self): + body = dict(rescue=None) + + def fake_rescue(*args, **kwargs): + raise exception.InstanceInvalidState('fake message') + + self.stubs.Set(compute.api.API, "rescue", fake_rescue) + req = webob.Request.blank('/v2/fake/servers/test_inst/action') + req.method = "POST" + req.body = json.dumps(body) + req.headers["content-type"] = "application/json" + + resp = req.get_response(fakes.wsgi_app()) + self.assertEqual(resp.status_int, 409) + def test_unrescue(self): body = dict(unrescue=None) req = webob.Request.blank('/v2/fake/servers/test_inst/action') -- cgit