Updated common create server sample request because of microversion 2.37
Change I89b18709e0cfbbcbf9be96a91a13a1356cdf85b0 added new microversion 2.37. This microversion added required field 'networks' into create server request. By default Nova functional api tests use samples from '/servers' directory to create a server. But now such requests got 400 Bad Request because of missed 'networks' field. We must handle this case if we are testing microversions >= 2.37. This patch will add sample for microversion 2.37+ Closes-Bug: 1613998 Change-Id: I40cac263c97a4a871072d0efe5ebff295c2d917e
This commit is contained in:
parent
b292bf3441
commit
2132cfaa30
30
doc/api_samples/servers/server-create-req-v237.json
Normal file
30
doc/api_samples/servers/server-create-req-v237.json
Normal file
@ -0,0 +1,30 @@
|
||||
{
|
||||
"server" : {
|
||||
"accessIPv4": "1.2.3.4",
|
||||
"accessIPv6": "80fe::",
|
||||
"name" : "new-server-test",
|
||||
"imageRef" : "70a599e0-31e7-49b7-b260-868f441e862b",
|
||||
"flavorRef" : "1",
|
||||
"availability_zone": "nova",
|
||||
"OS-DCF:diskConfig": "AUTO",
|
||||
"metadata" : {
|
||||
"My Server Name" : "Apache1"
|
||||
},
|
||||
"personality": [
|
||||
{
|
||||
"path": "/etc/banner.txt",
|
||||
"contents": "ICAgICAgDQoiQSBjbG91ZCBkb2VzIG5vdCBrbm93IHdoeSBp dCBtb3ZlcyBpbiBqdXN0IHN1Y2ggYSBkaXJlY3Rpb24gYW5k IGF0IHN1Y2ggYSBzcGVlZC4uLkl0IGZlZWxzIGFuIGltcHVs c2lvbi4uLnRoaXMgaXMgdGhlIHBsYWNlIHRvIGdvIG5vdy4g QnV0IHRoZSBza3kga25vd3MgdGhlIHJlYXNvbnMgYW5kIHRo ZSBwYXR0ZXJucyBiZWhpbmQgYWxsIGNsb3VkcywgYW5kIHlv dSB3aWxsIGtub3csIHRvbywgd2hlbiB5b3UgbGlmdCB5b3Vy c2VsZiBoaWdoIGVub3VnaCB0byBzZWUgYmV5b25kIGhvcml6 b25zLiINCg0KLVJpY2hhcmQgQmFjaA=="
|
||||
}
|
||||
],
|
||||
"security_groups": [
|
||||
{
|
||||
"name": "default"
|
||||
}
|
||||
],
|
||||
"user_data" : "IyEvYmluL2Jhc2gKL2Jpbi9zdQplY2hvICJJIGFtIGluIHlvdSEiCg==",
|
||||
"networks": "auto"
|
||||
},
|
||||
"OS-SCH-HNT:scheduler_hints": {
|
||||
"same_host": "48e6a9f6-30af-47e0-bc04-acaed113bb4e"
|
||||
}
|
||||
}
|
@ -0,0 +1,30 @@
|
||||
{
|
||||
"server" : {
|
||||
"accessIPv4": "%(access_ip_v4)s",
|
||||
"accessIPv6": "%(access_ip_v6)s",
|
||||
"name" : "new-server-test",
|
||||
"imageRef" : "%(image_id)s",
|
||||
"flavorRef" : "1",
|
||||
"availability_zone": "nova",
|
||||
"OS-DCF:diskConfig": "AUTO",
|
||||
"metadata" : {
|
||||
"My Server Name" : "Apache1"
|
||||
},
|
||||
"personality": [
|
||||
{
|
||||
"path": "/etc/banner.txt",
|
||||
"contents": "ICAgICAgDQoiQSBjbG91ZCBkb2VzIG5vdCBrbm93IHdoeSBp dCBtb3ZlcyBpbiBqdXN0IHN1Y2ggYSBkaXJlY3Rpb24gYW5k IGF0IHN1Y2ggYSBzcGVlZC4uLkl0IGZlZWxzIGFuIGltcHVs c2lvbi4uLnRoaXMgaXMgdGhlIHBsYWNlIHRvIGdvIG5vdy4g QnV0IHRoZSBza3kga25vd3MgdGhlIHJlYXNvbnMgYW5kIHRo ZSBwYXR0ZXJucyBiZWhpbmQgYWxsIGNsb3VkcywgYW5kIHlv dSB3aWxsIGtub3csIHRvbywgd2hlbiB5b3UgbGlmdCB5b3Vy c2VsZiBoaWdoIGVub3VnaCB0byBzZWUgYmV5b25kIGhvcml6 b25zLiINCg0KLVJpY2hhcmQgQmFjaA=="
|
||||
}
|
||||
],
|
||||
"security_groups": [
|
||||
{
|
||||
"name": "default"
|
||||
}
|
||||
],
|
||||
"user_data" : "%(user_data)s",
|
||||
"networks": "auto"
|
||||
},
|
||||
"OS-SCH-HNT:scheduler_hints": {
|
||||
"same_host": "%(uuid)s"
|
||||
}
|
||||
}
|
@ -15,6 +15,7 @@
|
||||
|
||||
import base64
|
||||
|
||||
from nova.api.openstack import api_version_request as avr
|
||||
from nova.tests.functional.api_sample_tests import api_sample_base
|
||||
from nova.tests.unit.api.openstack import fakes
|
||||
from nova.tests.unit.image import fake
|
||||
@ -27,6 +28,21 @@ class ServersSampleBase(api_sample_base.ApiSampleTestBaseV21):
|
||||
user_data_contents = '#!/bin/bash\n/bin/su\necho "I am in you!"\n'
|
||||
user_data = base64.b64encode(user_data_contents)
|
||||
|
||||
common_req_names = [
|
||||
(None, '2.36', 'server-create-req'),
|
||||
('2.37', None, 'server-create-req-v237')
|
||||
]
|
||||
|
||||
def _get_request_name(self, use_common):
|
||||
if not use_common:
|
||||
return 'server-create-req'
|
||||
|
||||
api_version = self.microversion or '2.1'
|
||||
for min, max, name in self.common_req_names:
|
||||
if avr.APIVersionRequest(api_version).matches(
|
||||
avr.APIVersionRequest(min), avr.APIVersionRequest(max)):
|
||||
return name
|
||||
|
||||
def _post_server(self, use_common_server_api_samples=True):
|
||||
# param use_common_server_api_samples: Boolean to set whether tests use
|
||||
# common sample files for server post request and response.
|
||||
@ -51,7 +67,8 @@ class ServersSampleBase(api_sample_base.ApiSampleTestBaseV21):
|
||||
try:
|
||||
self.__class__._use_common_server_api_samples = (
|
||||
use_common_server_api_samples)
|
||||
response = self._do_post('servers', 'server-create-req', subs)
|
||||
response = self._do_post('servers', self._get_request_name(
|
||||
use_common_server_api_samples), subs)
|
||||
status = self._verify_response('server-create-resp', subs,
|
||||
response, 202)
|
||||
return status
|
||||
|
Loading…
Reference in New Issue
Block a user