diff --git a/neutron_tempest_plugin/common/ip.py b/neutron_tempest_plugin/common/ip.py index 592f040d..a286d6bc 100644 --- a/neutron_tempest_plugin/common/ip.py +++ b/neutron_tempest_plugin/common/ip.py @@ -22,8 +22,10 @@ import netaddr from neutron_lib import constants from oslo_log import log from oslo_utils import excutils +from tempest.common import waiters from neutron_tempest_plugin.common import shell +from neutron_tempest_plugin.common import utils as common_utils LOG = log.getLogger(__name__) @@ -375,3 +377,25 @@ def find_valid_cidr(valid_cidr='10.0.0.0/8', used_cidr=None): if used_cidr: exception_str += ', used CIDR %s' % used_cidr raise Exception(exception_str) + + +def wait_for_interface_status(client, server_id, port_id, status, + ssh_client=None, mac_address=None): + """Waits for an interface to reach a given status and checks VM NIC + + This method enhances the tempest one. Apart from checking the interface + status returned by Nova, this methods access the VM to check if the NIC + interface is already detected by the kernel. + """ + body = waiters.wait_for_interface_status(client, server_id, port_id, + status) + + if ssh_client and mac_address: + ip_command = IPCommand(ssh_client) + common_utils.wait_until_true( + lambda: ip_command.get_nic_name_by_mac(mac_address), + timeout=10, + exception=RuntimeError('Interface with MAC %s not present in the ' + 'VM' % mac_address)) + + return body diff --git a/neutron_tempest_plugin/common/utils.py b/neutron_tempest_plugin/common/utils.py index 34e7464e..f03762c6 100644 --- a/neutron_tempest_plugin/common/utils.py +++ b/neutron_tempest_plugin/common/utils.py @@ -26,8 +26,10 @@ except ImportError: from urllib import parse as urlparse import eventlet + from tempest.lib import exceptions + SCHEMA_PORT_MAPPING = { "http": 80, "https": 443, diff --git a/neutron_tempest_plugin/scenario/test_ipv6.py b/neutron_tempest_plugin/scenario/test_ipv6.py index 844f995d..02e28463 100644 --- a/neutron_tempest_plugin/scenario/test_ipv6.py +++ b/neutron_tempest_plugin/scenario/test_ipv6.py @@ -16,7 +16,6 @@ from neutron_lib import constants as lib_constants from oslo_log import log from tempest.common import utils as tempest_utils -from tempest.common import waiters from tempest.lib.common.utils import data_utils from tempest.lib import decorators from tempest.lib import exceptions as lib_exc @@ -158,9 +157,10 @@ class IPv6Test(base.BaseTempestTestCase): # And plug VM to the second IPv6 network ipv6_port = self.create_port(ipv6_networks[1]) self.create_interface(vm['id'], ipv6_port['id']) - waiters.wait_for_interface_status( + ip.wait_for_interface_status( self.os_primary.interfaces_client, vm['id'], - ipv6_port['id'], lib_constants.PORT_STATUS_ACTIVE) + ipv6_port['id'], lib_constants.PORT_STATUS_ACTIVE, + ssh_client=ssh_client, mac_address=ipv6_port['mac_address']) self._test_ipv6_address_configured(ssh_client, vm, ipv6_port) @decorators.idempotent_id('b13e5408-5250-4a42-8e46-6996ce613e91')