Skip to content

Commit 2acac47

Browse files
committed
[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 370d8bc)
1 parent 5d4d692 commit 2acac47

File tree

1 file changed

+15
-3
lines changed

1 file changed

+15
-3
lines changed

neutron/tests/common/net_helpers.py

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -784,6 +784,19 @@ def get(cls, bridge, namespace=None, mac=None, port_id=None,
784784
return VethPortFixture(bridge, namespace)
785785
tools.fail('Unexpected bridge type: %s' % type(bridge))
786786

787+
def set_port_mac_address(self):
788+
789+
def set_mac_address():
790+
self.port.link.set_address(self.mac)
791+
return self.port.link.address.lower() == self.mac.lower()
792+
793+
try:
794+
common_utils.wait_until_true(set_mac_address, timeout=10)
795+
except common_utils.WaitTimeout:
796+
LOG.error("MAC address of the port %s not set properly. "
797+
"Requested MAC: %s; Actual MAC: %s",
798+
self.port, self.mac, self.port.link.address)
799+
787800

788801
class OVSBridgeFixture(fixtures.Fixture):
789802
"""Create an OVS bridge.
@@ -899,7 +912,7 @@ def hybrid_plug_port(self, port_name):
899912
bridge_port.link.set_up()
900913
self.qbr.addif(bridge_port.name)
901914

902-
self.port.link.set_address(self.mac)
915+
self.set_port_mac_address()
903916
self.port.link.set_up()
904917

905918
# NOTE(jlibosva): Methods below are taken from nova.virt.libvirt.vif
@@ -990,8 +1003,7 @@ def _setUp(self):
9901003
self.veth_fixture = self.useFixture(VethFixture())
9911004
self.br_port, self.port = self.veth_fixture.ports
9921005

993-
if self.mac:
994-
self.port.link.set_address(self.mac)
1006+
self.set_port_mac_address()
9951007

9961008
# bridge side
9971009
br_ip_wrapper = ip_lib.IPWrapper(self.bridge.namespace)

0 commit comments

Comments
 (0)