Share server POST sample file for microversion too

There are many place where server POST request has been used to tests
other API behavior. There was issue of having duplicate
server POST req and resp sample files in each API sample directory.
we added logic to share those sample files from common place
('servers' sample dir)

As microversion tests also need to share such logic, This commit
extends that logic to work for microversion tests also.

Partially implements blueprint test-collapse-v2-and-v21

Change-Id: I3448e1934585c2dabed6c45216ea0513db258b27
This commit is contained in:
ghanshyam
2015-08-24 14:40:12 +09:00
parent 0c8b8f972b
commit 3fa2200f0c
6 changed files with 10 additions and 71 deletions

View File

@@ -1,12 +0,0 @@
{
"server" : {
"accessIPv4": "1.2.3.4",
"accessIPv6": "80fe::",
"name" : "new-server-test",
"imageRef" : "http://glance.openstack.example.com/images/70a599e0-31e7-49b7-b260-868f441e862b",
"flavorRef" : "http://openstack.example.com/flavors/1",
"metadata" : {
"My Server Name" : "Apache1"
}
}
}

View File

@@ -1,16 +0,0 @@
{
"server": {
"adminPass": "6NpUwoz2QDRN",
"id": "f5dc173b-6804-445a-a6d8-c705dad5b5eb",
"links": [
{
"href": "http://openstack.example.com/v2/openstack/servers/f5dc173b-6804-445a-a6d8-c705dad5b5eb",
"rel": "self"
},
{
"href": "http://openstack.example.com/openstack/servers/f5dc173b-6804-445a-a6d8-c705dad5b5eb",
"rel": "bookmark"
}
]
}
}

View File

@@ -91,15 +91,18 @@ class ApiSampleTestBaseV3(testscenarios.WithScenarios,
parts.append('all_extensions')
# Note(gmann): if _use_common_server_api_samples is set to True
# then common server sample files present in 'servers' directory
# will be used.
# will be used. As of now it is being used for server POST request
# to avoid duplicate copy of server req and resp sample files.
# Example - ServersSampleBase's _post_server method.
elif cls._use_common_server_api_samples:
parts.append('servers')
elif cls.sample_dir:
parts.append(cls.sample_dir)
elif cls.extension_name:
parts.append(cls.extension_name)
if api_version:
parts.append('v' + api_version)
else:
if cls.sample_dir:
parts.append(cls.sample_dir)
elif cls.extension_name:
parts.append(cls.extension_name)
if api_version:
parts.append('v' + api_version)
parts.append(name + "." + cls.ctype + suffix)
return os.path.join(*parts)

View File

@@ -1,12 +0,0 @@
{
"server" : {
"accessIPv4": "%(access_ip_v4)s",
"accessIPv6": "%(access_ip_v6)s",
"name" : "new-server-test",
"imageRef" : "%(glance_host)s/images/%(image_id)s",
"flavorRef" : "%(host)s/flavors/1",
"metadata" : {
"My Server Name" : "Apache1"
}
}
}

View File

@@ -1,16 +0,0 @@
{
"server": {
"adminPass": "%(password)s",
"id": "%(id)s",
"links": [
{
"href": "http://openstack.example.com/v2/openstack/servers/%(uuid)s",
"rel": "self"
},
{
"href": "http://openstack.example.com/openstack/servers/%(uuid)s",
"rel": "bookmark"
}
]
}
}

View File

@@ -100,11 +100,7 @@ class ConsolesV26SampleJsonTests(test_servers.ServersSampleBase):
self.http_regex = "(https?://)([\w\d:#@%/;$()~_?\+-=\\\.&](#!)?)*"
def test_create_console(self):
# NOTE(rgerganov): set temporary to None to avoid duplicating server
# templates in the v2.6 folder
ConsolesV26SampleJsonTests.request_api_version = None
uuid = self._post_server()
ConsolesV26SampleJsonTests.request_api_version = '2.6'
body = {'protocol': 'vnc', 'type': 'novnc'}
response = self._do_post('servers/%s/remote-consoles' % uuid,
@@ -127,11 +123,7 @@ class ConsolesV28SampleJsonTests(test_servers.ServersSampleBase):
self.flags(enabled=True, group='mks')
def test_create_mks_console(self):
# NOTE(rgerganov): set temporary to None to avoid duplicating server
# templates in the v2.8 folder
ConsolesV28SampleJsonTests.request_api_version = None
uuid = self._post_server()
ConsolesV28SampleJsonTests.request_api_version = '2.8'
body = {'protocol': 'mks', 'type': 'webmks'}
response = self._do_post('servers/%s/remote-consoles' % uuid,