Skip to content

Commit de561ba

Browse files
committed
Execute "IpMonitorTestCase" tests always inside a namespace
To improve the execution isolation of "IpMonitorTestCase", the test cases will be executed inside a network namespace only. Closes-Bug: #1991798 Change-Id: I69200f8236e65ea50d1ad3ac322441554634c9c3 (cherry picked from commit a8a43c8)
1 parent d890ad3 commit de561ba

File tree

1 file changed

+4
-18
lines changed

1 file changed

+4
-18
lines changed

neutron/tests/functional/agent/linux/test_ip_lib.py

Lines changed: 4 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@
2727
from oslo_utils import importutils
2828
from oslo_utils import uuidutils
2929
from pyroute2.iproute import linux as iproute_linux
30-
import testscenarios
3130
import testtools
3231

3332
from neutron.agent.common import async_process
@@ -697,19 +696,13 @@ def test_network_namespace_exists_ns_doesnt_exists_try_is_ready(self):
697696
try_is_ready=True))
698697

699698

700-
class IpMonitorTestCase(testscenarios.WithScenarios,
701-
functional_base.BaseLoggingTestCase):
702-
703-
scenarios = [
704-
('namespace', {'namespace': 'ns_' + uuidutils.generate_uuid()}),
705-
('no_namespace', {'namespace': None})
706-
]
699+
class IpMonitorTestCase(functional_base.BaseLoggingTestCase):
707700

708701
def setUp(self):
709702
super(IpMonitorTestCase, self).setUp()
710703
self.addCleanup(self._cleanup)
711-
if self.namespace:
712-
priv_ip_lib.create_netns(self.namespace)
704+
self.namespace = 'ns_' + uuidutils.generate_uuid()
705+
priv_ip_lib.create_netns(self.namespace)
713706
self.devices = [('int_' + uuidutils.generate_uuid())[
714707
:constants.DEVICE_NAME_MAX_LEN] for _ in range(5)]
715708
self.ip_wrapper = ip_lib.IPWrapper(self.namespace)
@@ -719,14 +712,7 @@ def setUp(self):
719712

720713
def _cleanup(self):
721714
self.proc.stop(kill_timeout=10, kill_signal=signal.SIGTERM)
722-
if self.namespace:
723-
priv_ip_lib.remove_netns(self.namespace)
724-
else:
725-
for device in self.devices:
726-
try:
727-
priv_ip_lib.delete_interface(device, self.namespace)
728-
except priv_ip_lib.NetworkInterfaceNotFound:
729-
pass
715+
priv_ip_lib.remove_netns(self.namespace)
730716

731717
@staticmethod
732718
def _normalize_module_name(name):

0 commit comments

Comments
 (0)