Share hide server add tests between v2 and v2.1

Currently v2 and v2.1 have separate functional tests and their
corresponding sample files. As v2 and v2.1 are supposed to be identical,
there is overhead to maintain two set of functional tests and sample files.
We can have one set of tests which can run for both v2 and v2.1.

This commit merges hide server addresses functional tests.

In V2.1 os-access-ip is separate plugin where in v2 it was mixed in server
plugin itself. So os-access-ip extension is enabled to run
merged functional tests for both v2 and v2.1.

Change-Id: I8c467050ea3ed666c3837d9c2846ae5d9b245c69
This commit is contained in:
ghanshyam 2015-04-10 13:48:01 +09:00
parent 45c4fcb095
commit 57d4698f66
14 changed files with 37 additions and 296 deletions

View File

@ -1,47 +0,0 @@
{
"server": {
"accessIPv4": "",
"accessIPv6": "",
"addresses": {},
"created": "2012-12-19T20:32:40Z",
"flavor": {
"id": "1",
"links": [
{
"href": "http://openstack.example.com/openstack/flavors/1",
"rel": "bookmark"
}
]
},
"hostId": "d2697421d9869915ee376575508fdba76432f9b3ef451e7a1f86c62e",
"id": "2e9157dc-deea-4ee7-820a-640ecba32b5a",
"image": {
"id": "70a599e0-31e7-49b7-b260-868f441e862b",
"links": [
{
"href": "http://openstack.example.com/openstack/images/70a599e0-31e7-49b7-b260-868f441e862b",
"rel": "bookmark"
}
]
},
"links": [
{
"href": "http://openstack.example.com/v2/openstack/servers/2e9157dc-deea-4ee7-820a-640ecba32b5a",
"rel": "self"
},
{
"href": "http://openstack.example.com/openstack/servers/2e9157dc-deea-4ee7-820a-640ecba32b5a",
"rel": "bookmark"
}
],
"metadata": {
"My Server Name": "Apache1"
},
"name": "new-server-test",
"progress": 0,
"status": "ACTIVE",
"tenant_id": "openstack",
"updated": "2012-12-19T20:32:42Z",
"user_id": "fake"
}
}

View File

@ -1,49 +0,0 @@
{
"servers": [
{
"accessIPv4": "",
"accessIPv6": "",
"addresses": {},
"created": "2012-12-19T20:32:37Z",
"flavor": {
"id": "1",
"links": [
{
"href": "http://openstack.example.com/openstack/flavors/1",
"rel": "bookmark"
}
]
},
"hostId": "11c1ae0bb109cd0467c62e96917cfa2956a9f3c1dce9a6565d80f5eb",
"id": "625a1d37-3515-49ad-91e2-21075a1b2ccf",
"image": {
"id": "70a599e0-31e7-49b7-b260-868f441e862b",
"links": [
{
"href": "http://openstack.example.com/openstack/images/70a599e0-31e7-49b7-b260-868f441e862b",
"rel": "bookmark"
}
]
},
"links": [
{
"href": "http://openstack.example.com/v2/openstack/servers/625a1d37-3515-49ad-91e2-21075a1b2ccf",
"rel": "self"
},
{
"href": "http://openstack.example.com/openstack/servers/625a1d37-3515-49ad-91e2-21075a1b2ccf",
"rel": "bookmark"
}
],
"metadata": {
"My Server Name": "Apache1"
},
"name": "new-server-test",
"progress": 0,
"status": "ACTIVE",
"tenant_id": "openstack",
"updated": "2012-12-19T20:32:39Z",
"user_id": "fake"
}
]
}

View File

@ -1,18 +0,0 @@
{
"servers": [
{
"id": "120eed64-e7db-409c-b565-38ce2bc90021",
"links": [
{
"href": "http://openstack.example.com/v2/openstack/servers/120eed64-e7db-409c-b565-38ce2bc90021",
"rel": "self"
},
{
"href": "http://openstack.example.com/openstack/servers/120eed64-e7db-409c-b565-38ce2bc90021",
"rel": "bookmark"
}
],
"name": "new-server-test"
}
]
}

