Skip to content

Commit 1530d2f

Browse files
authored
Merge pull request #164 from stackhpc/upstream/2023.1-2024-07-08
Synchronise 2023.1 with upstream
2 parents b57f96c + 65be5a9 commit 1530d2f

File tree

1 file changed

+23
-2
lines changed

1 file changed

+23
-2
lines changed

neutron/tests/functional/plugins/ml2/drivers/macvtap/agent/test_macvtap_neutron_agent.py

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@
1616

1717
from neutron_lib import constants
1818

19+
from neutron.agent.linux import ip_lib
20+
from neutron.common import utils as common_utils
1921
from neutron.plugins.ml2.drivers.macvtap.agent import macvtap_neutron_agent
2022
from neutron.tests.common import net_helpers
2123
from neutron.tests.functional import base as functional_base
@@ -27,11 +29,30 @@ def setUp(self):
2729
self.mgr = macvtap_neutron_agent.MacvtapManager({})
2830

2931
def test_get_all_devices(self):
32+
# NOTE(ralonsoh): Clean-up before testing. This test is executed with
33+
# concurrency=1. That means no other test is being executed at the same
34+
# time. Because the macvtap interface must be created in the root
35+
# namespace (``MacvtapManager`` cannot handle namespaces), the test
36+
# deletes any previous existing interface.
37+
for mac in self.mgr.get_all_devices():
38+
devices = ip_lib.IPWrapper().get_devices()
39+
for device in (d for d in devices if d.address == mac):
40+
device.link.delete()
41+
3042
# Veth is simulating the hosts eth device. In this test it is used as
3143
# src_dev for the macvtap
3244
veth1, veth2 = self.useFixture(net_helpers.VethFixture()).ports
3345
macvtap = self.useFixture(net_helpers.MacvtapFixture(
3446
src_dev=veth1.name, mode='bridge',
3547
prefix=constants.MACVTAP_DEVICE_PREFIX)).ip_dev
36-
self.assertEqual(set([macvtap.link.address]),
37-
self.mgr.get_all_devices())
48+
try:
49+
common_utils.wait_until_true(
50+
lambda: {macvtap.link.address} == self.mgr.get_all_devices(),
51+
timeout=5)
52+
except common_utils.WaitTimeout:
53+
msg = 'MacVTap address: %s, read devices: %s\n' % (
54+
macvtap.link.address, self.mgr.get_all_devices())
55+
for device in ip_lib.IPWrapper().get_devices():
56+
msg += ' Device %s, MAC: %s' % (device.name,
57+
device.link.address)
58+
self.fail(msg)

0 commit comments

Comments
 (0)