Merge virtual interface 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 virtual interface functional tests.
Previously there was no functional tests of virtual interface in v2.1.

There is difference between v2 and v2.1 as extension "OS-EXT-VIF-NET"
is missing in v2.1.
As v2,1 has been released in Kilo, it is too late to fix that difference
in v2.1 base. That fix will go with microversion -
I3caca80a6c010b86150909126f4545425ed99e11
Due to that sample files are different for v2 and v2.1.

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.

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

Change-Id: I7097483cb57ed785b01fddb4f832e453f71987fd
This commit is contained in:
ghanshyam
2015-08-19 16:29:14 +09:00
committed by Ghanshyam Mann
parent caf0f8388b
commit b026b1ad13
6 changed files with 51 additions and 57 deletions

View File

@@ -1,8 +0,0 @@
{
"virtual_interfaces": [
{
"id": "cec8b9bb-5d22-4104-b3c8-4c35db3210a6",
"mac_address": "fa:16:3e:3c:ce:6f"
}
]
}

View File

@@ -1,8 +0,0 @@
{
"virtual_interfaces": [
{
"id": "%(id)s",
"mac_address": "%(mac_addr)s"
}
]
}

View File

@@ -192,21 +192,6 @@ class LimitsSampleJsonTest(ApiSampleTestBaseV2):
self._verify_response('limit-get-resp', subs, response, 200)
class VirtualInterfacesJsonTest(ServersSampleBase):
extension_name = ("nova.api.openstack.compute.legacy_v2.contrib"
".virtual_interfaces.Virtual_interfaces")
def test_vifs_list(self):
uuid = self._post_server()
response = self._do_get('servers/%s/os-virtual-interfaces' % uuid)
subs = self._get_regexes()
subs['mac_addr'] = '(?:[a-f0-9]{2}:){5}[a-f0-9]{2}'
self._verify_response('vifs-list-resp', subs, response, 200)
class UsedLimitsSamplesJsonTest(ApiSampleTestBaseV2):
extension_name = ("nova.api.openstack.compute.legacy_v2.contrib."
"used_limits.Used_limits")
@@ -282,32 +267,6 @@ class ExtendedIpsMacSampleJsonTests(ServersSampleBase):
self._verify_response('servers-detail-resp', subs, response, 200)
class ExtendedVIFNetSampleJsonTests(ServersSampleBase):
extension_name = ("nova.api.openstack.compute.legacy_v2.contrib"
".extended_virtual_interfaces_net.Extended_virtual_interfaces_net")
def _get_flags(self):
f = super(ExtendedVIFNetSampleJsonTests, self)._get_flags()
f['osapi_compute_extension'] = CONF.osapi_compute_extension[:]
# extended_virtual_interfaces_net_update also
# needs virtual_interfaces to be loaded
f['osapi_compute_extension'].append(
('nova.api.openstack.compute.legacy_v2.contrib'
'.virtual_interfaces.Virtual_interfaces'))
return f
def test_vifs_list(self):
uuid = self._post_server()
response = self._do_get('servers/%s/os-virtual-interfaces' % uuid)
self.assertEqual(response.status_code, 200)
subs = self._get_regexes()
subs['mac_addr'] = '(?:[a-f0-9]{2}:){5}[a-f0-9]{2}'
self._verify_response('vifs-list-resp', subs, response, 200)
class ServerGroupQuotas_LimitsSampleJsonTest(LimitsSampleJsonTest):
sample_dir = None
extension_name = ("nova.api.openstack.compute.legacy_v2.contrib."

View File

@@ -0,0 +1,51 @@
# Copyright 2012 Nebula, Inc.
# Copyright 2013 IBM Corp.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
from oslo_config import cfg
from nova.tests.functional.api_sample_tests import test_servers
CONF = cfg.CONF
CONF.import_opt('osapi_compute_extension',
'nova.api.openstack.compute.legacy_v2.extensions')
class VirtualInterfacesJsonTest(test_servers.ServersSampleBase):
extension_name = "os-virtual-interfaces"
extra_extensions_to_load = ["os-access-ips"]
_api_version = 'v2'
def _get_flags(self):
f = super(VirtualInterfacesJsonTest, self)._get_flags()
f['osapi_compute_extension'] = CONF.osapi_compute_extension[:]
f['osapi_compute_extension'].append(
'nova.api.openstack.compute.legacy_v2.contrib.'
'virtual_interfaces.Virtual_interfaces')
f['osapi_compute_extension'].append(
'nova.api.openstack.compute.legacy_v2.contrib.'
'extended_virtual_interfaces_net.Extended_virtual_interfaces_net')
return f
def test_vifs_list(self):
uuid = self._post_server()
response = self._do_get('servers/%s/os-virtual-interfaces' % uuid)
subs = self._get_regexes()
subs['mac_addr'] = '(?:[a-f0-9]{2}:){5}[a-f0-9]{2}'
template = 'vifs-list-resp'
if self._test == 'v2':
template = 'vifs-list-resp-v2'
self._verify_response(template, subs, response, 200)