Merge "Check interface is present in the VM"

This commit is contained in:
Zuul 2020-06-20 00:29:07 +00:00 committed by Gerrit Code Review
commit 4f06bc9643
3 changed files with 29 additions and 3 deletions

View File

@ -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

View File

@ -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,

View File

@ -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')