Check interface is present in the VM
This patch enhances the method "wait_for_interface_status" from
tempest. 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.
Change-Id: I5e411c72e0b6a8d96535adb04ff15e903454141c
Closes-Bug: #1883095
diff --git a/neutron_tempest_plugin/common/ip.py b/neutron_tempest_plugin/common/ip.py
index 592f040..a286d6b 100644
--- a/neutron_tempest_plugin/common/ip.py
+++ b/neutron_tempest_plugin/common/ip.py
@@ -22,8 +22,10 @@
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 @@
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 34e7464..f03762c 100644
--- a/neutron_tempest_plugin/common/utils.py
+++ b/neutron_tempest_plugin/common/utils.py
@@ -26,8 +26,10 @@
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 844f995..02e2846 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 @@
# 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')