From b026b1ad13dc6c5849360e19a2205736f6ac0bd8 Mon Sep 17 00:00:00 2001 From: ghanshyam Date: Wed, 19 Aug 2015 16:29:14 +0900 Subject: [PATCH] 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 --- .../os-virtual-interfaces/vifs-list-resp.json | 8 --- .../vifs-list-resp-v2.json} | 0 .../vifs-list-resp-v2.json.tpl} | 0 .../vifs-list-resp.json.tpl | 8 --- .../legacy_v2/test_api_samples.py | 41 --------------- .../test_virtual_interfaces.py | 51 +++++++++++++++++++ 6 files changed, 51 insertions(+), 57 deletions(-) delete mode 100644 doc/api_samples/legacy_v2/os-virtual-interfaces/vifs-list-resp.json rename doc/api_samples/{legacy_v2/OS-EXT-VIF-NET/vifs-list-resp.json => os-virtual-interfaces/vifs-list-resp-v2.json} (100%) rename nova/tests/functional/api_sample_tests/{legacy_v2/OS-EXT-VIF-NET/vifs-list-resp.json.tpl => api_samples/os-virtual-interfaces/vifs-list-resp-v2.json.tpl} (100%) delete mode 100644 nova/tests/functional/api_sample_tests/legacy_v2/os-virtual-interfaces/vifs-list-resp.json.tpl create mode 100644 nova/tests/functional/api_sample_tests/test_virtual_interfaces.py diff --git a/doc/api_samples/legacy_v2/os-virtual-interfaces/vifs-list-resp.json b/doc/api_samples/legacy_v2/os-virtual-interfaces/vifs-list-resp.json deleted file mode 100644 index c2e62b6ebd06..000000000000 --- a/doc/api_samples/legacy_v2/os-virtual-interfaces/vifs-list-resp.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "virtual_interfaces": [ - { - "id": "cec8b9bb-5d22-4104-b3c8-4c35db3210a6", - "mac_address": "fa:16:3e:3c:ce:6f" - } - ] -} \ No newline at end of file diff --git a/doc/api_samples/legacy_v2/OS-EXT-VIF-NET/vifs-list-resp.json b/doc/api_samples/os-virtual-interfaces/vifs-list-resp-v2.json similarity index 100% rename from doc/api_samples/legacy_v2/OS-EXT-VIF-NET/vifs-list-resp.json rename to doc/api_samples/os-virtual-interfaces/vifs-list-resp-v2.json diff --git a/nova/tests/functional/api_sample_tests/legacy_v2/OS-EXT-VIF-NET/vifs-list-resp.json.tpl b/nova/tests/functional/api_sample_tests/api_samples/os-virtual-interfaces/vifs-list-resp-v2.json.tpl similarity index 100% rename from nova/tests/functional/api_sample_tests/legacy_v2/OS-EXT-VIF-NET/vifs-list-resp.json.tpl rename to nova/tests/functional/api_sample_tests/api_samples/os-virtual-interfaces/vifs-list-resp-v2.json.tpl diff --git a/nova/tests/functional/api_sample_tests/legacy_v2/os-virtual-interfaces/vifs-list-resp.json.tpl b/nova/tests/functional/api_sample_tests/legacy_v2/os-virtual-interfaces/vifs-list-resp.json.tpl deleted file mode 100644 index af0b7e05a795..000000000000 --- a/nova/tests/functional/api_sample_tests/legacy_v2/os-virtual-interfaces/vifs-list-resp.json.tpl +++ /dev/null @@ -1,8 +0,0 @@ -{ - "virtual_interfaces": [ - { - "id": "%(id)s", - "mac_address": "%(mac_addr)s" - } - ] -} \ No newline at end of file diff --git a/nova/tests/functional/api_sample_tests/legacy_v2/test_api_samples.py b/nova/tests/functional/api_sample_tests/legacy_v2/test_api_samples.py index f2615b90c828..7f46fd304ebd 100644 --- a/nova/tests/functional/api_sample_tests/legacy_v2/test_api_samples.py +++ b/nova/tests/functional/api_sample_tests/legacy_v2/test_api_samples.py @@ -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." diff --git a/nova/tests/functional/api_sample_tests/test_virtual_interfaces.py b/nova/tests/functional/api_sample_tests/test_virtual_interfaces.py new file mode 100644 index 000000000000..46a35069840c --- /dev/null +++ b/nova/tests/functional/api_sample_tests/test_virtual_interfaces.py @@ -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)