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:
parent
321037b648
commit
01a44568cc
@ -0,0 +1,3 @@
|
||||
{
|
||||
"confirm_resize" : null
|
||||
}
|
@ -0,0 +1,3 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<confirm_resize
|
||||
xmlns="http://docs.openstack.org/compute/api/v1.1"/>
|
5
doc/v3/api_samples/servers/server-action-resize.json
Normal file
5
doc/v3/api_samples/servers/server-action-resize.json
Normal file
@ -0,0 +1,5 @@
|
||||
{
|
||||
"resize" : {
|
||||
"flavor_ref" : "2"
|
||||
}
|
||||
}
|
4
doc/v3/api_samples/servers/server-action-resize.xml
Normal file
4
doc/v3/api_samples/servers/server-action-resize.xml
Normal 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"/>
|
@ -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)
|
||||
|
@ -0,0 +1,3 @@
|
||||
{
|
||||
"confirm_resize" : null
|
||||
}
|
@ -0,0 +1,3 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<confirm_resize
|
||||
xmlns="http://docs.openstack.org/compute/api/v1.1"/>
|
@ -0,0 +1,5 @@
|
||||
{
|
||||
"resize" : {
|
||||
"flavor_ref" : "%(id)s"
|
||||
}
|
||||
}
|
@ -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"/>
|
@ -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'
|
||||
|
Loading…
Reference in New Issue
Block a user