aboutsummaryrefslogtreecommitdiffstats
path: root/testcases
diff options
context:
space:
mode:
authorMartin Klozik <martinx.klozik@intel.com>2017-08-14 14:27:06 +0000
committerGerrit Code Review <gerrit@opnfv.org>2017-08-14 14:27:06 +0000
commit2a4d03a1c5634c7d8b54bd9bda6c14b7a683de6e (patch)
tree5588bbaff2b78881d1aafab0ec40502e5c3dedf7 /testcases
parent73025baf2e393c61c59957e8714d2ddd54d25e51 (diff)
parent6961a6fa333ca2cff055d7d7a889876263b673f5 (diff)
Merge "tests: L3, L4 and VxLAN tests for OVS & VPP"
Diffstat (limited to 'testcases')
-rw-r--r--testcases/testcase.py27
1 files changed, 19 insertions, 8 deletions
diff --git a/testcases/testcase.py b/testcases/testcase.py
index 17bce38e..a213bbe8 100644
--- a/testcases/testcase.py
+++ b/testcases/testcase.py
@@ -681,8 +681,7 @@ class TestCase(object):
if self._step_vnf_list[vnf]:
self._step_vnf_list[vnf].stop()
- @staticmethod
- def step_eval_param(param, STEP):
+ def step_eval_param(self, param, STEP):
# pylint: disable=invalid-name
""" Helper function for #STEP macro evaluation
"""
@@ -694,28 +693,40 @@ class TestCase(object):
# pylint: disable=eval-used
tmp_val = str(eval(macro[1:]))
param = param.replace(macro, tmp_val)
+
+ # evaluate references to vsperf configuration options
+ macros = re.findall(r'\$(([\w\-]+)(\[[\w\[\]\-\'\"]+\])*)', param)
+ if macros:
+ for macro in macros:
+ # pylint: disable=eval-used
+ try:
+ tmp_val = str(eval("S.getValue('{}'){}".format(macro[1], macro[2])))
+ param = param.replace('${}'.format(macro[0]), tmp_val)
+ # ignore that required option can't be evaluated
+ except (IndexError, KeyError, AttributeError):
+ self._logger.debug("Skipping %s as it isn't a configuration "
+ "parameter.", '${}'.format(macro[0]))
return param
elif isinstance(param, list) or isinstance(param, tuple):
tmp_list = []
for item in param:
- tmp_list.append(TestCase.step_eval_param(item, STEP))
+ tmp_list.append(self.step_eval_param(item, STEP))
return tmp_list
elif isinstance(param, dict):
tmp_dict = {}
for (key, value) in param.items():
- tmp_dict[key] = TestCase.step_eval_param(value, STEP)
+ tmp_dict[key] = self.step_eval_param(value, STEP)
return tmp_dict
else:
return param
- @staticmethod
- def step_eval_params(params, step_result):
+ def step_eval_params(self, params, step_result):
""" Evaluates referrences to results from previous steps
"""
eval_params = []
# evaluate all parameters if needed
for param in params:
- eval_params.append(TestCase.step_eval_param(param, step_result))
+ eval_params.append(self.step_eval_param(param, step_result))
return eval_params
def step_run(self):
@@ -788,7 +799,7 @@ class TestCase(object):
try:
# eval parameters, but use only valid step_results
# to support negative indexes
- step_params = TestCase.step_eval_params(step[2:], self._step_result[:i])
+ step_params = self.step_eval_params(step[2:], self._step_result[:i])
step_log = '{} {}'.format(' '.join(step[:2]), step_params)
self._logger.debug("Step %s '%s' start", i, step_log)
self._step_result[i] = test_method(*step_params)