View File

@ -1,12 +1,14 @@
{
"server": {
"accessIPv4": "1.2.3.4",
"accessIPv6": "80fe::",
"addresses": {},
"created": "2013-09-24T14:39:00Z",
"flavor": {
"id": "1",
"links": [
{
"href": "http://openstack.example.com/flavors/1",
"href": "http://openstack.example.com/openstack/flavors/1",
"rel": "bookmark"
}
]
@ -17,7 +19,7 @@
"id": "70a599e0-31e7-49b7-b260-868f441e862b",
"links": [
{
"href": "http://openstack.example.com/images/70a599e0-31e7-49b7-b260-868f441e862b",
"href": "http://openstack.example.com/openstack/images/70a599e0-31e7-49b7-b260-868f441e862b",
"rel": "bookmark"
}
]
@ -25,11 +27,11 @@
"key_name": null,
"links": [
{
"href": "http://openstack.example.com/v3/servers/4bdee8c7-507f-40f2-8429-d301edd3791b",
"href": "http://openstack.example.com/v2/openstack/servers/4bdee8c7-507f-40f2-8429-d301edd3791b",
"rel": "self"
},
{
"href": "http://openstack.example.com/servers/4bdee8c7-507f-40f2-8429-d301edd3791b",
"href": "http://openstack.example.com/openstack/servers/4bdee8c7-507f-40f2-8429-d301edd3791b",
"rel": "bookmark"
}
],

View File

@ -1,13 +1,15 @@
{
"servers": [
{
"accessIPv4": "1.2.3.4",
"accessIPv6": "80fe::",
"addresses": {},
"created": "2013-09-24T14:44:01Z",
"flavor": {
"id": "1",
"links": [
{
"href": "http://openstack.example.com/flavors/1",
"href": "http://openstack.example.com/openstack/flavors/1",
"rel": "bookmark"
}
]
@ -18,7 +20,7 @@
"id": "70a599e0-31e7-49b7-b260-868f441e862b",
"links": [
{
"href": "http://openstack.example.com/images/70a599e0-31e7-49b7-b260-868f441e862b",
"href": "http://openstack.example.com/openstack/images/70a599e0-31e7-49b7-b260-868f441e862b",
"rel": "bookmark"
}
]
@ -26,11 +28,11 @@
"key_name": null,
"links": [
{
"href": "http://openstack.example.com/v3/servers/a747eac1-e3ed-446c-935a-c2a2853f919c",
"href": "http://openstack.example.com/v2/openstack/servers/a747eac1-e3ed-446c-935a-c2a2853f919c",
"rel": "self"
},
{
"href": "http://openstack.example.com/servers/a747eac1-e3ed-446c-935a-c2a2853f919c",
"href": "http://openstack.example.com/openstack/servers/a747eac1-e3ed-446c-935a-c2a2853f919c",
"rel": "bookmark"
}
],

View File

@ -4,11 +4,11 @@
"id": "b2a7068b-8aed-41a4-aa74-af8feb984bae",
"links": [
{
"href": "http://openstack.example.com/v3/servers/b2a7068b-8aed-41a4-aa74-af8feb984bae",
"href": "http://openstack.example.com/v2/openstack/servers/b2a7068b-8aed-41a4-aa74-af8feb984bae",
"rel": "self"
},
{
"href": "http://openstack.example.com/servers/b2a7068b-8aed-41a4-aa74-af8feb984bae",
"href": "http://openstack.example.com/openstack/servers/b2a7068b-8aed-41a4-aa74-af8feb984bae",
"rel": "bookmark"
}
],

View File

@ -1,47 +0,0 @@
{
"server": {
"accessIPv4": "",
"accessIPv6": "",
"addresses": {},
"created": "%(isotime)s",
"flavor": {
"id": "1",
"links": [
{
"href": "%(host)s/openstack/flavors/1",
"rel": "bookmark"
}
]
},
"hostId": "%(hostid)s",
"id": "%(id)s",
"image": {
"id": "%(uuid)s",
"links": [
{
"href": "%(host)s/openstack/images/%(uuid)s",
"rel": "bookmark"
}
]
},
"links": [
{
"href": "%(host)s/v2/openstack/servers/%(id)s",
"rel": "self"
},
{
"href": "%(host)s/openstack/servers/%(id)s",
"rel": "bookmark"
}
],
"metadata": {
"My Server Name": "Apache1"
},
"name": "new-server-test",
"progress": 0,
"status": "ACTIVE",
"tenant_id": "openstack",
"updated": "%(isotime)s",
"user_id": "fake"
}
}

View File

@ -1,49 +0,0 @@
{
"servers": [
{
"accessIPv4": "",
"accessIPv6": "",
"addresses": {},
"created": "%(isotime)s",
"flavor": {
"id": "1",
"links": [
{
"href": "%(host)s/openstack/flavors/1",
"rel": "bookmark"
}
]
},
"hostId": "%(hostid)s",
"id": "%(id)s",
"image": {
"id": "%(uuid)s",
"links": [
{
"href": "%(host)s/openstack/images/%(uuid)s",
"rel": "bookmark"
}
]
},
"links": [
{
"href": "%(host)s/v2/openstack/servers/%(id)s",
"rel": "self"
},
{
"href": "%(host)s/openstack/servers/%(id)s",
"rel": "bookmark"
}
],
"metadata": {
"My Server Name": "Apache1"
},
"name": "new-server-test",
"progress": 0,
"status": "ACTIVE",
"tenant_id": "openstack",
"updated": "%(isotime)s",
"user_id": "fake"
}
]
}

View File

@ -1,18 +0,0 @@
{
"servers": [
{
"id": "%(id)s",
"links": [
{
"href": "%(host)s/v2/openstack/servers/%(id)s",
"rel": "self"
},
{
"href": "%(host)s/openstack/servers/%(id)s",
"rel": "bookmark"
}
],
"name": "new-server-test"
}
]
}

View File

@ -37,7 +37,6 @@ from nova.cells import utils as cells_utils
from nova.cloudpipe import pipelib
from nova.compute import api as compute_api
from nova.compute import cells_api as cells_api
from nova.compute import vm_states
from nova.conductor import manager as conductor_manager
from nova.console import manager as console_manager # noqa - only for cfg
from nova import db
@ -191,51 +190,6 @@ class ServersSampleBase(ApiSampleTestBaseV2):
self.__class__._use_common_server_api_samples = orig_value
class ServersSampleHideAddressesJsonTest(ServersSampleBase):
sample_dir = None
extension_name = '.'.join(('nova.api.openstack.compute.contrib',
'hide_server_addresses',
'Hide_server_addresses'))
def setUp(self):
# We override osapi_hide_server_address_states in order
# to have an example of in the json samples of the
# addresses being hidden
CONF.set_override("osapi_hide_server_address_states",
[vm_states.ACTIVE])
super(ServersSampleHideAddressesJsonTest, self).setUp()
def test_servers_post(self):
return self._post_server()
def test_servers_get(self):
uuid = self.test_servers_post()
response = self._do_get('servers/%s' % uuid)
subs = self._get_regexes()
subs['hostid'] = '[a-f0-9]+'
subs['id'] = uuid
subs['hypervisor_hostname'] = r'[\w\.\-]+'
subs['mac_addr'] = '(?:[a-f0-9]{2}:){5}[a-f0-9]{2}'
self._verify_response('server-get-resp', subs, response, 200)
def test_servers_list(self):
uuid = self._post_server()
response = self._do_get('servers')
subs = self._get_regexes()
subs['id'] = uuid
self._verify_response('servers-list-resp', subs, response, 200)
def test_servers_details(self):
uuid = self._post_server()
response = self._do_get('servers/detail')
subs = self._get_regexes()
subs['hostid'] = '[a-f0-9]+'
subs['id'] = uuid
subs['hypervisor_hostname'] = r'[\w\.\-]+'
subs['mac_addr'] = '(?:[a-f0-9]{2}:){5}[a-f0-9]{2}'
self._verify_response('servers-details-resp', subs, response, 200)
class ServersSampleMultiStatusJsonTest(ServersSampleBase):
extension_name = '.'.join(('nova.api.openstack.compute.contrib',
'server_list_multi_status',

View File

@ -1,5 +1,7 @@
{
"server": {
"accessIPv4": "1.2.3.4",
"accessIPv6": "80fe::",
"addresses": {
},
"created": "%(isotime)s",
@ -7,7 +9,7 @@
"id": "1",
"links": [
{
"href": "%(host)s/flavors/1",
"href": "%(host)s/openstack/flavors/1",
"rel": "bookmark"
}
]
@ -18,7 +20,7 @@
"id": "%(uuid)s",
"links": [
{
"href": "%(host)s/images/%(uuid)s",
"href": "%(host)s/openstack/images/%(uuid)s",
"rel": "bookmark"
}
]
@ -26,11 +28,11 @@
"key_name": null,
"links": [
{
"href": "%(host)s/v3/servers/%(uuid)s",
"href": "%(host)s/v2/openstack/servers/%(uuid)s",
"rel": "self"
},
{
"href": "%(host)s/servers/%(uuid)s",
"href": "%(host)s/openstack/servers/%(uuid)s",
"rel": "bookmark"
}
],

View File

@ -1,13 +1,15 @@
{
"servers": [
{
"accessIPv4": "1.2.3.4",
"accessIPv6": "80fe::",
"addresses": {},
"created": "%(isotime)s",
"flavor": {
"id": "1",
"links": [
{
"href": "%(host)s/flavors/1",
"href": "%(host)s/openstack/flavors/1",
"rel": "bookmark"
}
]
@ -18,7 +20,7 @@
"id": "%(uuid)s",
"links": [
{
"href": "%(host)s/images/%(uuid)s",
"href": "%(host)s/openstack/images/%(uuid)s",
"rel": "bookmark"
}
]
@ -26,11 +28,11 @@
"key_name": null,
"links": [
{
"href": "%(host)s/v3/servers/%(uuid)s",
"href": "%(host)s/v2/openstack/servers/%(uuid)s",
"rel": "self"
},
{
"href": "%(host)s/servers/%(id)s",
"href": "%(host)s/openstack/servers/%(id)s",
"rel": "bookmark"
}
],

View File

@ -4,11 +4,11 @@
"id": "%(id)s",
"links": [
{
"href": "%(host)s/v3/servers/%(id)s",
"href": "%(host)s/v2/openstack/servers/%(id)s",
"rel": "self"
},
{
"href": "%(host)s/servers/%(id)s",
"href": "%(host)s/openstack/servers/%(id)s",
"rel": "bookmark"
}
],

View File

@ -21,6 +21,8 @@ from nova.tests.functional.v3 import test_servers
CONF = cfg.CONF
CONF.import_opt('osapi_hide_server_address_states',
'nova.api.openstack.compute.plugins.v3.hide_server_addresses')
CONF.import_opt('osapi_compute_extension',
'nova.api.openstack.compute.extensions')
class ServersSampleHideAddressesJsonTest(test_servers.ServersSampleJsonTest):
@ -29,8 +31,13 @@ class ServersSampleHideAddressesJsonTest(test_servers.ServersSampleJsonTest):
# test_servers.ServersSampleJsonTest does and so it won't default
# to the extension name
sample_dir = extension_name
extra_extensions_to_load = []
_api_version = 'v3'
def _get_flags(self):
f = super(ServersSampleHideAddressesJsonTest, self)._get_flags()
f['osapi_compute_extension'].append(
'nova.api.openstack.compute.contrib.hide_server_addresses.'
'Hide_server_addresses')
return f
def setUp(self):
# We override osapi_hide_server_address_states in order