summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSlawek Kaplonski <skaplons@redhat.com>2022-12-21 16:59:53 +0100
committerSlawek Kaplonski <skaplons@redhat.com>2022-12-22 15:46:14 +0000
commitb48992d3875b7352ede3995976197272fd8482bf (patch)
tree8353b0706a849691284050fa789791099401c890
parent03abe3848bdc3d2c1edb4b26ff5545cbdd5e4bc3 (diff)
downloadneutron-b48992d3875b7352ede3995976197272fd8482bf.tar.gz
[Fullstack] Wait 10 seconds to ensure that MAC address is configured
In Linuxbridge and OVS PortFixture, when port is created, in the fake vm's namespace it needs to have correct mac address configured. It seems that for some reason it's not properly configured sometimes and that may cause failure of e.g. DHCP tests. So this patch adds retries for 10 seconds to ensure that MAC address is configured to the one which should be. Closes-bug: #2000150 Change-Id: I8c6d226e626812c3ccf0a2681be68a5b080b3463 (cherry picked from commit 370d8bcea3ae728c1aacba7b36800ecd759f3f8e)
-rw-r--r--neutron/tests/common/net_helpers.py18
1 files changed, 15 insertions, 3 deletions
diff --git a/neutron/tests/common/net_helpers.py b/neutron/tests/common/net_helpers.py
index a070ec4eb4..43f3a40094 100644
--- a/neutron/tests/common/net_helpers.py
+++ b/neutron/tests/common/net_helpers.py
@@ -738,6 +738,19 @@ class PortFixture(fixtures.Fixture):
return VethPortFixture(bridge, namespace)
tools.fail('Unexpected bridge type: %s' % type(bridge))
+ def set_port_mac_address(self):
+
+ def set_mac_address():
+ self.port.link.set_address(self.mac)
+ return self.port.link.address.lower() == self.mac.lower()
+
+ try:
+ common_utils.wait_until_true(set_mac_address, timeout=10)
+ except common_utils.WaitTimeout:
+ LOG.error("MAC address of the port %s not set properly. "
+ "Requested MAC: %s; Actual MAC: %s",
+ self.port, self.mac, self.port.link.address)
+
class OVSBridgeFixture(fixtures.Fixture):
"""Create an OVS bridge.
@@ -850,7 +863,7 @@ class OVSPortFixture(PortFixture):
bridge_port.link.set_up()
self.qbr.addif(bridge_port)
- self.port.link.set_address(self.mac)
+ self.set_port_mac_address()
self.port.link.set_up()
# NOTE(jlibosva): Methods below are taken from nova.virt.libvirt.vif
@@ -941,8 +954,7 @@ class LinuxBridgePortFixture(PortFixture):
self.veth_fixture = self.useFixture(VethFixture())
self.br_port, self.port = self.veth_fixture.ports
- if self.mac:
- self.port.link.set_address(self.mac)
+ self.set_port_mac_address()
# bridge side
br_ip_wrapper = ip_lib.IPWrapper(self.bridge.namespace)