From 9736e446dc24627907b4f1527eccd3242db0dc13 Mon Sep 17 00:00:00 2001 From: elajkat Date: Mon, 10 Aug 2020 12:05:37 +0200 Subject: [PATCH] Rehome api tests for propagate_uplink_status Since [0] was merged propagate_uplink_status value is True, tempest (and neutron-tempest-plugin) is branchless, so test_create_port_without_propagate_uplink_status and test_create_port_with_propagate_uplink_status can be moved to fullstack tests to keep the coverage. Issues: - On ussuri the default value for propagate_uplink_status was False, so the test_create_port_without_propagate_uplink_status test asserts False. see [1] - On train there is no dhcp_scheduler_class attribute for EnvironmentDescription - On stein EnvironmentDescription has no has_placement & placement_port attributes, and the related logic. [0]: https://review.opendev.org/744208 [1]: https://review.opendev.org/744210 Change-Id: I8dfe76e75aa932e587d91f475317b7bac1f02ed9 Related-Bug: #1890842 (cherry picked from commit d2f8a2bea8eab491b626a66a847883fe8ac871e6) (cherry picked from commit 5ac50b220e69ad1717e3528545bb4279a7dcf187) --- neutron/tests/fullstack/resources/config.py | 6 +- .../tests/fullstack/resources/environment.py | 4 +- neutron/tests/fullstack/test_ports_api.py | 59 +++++++++++++++++++ 3 files changed, 66 insertions(+), 3 deletions(-) create mode 100644 neutron/tests/fullstack/test_ports_api.py diff --git a/neutron/tests/fullstack/resources/config.py b/neutron/tests/fullstack/resources/config.py index 8fb0a411ecc..cff778be57f 100644 --- a/neutron/tests/fullstack/resources/config.py +++ b/neutron/tests/fullstack/resources/config.py @@ -153,9 +153,11 @@ class ML2ConfigFixture(ConfigFixture): }, }) - extension_drivers = ['port_security'] + extension_drivers = {'port_security'} if env_desc.qos: - extension_drivers.append(qos_ext.QOS_EXT_DRIVER_ALIAS) + extension_drivers.add(qos_ext.QOS_EXT_DRIVER_ALIAS) + if env_desc.ml2_extension_drivers: + extension_drivers.update(env_desc.ml2_extension_drivers) self.config['ml2']['extension_drivers'] = ','.join(extension_drivers) diff --git a/neutron/tests/fullstack/resources/environment.py b/neutron/tests/fullstack/resources/environment.py index 99b6ff5e4bb..e3eb7f4af1b 100644 --- a/neutron/tests/fullstack/resources/environment.py +++ b/neutron/tests/fullstack/resources/environment.py @@ -39,7 +39,8 @@ class EnvironmentDescription(object): service_plugins='router', arp_responder=False, agent_down_time=75, router_scheduler=None, global_mtu=common_const.DEFAULT_NETWORK_MTU, - debug_iptables=False, log=False, report_bandwidths=False): + debug_iptables=False, log=False, report_bandwidths=False, + ml2_extension_drivers=None): self.network_type = network_type self.l2_pop = l2_pop self.qos = qos @@ -57,6 +58,7 @@ class EnvironmentDescription(object): self.service_plugins += ',qos' if self.log: self.service_plugins += ',log' + self.ml2_extension_drivers = ml2_extension_drivers @property def tunneling_enabled(self): diff --git a/neutron/tests/fullstack/test_ports_api.py b/neutron/tests/fullstack/test_ports_api.py new file mode 100644 index 00000000000..cdf634fd18e --- /dev/null +++ b/neutron/tests/fullstack/test_ports_api.py @@ -0,0 +1,59 @@ +# 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 neutron_lib import constants +from oslo_utils import uuidutils + +from neutron.tests.fullstack import base +from neutron.tests.fullstack.resources import environment +from neutron.tests.unit import testlib_api + +load_tests = testlib_api.module_load_tests + + +class TestPortsApi(base.BaseFullStackTestCase): + + scenarios = [ + ('Sriov Agent', {'l2_agent_type': constants.AGENT_TYPE_NIC_SWITCH})] + + def setUp(self): + host_descriptions = [ + environment.HostDescription( + l2_agent_type=self.l2_agent_type)] + env = environment.Environment( + environment.EnvironmentDescription( + agent_down_time=10, + ml2_extension_drivers=['uplink_status_propagation']), + host_descriptions) + super(TestPortsApi, self).setUp(env) + + self.tenant_id = uuidutils.generate_uuid() + self.network = self.safe_client.create_network(self.tenant_id) + self.safe_client.create_subnet( + self.tenant_id, self.network['id'], '20.0.0.0/24') + + def test_create_port_with_propagate_uplink_status(self): + body = self.safe_client.create_port( + self.tenant_id, self.network['id'], propagate_uplink_status=False) + self.assertFalse(body['propagate_uplink_status']) + body = self.safe_client.client.list_ports(id=body['id'])['ports'][0] + self.assertFalse(body['propagate_uplink_status']) + body = self.safe_client.client.show_port(body['id'])['port'] + self.assertFalse(body['propagate_uplink_status']) + + def test_create_port_without_propagate_uplink_status(self): + body = self.safe_client.create_port(self.tenant_id, self.network['id']) + self.assertFalse(body['propagate_uplink_status']) + body = self.safe_client.client.list_ports(id=body['id'])['ports'][0] + self.assertFalse(body['propagate_uplink_status']) + body = self.safe_client.client.show_port(body['id'])['port'] + self.assertFalse(body['propagate_uplink_status'])