Skip to content

Commit 9de68a7

Browse files
ralonsohkarelyatin
authored andcommitted
Cleanup before executing "test_get_all_devices"
The test "test_get_all_devices" is executed wiht concurrency=1. Before executing the test checks, this patch removes any existing macvtap interface present in the root namespace. Closes-Bug: #2012510 Change-Id: I98834fc6719caa4909c737f5fe37a8dc51035d6d (cherry picked from commit 0220236)
1 parent 0a7b9d3 commit 9de68a7

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

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

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616

1717
from neutron_lib import constants
1818

19+
from neutron.agent.linux import ip_lib
1920
from neutron.plugins.ml2.drivers.macvtap.agent import macvtap_neutron_agent
2021
from neutron.tests.common import net_helpers
2122
from neutron.tests.functional import base as functional_base
@@ -27,6 +28,16 @@ def setUp(self):
2728
self.mgr = macvtap_neutron_agent.MacvtapManager({})
2829

2930
def test_get_all_devices(self):
31+
# NOTE(ralonsoh): Clean-up before testing. This test is executed with
32+
# concurrency=1. That means no other test is being executed at the same
33+
# time. Because the macvtap interface must be created in the root
34+
# namespace (``MacvtapManager`` cannot handle namespaces), the test
35+
# deletes any previous existing interface.
36+
for mac in self.mgr.get_all_devices():
37+
devices = ip_lib.IPWrapper().get_devices()
38+
for device in (d for d in devices if d.address == mac):
39+
device.link.delete()
40+
3041
# Veth is simulating the hosts eth device. In this test it is used as
3142
# src_dev for the macvtap
3243
veth1, veth2 = self.useFixture(net_helpers.VethFixture()).ports

0 commit comments

Comments
 (0)