From fc09b7f0b6e036651fd4c101d9b8492c4cccfe0c Mon Sep 17 00:00:00 2001 From: Christian Trautman Date: Wed, 29 Jun 2016 11:22:41 -0400 Subject: Namespace_veth: Add funtionality for network namespace, veth ports Adds functionality for network namespaces and veth/peer ports to connect the namespaces. The namespaces are tracked outside of default Linux namespaces to prevent possible disruption of work outside of VSPerf where a user may create a namespace and the cleanup code deletes it. The cleanup code only removes namespaces and veth ports created inside the testcase. JIRA: VSPERF-310 Change-Id: If8881cafb119f38f052403a1de497e9660187d2e Signed-off-by: Christian Trautman --- testcases/integration.py | 7 +++++++ testcases/testcase.py | 20 ++++++++++++++++++++ 2 files changed, 27 insertions(+) (limited to 'testcases') diff --git a/testcases/integration.py b/testcases/integration.py index fdd8b09c..ffde5822 100644 --- a/testcases/integration.py +++ b/testcases/integration.py @@ -22,10 +22,13 @@ import copy from testcases import TestCase from conf import settings as S from collections import OrderedDict +from tools import namespace +from tools import veth from core.loader import Loader CHECK_PREFIX = 'validate_' + class IntegrationTestCase(TestCase): """IntegrationTestCase class """ @@ -115,6 +118,10 @@ class IntegrationTestCase(TestCase): step_ok = False if step[0] == 'vswitch': test_object = self._vswitch_ctl.get_vswitch() + elif step[0] == 'namespace': + test_object = namespace + elif step[0] == 'veth': + test_object = veth elif step[0] == 'trafficgen': test_object = self._traffic_ctl # in case of send_traffic method, ensure that specified diff --git a/testcases/testcase.py b/testcases/testcase.py index e5f8a14c..5f5c9358 100644 --- a/testcases/testcase.py +++ b/testcases/testcase.py @@ -234,6 +234,26 @@ class TestCase(object): # restore original settings S.load_from_dict(self._settings_original) + # cleanup any namespaces created + if os.path.isdir('/tmp/namespaces'): + import tools.namespace + namespace_list = os.listdir('/tmp/namespaces') + if len(namespace_list): + self._logger.info('Cleaning up namespaces') + for name in namespace_list: + tools.namespace.delete_namespace(name) + os.rmdir('/tmp/namespaces') + # cleanup any veth ports created + if os.path.isdir('/tmp/veth'): + import tools.veth + veth_list = os.listdir('/tmp/veth') + if len(veth_list): + self._logger.info('Cleaning up veth ports') + for eth in veth_list: + port1, port2 = eth.split('-') + tools.veth.del_veth_port(port1, port2) + os.rmdir('/tmp/veth') + def run_report(self): """ Report test results """ -- cgit 1.2.3-korg