diff options
Diffstat (limited to 'testcases')
-rw-r--r-- | testcases/integration.py | 9 | ||||
-rw-r--r-- | testcases/testcase.py | 36 |
2 files changed, 24 insertions, 21 deletions
diff --git a/testcases/integration.py b/testcases/integration.py index 4b9dacfd..f2a5fecf 100644 --- a/testcases/integration.py +++ b/testcases/integration.py @@ -14,19 +14,10 @@ """IntegrationTestCase class """ -import os -import time import logging -import copy -import re from collections import OrderedDict from testcases import TestCase -from conf import settings as S -from tools import namespace -from tools import veth -from tools.teststepstools import TestStepsTools -from core.loader import Loader class IntegrationTestCase(TestCase): """IntegrationTestCase class diff --git a/testcases/testcase.py b/testcases/testcase.py index 00164ea2..18ad4240 100644 --- a/testcases/testcase.py +++ b/testcases/testcase.py @@ -32,6 +32,9 @@ from core.results.results_constants import ResultsConstants from tools import tasks from tools import hugepages from tools import functions +from tools import namespace +from tools import veth +from tools.teststepstools import TestStepsTools from tools.pkt_gen.trafficgen.trafficgenhelper import TRAFFIC_DEFAULTS CHECK_PREFIX = 'validate_' @@ -66,6 +69,7 @@ class TestCase(object): self._step_vnf_list = {} self._step_result = [] self._step_status = None + self._testcase_run_time = None # store all GUEST_ specific settings to keep original values before their expansion for key in S.__dict__: @@ -75,14 +79,21 @@ class TestCase(object): self._update_settings('VSWITCH', cfg.get('vSwitch', S.getValue('VSWITCH'))) self._update_settings('VNF', cfg.get('VNF', S.getValue('VNF'))) self._update_settings('TRAFFICGEN', cfg.get('Trafficgen', S.getValue('TRAFFICGEN'))) - self._update_settings('TEST_PARAMS', cfg.get('Parameters', S.getValue('TEST_PARAMS'))) + test_params = copy.deepcopy(S.getValue('TEST_PARAMS')) + tc_test_params = cfg.get('Parameters', S.getValue('TEST_PARAMS')) + test_params.update(tc_test_params) + self._update_settings('TEST_PARAMS', test_params) + S.check_test_params() + + # override all redefined GUEST_ values to have them expanded correctly + tmp_test_params = copy.deepcopy(S.getValue('TEST_PARAMS')) + for key in tmp_test_params: + if key.startswith('GUEST_'): + S.setValue(key, S.getValue(key)) + S.getValue('TEST_PARAMS').pop(key) # update global settings functions.settings_update_paths() - guest_loopback = get_test_param('guest_loopback', None) - if guest_loopback: - # we can put just one item, it'll be expanded automatically for all VMs - self._update_settings('GUEST_LOOPBACK', [guest_loopback]) # set test parameters; CLI options take precedence to testcase settings self._logger = logging.getLogger(__name__) @@ -168,7 +179,9 @@ class TestCase(object): self._traffic['l2'] = S.getValue(self._tunnel_type.upper() + '_FRAME_L2') self._traffic['l3'] = S.getValue(self._tunnel_type.upper() + '_FRAME_L3') self._traffic['l4'] = S.getValue(self._tunnel_type.upper() + '_FRAME_L4') - elif S.getValue('NICS')[0]['type'] == 'vf' or S.getValue('NICS')[1]['type'] == 'vf': + elif len(S.getValue('NICS')) and \ + (S.getValue('NICS')[0]['type'] == 'vf' or + S.getValue('NICS')[1]['type'] == 'vf'): mac1 = S.getValue('NICS')[0]['mac'] mac2 = S.getValue('NICS')[1]['mac'] if mac1 and mac2: @@ -270,22 +283,20 @@ class TestCase(object): # 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) + 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) + veth.del_veth_port(port1, port2) os.rmdir('/tmp/veth') def run_report(self): @@ -337,7 +348,8 @@ class TestCase(object): self.run_finalize() self._testcase_run_time = time.strftime("%H:%M:%S", - time.gmtime(time.time() - self._testcase_start_time)) + time.gmtime(time.time() - + self._testcase_start_time)) logging.info("Testcase execution time: " + self._testcase_run_time) # report test results self.run_report() @@ -352,7 +364,7 @@ class TestCase(object): """ orig_value = S.getValue(param) if orig_value != value: - self._settings_original[param] = orig_value + self._settings_original[param] = copy.deepcopy(orig_value) S.setValue(param, value) def _append_results(self, results): |