Fix status code of server's action confirm_resize for v3

The status code of confirm_resize should be 202, but it
returns 204 now. That because it returns HTTPNoContent
that overwrites the status code of decorator 'wsgi.response(202)'

And adds API samples for confirm_resize that used to test
the status code of confirm_resize.

Partially implements blueprint v3-api-unittests
Closes-bug: #1233561

Change-Id: I50a3046866af0a1efdb5c41ded40f973b02843e8
This commit is contained in:
He Jie Xu 2013-09-06 16:25:26 +08:00
parent 321037b648
commit 01a44568cc
10 changed files with 65 additions and 1 deletions

View File

@ -0,0 +1,3 @@
{
"confirm_resize" : null
}

View File

@ -0,0 +1,3 @@
<?xml version="1.0" encoding="UTF-8"?>
<confirm_resize
xmlns="http://docs.openstack.org/compute/api/v1.1"/>

View File

@ -0,0 +1,5 @@
{
"resize" : {
"flavor_ref" : "2"
}
}

View File

@ -0,0 +1,4 @@
<?xml version="1.0" encoding="UTF-8"?>
<resize
xmlns="http://docs.openstack.org/compute/api/v1.1"
flavor_ref="2"/>

View File

@ -953,7 +953,6 @@ class ServersController(wsgi.Controller):
except exception.InstanceInvalidState as state_error:
common.raise_http_conflict_for_instance_invalid_state(state_error,
'confirm_resize')
return exc.HTTPNoContent()
@wsgi.response(202)
@wsgi.serializers(xml=FullServerTemplate)

View File

@ -0,0 +1,3 @@
{
"confirm_resize" : null
}

View File

@ -0,0 +1,3 @@
<?xml version="1.0" encoding="UTF-8"?>
<confirm_resize
xmlns="http://docs.openstack.org/compute/api/v1.1"/>

View File

@ -0,0 +1,5 @@
{
"resize" : {
"flavor_ref" : "%(id)s"
}
}

View File

@ -0,0 +1,4 @@
<?xml version="1.0" encoding="UTF-8"?>
<resize
xmlns="http://docs.openstack.org/compute/api/v1.1"
flavor_ref="%(id)s"/>

View File

@ -74,3 +74,38 @@ class ServersSampleAllExtensionJsonTest(ServersSampleJsonTest):
class ServersSampleAllExtensionXmlTest(ServersSampleXmlTest):
all_extensions = True
class ServersActionsJsonTest(ServersSampleBase):
sample_dir = 'servers'
def _test_server_action(self, uuid, action,
subs={}, resp_tpl=None, code=202):
subs.update({'action': action,
'glance_host': self._get_glance_host()})
response = self._do_post('servers/%s/action' % uuid,
'server-action-%s' % action.replace('_',
'-'),
subs)
if resp_tpl:
subs.update(self._get_regexes())
self._verify_response(resp_tpl, subs, response, code)
else:
self.assertEqual(response.status, code)
self.assertEqual(response.read(), "")
def test_server_resize(self):
self.flags(allow_resize_to_same_host=True)
uuid = self._post_server()
self._test_server_action(uuid, "resize",
{"id": 2,
"host": self._get_host()})
return uuid
def test_server_confirm_resize(self):
uuid = self.test_server_resize()
self._test_server_action(uuid, "confirm_resize")
class ServersActionsXmlTest(ServersActionsJsonTest):
ctype = 'xml'