From 12cd47abccc2d31c2c41600bdc4ad865e3e4f5e3 Mon Sep 17 00:00:00 2001 From: Roman Popelka Date: Thu, 7 Apr 2022 11:04:00 +0200 Subject: [PATCH] [sfc] Remove _get_server_port_id_and_ip4 & check_vm_connectivity As tempest.scenario.manager was announced stable interface in Tempest 27.0.0[1] it can be now reused in plugins. Removed methods: * _get_server_port_id_and_ip4 * check_vm_connectivity There is a slight difference between tempest's _get_server_port_id_and_ip4 and this one. Most changes are just fixes, without bigger logical interference. See some of the related patches below.[2][3] Etherpad concerning this effort: https://etherpad.opendev.org/p/tempest-scenario-manager-cleanup [1] https://docs.openstack.org/releasenotes/tempest/v27.0.0.html#release-notes-27-0-0 [2] https://opendev.org/openstack/tempest/commit/5c191faae78f52f876edba72484ea644d3df04fd [3] https://opendev.org/openstack/tempest/commit/95a3169e1782f31c794e56cb836c1d9476a0adf8 Change-Id: I6a7268784b8a915aab665db1bc00e764f40986ef --- .../sfc/tests/scenario/manager.py | 61 ------------------- .../sfc/tests/scenario/test_sfc.py | 2 +- 2 files changed, 1 insertion(+), 62 deletions(-) diff --git a/neutron_tempest_plugin/sfc/tests/scenario/manager.py b/neutron_tempest_plugin/sfc/tests/scenario/manager.py index 1b685eab..b4c9fe38 100644 --- a/neutron_tempest_plugin/sfc/tests/scenario/manager.py +++ b/neutron_tempest_plugin/sfc/tests/scenario/manager.py @@ -15,7 +15,6 @@ # under the License. from oslo_log import log -from oslo_utils import netutils from tempest import config from tempest.lib.common.utils import data_utils @@ -59,36 +58,6 @@ class ScenarioTest(manager.NetworkScenarioTest): if not isinstance(exc, lib_exc.SSHTimeout): LOG.debug('Network information on a devstack host') - def check_vm_connectivity(self, ip_address, - username=None, - private_key=None, - should_connect=True, - mtu=None): - """Check server connectivity - - :param ip_address: server to test against - :param username: server's ssh username - :param private_key: server's ssh private key to be used - :param should_connect: True/False indicates positive/negative test - positive - attempt ping and ssh - negative - attempt ping and fail if succeed - :param mtu: network MTU to use for connectivity validation - - :raises: AssertError if the result of the connectivity check does - not match the value of the should_connect param - """ - if should_connect: - msg = "Timed out waiting for %s to become reachable" % ip_address - else: - msg = "ip address %s is reachable" % ip_address - self.assertTrue(self.ping_ip_address(ip_address, - should_succeed=should_connect, - mtu=mtu), - msg=msg) - if should_connect: - # no need to check ssh for negative connectivity - self.get_remote_client(ip_address, username, private_key) - def check_public_network_connectivity(self, ip_address, username, private_key, should_connect=True, msg=None, servers=None, mtu=None): @@ -131,36 +100,6 @@ class NetworkScenarioTest(ScenarioTest): if not CONF.service_available.neutron: raise cls.skipException('Neutron not available') - def _get_server_port_id_and_ip4(self, server, ip_addr=None): - ports = self.os_admin.ports_client.list_ports( - device_id=server['id'], fixed_ip=ip_addr)['ports'] - # A port can have more than one IP address in some cases. - # If the network is dual-stack (IPv4 + IPv6), this port is associated - # with 2 subnets - p_status = ['ACTIVE'] - # NOTE(vsaienko) With Ironic, instances live on separate hardware - # servers. Neutron does not bind ports for Ironic instances, as a - # result the port remains in the DOWN state. - # TODO(vsaienko) remove once bug: #1599836 is resolved. - if getattr(CONF.service_available, 'ironic', False): - p_status.append('DOWN') - port_map = [(p["id"], fxip["ip_address"]) - for p in ports - for fxip in p["fixed_ips"] - if netutils.is_valid_ipv4(fxip["ip_address"]) and - p['status'] in p_status] - inactive = [p for p in ports if p['status'] != 'ACTIVE'] - if inactive: - LOG.warning("Instance has ports that are not ACTIVE: %s", inactive) - - self.assertNotEmpty(port_map, - "No IPv4 addresses found in: %s" % ports) - self.assertEqual(len(port_map), 1, - "Found multiple IPv4 addresses: %s. " - "Unable to determine which port to target." - % port_map) - return port_map[0] - def _create_router(self, client=None, tenant_id=None, namestart='router-smoke'): if not client: diff --git a/neutron_tempest_plugin/sfc/tests/scenario/test_sfc.py b/neutron_tempest_plugin/sfc/tests/scenario/test_sfc.py index 4523d502..20930063 100644 --- a/neutron_tempest_plugin/sfc/tests/scenario/test_sfc.py +++ b/neutron_tempest_plugin/sfc/tests/scenario/test_sfc.py @@ -82,7 +82,7 @@ class TestSfc(base.SfcScenarioTest): floating_ip = self._create_floating_ip( server) port_id, fixed_ip = ( - self._get_server_port_id_and_ip4(server)) + self.get_server_port_id_and_ip4(server)) return floating_ip, port_id, fixed_ip def _create_floating_ip(self, server, client=None):