From e22983576b15c5378b02435802b5b0800bbf430b Mon Sep 17 00:00:00 2001 From: He Jie Xu Date: Wed, 4 May 2016 18:17:23 +0800 Subject: [PATCH] Remove legacy v2 API functional tests This patch removes the functional tests which against on the legacy V2 API. Partially implements blueprint remove-legacy-v2-api-code Change-Id: Ie7189ddcb2b8bc103104045882055eb6b1fc8290 --- nova/tests/functional/api_paste_fixture.py | 11 ----- nova/tests/functional/test_extensions.py | 47 ------------------- nova/tests/functional/test_server_group.py | 44 +++++++---------- .../functional/wsgi/test_flavor_manage.py | 6 --- 4 files changed, 18 insertions(+), 90 deletions(-) delete mode 100644 nova/tests/functional/test_extensions.py diff --git a/nova/tests/functional/api_paste_fixture.py b/nova/tests/functional/api_paste_fixture.py index 165618971222..dad800865924 100644 --- a/nova/tests/functional/api_paste_fixture.py +++ b/nova/tests/functional/api_paste_fixture.py @@ -47,17 +47,6 @@ class ApiPasteV21Fixture(fixtures.Fixture): group='wsgi') -class ApiPasteLegacyV2Fixture(ApiPasteV21Fixture): - - def _replace_line(self, target_file, line): - # NOTE(johnthetubaguy) this is hack so we test the legacy_v2 code - # even though its disable by default in api-paste.ini - line = line.replace( - "/v2: openstack_compute_api_v21_legacy_v2_compatible", - "/v2: openstack_compute_api_legacy_v2") - target_file.write(line) - - class ApiPasteNoProjectId(ApiPasteV21Fixture): def _replace_line(self, target_file, line): diff --git a/nova/tests/functional/test_extensions.py b/nova/tests/functional/test_extensions.py deleted file mode 100644 index 28e9a698b5a3..000000000000 --- a/nova/tests/functional/test_extensions.py +++ /dev/null @@ -1,47 +0,0 @@ -# Copyright 2011 Justin Santa Barbara -# All Rights Reserved. -# -# 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 oslo_log import log as logging - -# Import extensions to pull in osapi_compute_extension CONF option used below. -from nova.tests.functional import api_paste_fixture -from nova.tests.functional import integrated_helpers - -CONF = cfg.CONF -LOG = logging.getLogger(__name__) - - -class ExtensionsTest(integrated_helpers._IntegratedTestBase): - api_major_version = 'v2' - - def setUp(self): - self.useFixture(api_paste_fixture.ApiPasteLegacyV2Fixture()) - super(ExtensionsTest, self).setUp() - - def _get_flags(self): - f = super(ExtensionsTest, self)._get_flags() - f['osapi_compute_extension'] = CONF.osapi_compute_extension[:] - f['osapi_compute_extension'].append( - 'nova.tests.unit.api.openstack.compute.legacy_v2.extensions.' - 'foxinsocks.Foxinsocks') - return f - - def test_get_foxnsocks(self): - # Simple check that fox-n-socks works. - response = self.api.api_request('/foxnsocks') - foxnsocks = response.content - LOG.debug("foxnsocks: %s" % foxnsocks) - self.assertEqual('Try to say this Mr. Knox, sir...', foxnsocks) diff --git a/nova/tests/functional/test_server_group.py b/nova/tests/functional/test_server_group.py index 1ac46427c2a1..9803589e4a44 100644 --- a/nova/tests/functional/test_server_group.py +++ b/nova/tests/functional/test_server_group.py @@ -24,7 +24,6 @@ from nova.db.sqlalchemy import api as db_api from nova import test from nova.tests import fixtures as nova_fixtures from nova.tests.functional.api import client -from nova.tests.functional import api_paste_fixture from nova.tests.unit import fake_network from nova.tests.unit import policy_fixture @@ -40,7 +39,7 @@ PROJECT_ID_ALT = "616c6c796f7572626173656172656f73" class ServerGroupTestBase(test.TestCase): REQUIRES_LOCKING = True - api_major_version = 'v2' + api_major_version = 'v2.1' microversion = None _image_ref_parameter = 'imageRef' _flavor_ref_parameter = 'flavorRef' @@ -70,13 +69,8 @@ class ServerGroupTestBase(test.TestCase): self.useFixture(policy_fixture.RealPolicyFixture()) - if self.api_major_version == 'v2.1': - api_fixture = self.useFixture(nova_fixtures.OSAPIFixture( - api_version='v2.1')) - else: - self.useFixture(api_paste_fixture.ApiPasteLegacyV2Fixture()) - api_fixture = self.useFixture(nova_fixtures.OSAPIFixture( - api_version='v2')) + api_fixture = self.useFixture(nova_fixtures.OSAPIFixture( + api_version='v2.1')) self.api = api_fixture.api self.api.microversion = self.microversion @@ -145,11 +139,10 @@ class ServerGroupTestBase(test.TestCase): return server -class ServerGroupTestV2(ServerGroupTestBase): - api_major_version = 'v2' +class ServerGroupTestV21(ServerGroupTestBase): def setUp(self): - super(ServerGroupTestV2, self).setUp() + super(ServerGroupTestV21, self).setUp() self.start_service('network') self.compute = self.start_service('compute') @@ -472,6 +465,15 @@ class ServerGroupTestV2(ServerGroupTestBase): host.start() + def test_soft_affinity_not_supported(self): + ex = self.assertRaises(client.OpenStackApiException, + self.api.post_server_groups, + {'name': 'fake-name-1', + 'policies': ['soft-affinity']}) + self.assertEqual(400, ex.response.status_code) + self.assertIn('Invalid input', ex.response.text) + self.assertIn('soft-affinity', ex.response.text) + class ServerGroupAffinityConfTest(ServerGroupTestBase): api_major_version = 'v2.1' @@ -557,20 +559,7 @@ class ServerGroupSoftAntiAffinityConfTest(ServerGroupTestBase): self.assertEqual(400, failed_server['fault']['code']) -class ServerGroupTestV21(ServerGroupTestV2): - api_major_version = 'v2.1' - - def test_soft_affinity_not_supported(self): - ex = self.assertRaises(client.OpenStackApiException, - self.api.post_server_groups, - {'name': 'fake-name-1', - 'policies': ['soft-affinity']}) - self.assertEqual(400, ex.response.status_code) - self.assertIn('Invalid input', ex.response.text) - self.assertIn('soft-affinity', ex.response.text) - - -class ServerGroupTestV215(ServerGroupTestV2): +class ServerGroupTestV215(ServerGroupTestV21): api_major_version = 'v2.1' microversion = '2.15' @@ -825,3 +814,6 @@ class ServerGroupTestV215(ServerGroupTestV2): self._evacuate_with_soft_anti_affinity_policies( self.soft_anti_affinity)) self.assertEqual(evacuated_server, other_server) + + def test_soft_affinity_not_supported(self): + pass diff --git a/nova/tests/functional/wsgi/test_flavor_manage.py b/nova/tests/functional/wsgi/test_flavor_manage.py index 73e5d2b92ae4..4aa1368625da 100644 --- a/nova/tests/functional/wsgi/test_flavor_manage.py +++ b/nova/tests/functional/wsgi/test_flavor_manage.py @@ -24,7 +24,6 @@ from nova import exception as ex from nova import objects from nova import test from nova.tests import fixtures as nova_fixtures -from nova.tests.functional import api_paste_fixture from nova.tests.functional import integrated_helpers as helper from nova.tests.unit import policy_fixture @@ -84,11 +83,6 @@ class FlavorManageFullstack(testscenarios.WithScenarios, test.TestCase): # test v2.1 base microversion ('v2_1', { 'api_major_version': 'v2.1'}), - # test v2 with the v2 legacy code - ('v2legacy', { - 'api_major_version': 'v2', - '_additional_fixtures': [ - api_paste_fixture.ApiPasteLegacyV2Fixture]}) ] def setUp(self):