[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 370d8bcea3)
This commit is contained in:
Slawek Kaplonski 2022-12-21 16:59:53 +01:00
parent 03abe3848b
commit b48992d387
1 changed files with 15 additions and 3 deletions

View File

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