From 2ea4ed640824d24a6ab716b742842577066e87ba Mon Sep 17 00:00:00 2001 From: Stephen Finucane Date: Wed, 2 Oct 2019 11:39:34 +0100 Subject: [PATCH] nova-net: Remove 'USE_NEUTRON' from functional tests Does what it says on the tin. We can't remove the 'SampleNetworks' fixture yet since there are still nova-network tests and, sadly, XenAPI tests, using this. Soooon. Change-Id: I50c4c8ba300fe602fc18bdec8a71599b01a6b646 Signed-off-by: Stephen Finucane --- .../api_sample_tests/api_sample_base.py | 49 ----------- nova/tests/functional/integrated_helpers.py | 18 +--- nova/tests/functional/wsgi/test_interfaces.py | 85 +------------------ 3 files changed, 3 insertions(+), 149 deletions(-) diff --git a/nova/tests/functional/api_sample_tests/api_sample_base.py b/nova/tests/functional/api_sample_tests/api_sample_base.py index 30d8643f60d8..d9ac77f1ae0d 100644 --- a/nova/tests/functional/api_sample_tests/api_sample_base.py +++ b/nova/tests/functional/api_sample_tests/api_sample_base.py @@ -17,11 +17,9 @@ import os import testscenarios import nova.conf -from nova import test from nova.tests import fixtures from nova.tests.functional import api_paste_fixture from nova.tests.functional import api_samples_test_base -from nova.tests.unit import fake_network CONF = nova.conf.CONF @@ -102,13 +100,6 @@ class ApiSampleTestBaseV21(testscenarios.WithScenarios, self.USES_DB = False self.USES_DB_SELF = True - if not self.USE_NEUTRON: - # This is to enable the network quota which is being registered - # based on CONF.enable_network_quota. Need this to test the - # network quota in quota sample tests. - self.flags(enable_network_quota=True) - self.useFixture(fixtures.RegisterNetworkQuota()) - # super class call is delayed here so that we have the right # paste and conf before loading all the services, as we can't # change these later. @@ -122,50 +113,10 @@ class ApiSampleTestBaseV21(testscenarios.WithScenarios, super(ApiSampleTestBaseV21, self)._setup_services() - # TODO(stephenfin): Remove once we remove the few remaining - # nova-network-only APIs - if not self.USE_NEUTRON: - # self.network is only setup if USE_NEUTRON=False - self.useFixture(test.SampleNetworks(host=self.network.host)) - fake_network.stub_compute_with_ips(self) - self.useFixture(fixtures.SpawnIsSynchronousFixture()) # this is used to generate sample docs self.generate_samples = os.getenv('GENERATE_SAMPLES') is not None - # TODO(stephenfin): Remove once we remove the few remaining - # nova-network-only APIs - if not self.USE_NEUTRON: - # NOTE(mikal): this is used to stub away privsep helpers - def fake_noop(*args, **kwargs): - return '', '' - - def fake_true(*args, **kwargs): - return True - - self.stub_out('nova.privsep.linux_net.add_bridge', fake_noop) - self.stub_out('nova.privsep.linux_net.set_device_mtu', fake_noop) - self.stub_out('nova.privsep.linux_net.set_device_enabled', - fake_noop) - self.stub_out('nova.privsep.linux_net.set_device_macaddr', - fake_noop) - self.stub_out('nova.privsep.linux_net.routes_show', fake_noop) - self.stub_out('nova.privsep.linux_net.lookup_ip', fake_noop) - self.stub_out('nova.privsep.linux_net.change_ip', fake_noop) - self.stub_out('nova.privsep.linux_net.address_command_deprecated', - fake_noop) - self.stub_out('nova.privsep.linux_net.ipv4_forwarding_check', - fake_true) - self.stub_out('nova.privsep.linux_net.' - '_enable_ipv4_forwarding_inner', - fake_noop) - self.stub_out('nova.privsep.linux_net.add_vlan', fake_noop) - self.stub_out('nova.privsep.linux_net.bridge_setfd', fake_noop) - self.stub_out('nova.privsep.linux_net.bridge_disable_stp', - fake_noop) - self.stub_out('nova.privsep.linux_net.bridge_add_interface', - fake_noop) - if self.availability_zones: self.useFixture( fixtures.AvailabilityZoneFixture(self.availability_zones)) diff --git a/nova/tests/functional/integrated_helpers.py b/nova/tests/functional/integrated_helpers.py index 765ac62771f2..7bdd49dde7bf 100644 --- a/nova/tests/functional/integrated_helpers.py +++ b/nova/tests/functional/integrated_helpers.py @@ -220,12 +220,6 @@ class InstanceHelperMixin(object): class _IntegratedTestBase(test.TestCase): REQUIRES_LOCKING = True ADMIN_API = False - # Override this in subclasses which use the legacy nova-network service. - # New tests should rely on Neutron and old ones migrated to use this since - # nova-network is deprecated. - # TODO(stephenfin): Remove once we remove the few remaining - # nova-network-only APIs - USE_NEUTRON = True # This indicates whether to include the project ID in the URL for API # requests through OSAPIFixture. Overridden by subclasses. _use_project_id = False @@ -233,8 +227,6 @@ class _IntegratedTestBase(test.TestCase): def setUp(self): super(_IntegratedTestBase, self).setUp() - self.flags(use_neutron=self.USE_NEUTRON) - # NOTE(mikal): this is used to stub away privsep helpers def fake_noop(*args, **kwargs): return None @@ -245,9 +237,7 @@ class _IntegratedTestBase(test.TestCase): self.useFixture(cast_as_call.CastAsCall(self)) placement = self.useFixture(func_fixtures.PlacementFixture()) self.placement_api = placement.api - - if self.USE_NEUTRON: - self.neutron = self.useFixture(nova_fixtures.NeutronFixture(self)) + self.neutron = self.useFixture(nova_fixtures.NeutronFixture(self)) self._setup_services() @@ -265,13 +255,9 @@ class _IntegratedTestBase(test.TestCase): # which will result in us not doing the right thing. if 'cell1' in self.cell_mappings: self.flags(transport_url=self.cell_mappings['cell1'].transport_url) + self.conductor = self.start_service('conductor') - - if not self.USE_NEUTRON: - self.network = self.start_service('network', - manager=CONF.network_manager) self.scheduler = self._setup_scheduler_service() - self.compute = self._setup_compute_service() self.api_fixture = self.useFixture( diff --git a/nova/tests/functional/wsgi/test_interfaces.py b/nova/tests/functional/wsgi/test_interfaces.py index 18e56935d766..73bdf175418d 100644 --- a/nova/tests/functional/wsgi/test_interfaces.py +++ b/nova/tests/functional/wsgi/test_interfaces.py @@ -13,100 +13,17 @@ # 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_utils.fixture import uuidsentinel as uuids -from nova.tests import fixtures as nova_fixtures from nova.tests.functional.api import client -from nova.tests.functional import integrated_helpers from nova.tests.functional import test_servers -from nova.tests.unit import policy_fixture -def create_request_body(): - return { - "interfaceAttachment": { - "port_id": uuids.port, - "net_id": uuids.net, - "fixed_ips": [ - { - "ip_address": "192.168.1.3", - "subnet_id": uuids.subnet - } - ] - } - } - - -# TODO(stephenfin): Remove this test since it's nova-network only -class InterfaceFullstack(integrated_helpers._IntegratedTestBase): - """Tests for port interfaces command. - - Extension: os-interface - - os-interface adds a set of functions to the port interfaces - for the creation and deletion of port interfaces. - - POST /v2.1/{tenant_id}/servers/{server_id}/os-interface - DELETE /v2.1/{tenant_id}/servers/{server_id}/os-interface/{attachment_id} - - Functional Test Scope: - - This test starts the wsgi stack for the nova api services, uses an - in memory database to ensure the path through the wsgi layer to - the database. - - """ - api_major_version = 'v2.1' - USE_NEUTRON = False # nova-net only - _image_ref_parameter = 'imageRef' - _flavor_ref_parameter = 'flavorRef' - - def setUp(self): - super(InterfaceFullstack, self).setUp() - self.useFixture(policy_fixture.RealPolicyFixture()) - api_fixture = self.useFixture(nova_fixtures.OSAPIFixture()) - - self.api = api_fixture.api - - def test_interface_func_negative(self): - """Test port interface edge conditions. - - - Bogus body is a 400 - """ - # Create a server - server = self._build_minimal_create_server_request() - created_server = self.api.post_server({"server": server}) - created_server_id = created_server['id'] - - # Test for API failure conditions - # bad body is 400 - os_interface_url = '/servers/%s/os-interface' % created_server_id - - # Check in the case that both net_id and port_id are specified. - body = create_request_body() - del body['interfaceAttachment']['fixed_ips'] - resp = self.api.api_post(os_interface_url, body, - check_response_status=False) - self.assertEqual(400, resp.status) - - # Check in the case that fixed_ips is specified, - # but net_id is not specifed. - body = create_request_body() - del body['interfaceAttachment']['port_id'] - del body['interfaceAttachment']['net_id'] - resp = self.api.api_post(os_interface_url, body, - check_response_status=False) - self.assertEqual(400, resp.status) - - -class InterfaceFullstackWithNeutron(test_servers.ServersTestBase): +class InterfaceFullstack(test_servers.ServersTestBase): """Tests for port interfaces command. Functional Test Scope: - This test uses Neutron. os-interface API specifies a port ID created by Neutron. - """ api_major_version = 'v2.1'