aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMartin Klozik <martin.klozik@tieto.com>2018-05-04 02:23:09 -0700
committerMartin Klozik <martin.klozik@tieto.com>2018-05-10 01:17:11 -0700
commit7224efa9539584690236218f5243b6b5c81daca9 (patch)
tree4208a3d891bc6619a1287932104c676366e95cad
parent03c55c5804a60b19c182752d38d90a29eefdc84a (diff)
bugfix: Fix evaluation order of parameters
This patch ensures, that testcase definition keywords vSwitch, Trafficgen, VNF and Tunnel Type will have the highest priority to override any values specified via ``Parameters`` section, CLI arguments or configuration files. JIRA: VSPERF-574 Change-Id: Ied799187d489325a32cc4854145fdf9901e7e3e2 Signed-off-by: Martin Klozik <martin.klozik@tieto.com> Reviewed-by: Al Morton <acmorton@att.com> Reviewed-by: Christian Trautman <ctrautma@redhat.com> Reviewed-by: Sridhar Rao <sridhar.rao@spirent.com> Reviewed-by: Richard Elias <richard.elias@tieto.com>
-rw-r--r--docs/testing/user/userguide/testusage.rst11
-rw-r--r--testcases/testcase.py15
2 files changed, 21 insertions, 5 deletions
diff --git a/docs/testing/user/userguide/testusage.rst b/docs/testing/user/userguide/testusage.rst
index 7884324a..c7cc1484 100644
--- a/docs/testing/user/userguide/testusage.rst
+++ b/docs/testing/user/userguide/testusage.rst
@@ -107,11 +107,12 @@ line argument, etc. Thus it is important to understand the order of configuratio
parameter evaluation. This "priority hierarchy" can be described like so
(1 = max priority):
-1. Testcase definition section ``Parameters``
-2. Command line arguments (e.g. ``--test-params``, ``--vswitch``, etc.)
-3. Environment variables (see ``--load-env`` argument)
-4. Custom configuration file specified via ``--conf-file`` argument
-5. Standard configuration files, where higher prefix number means higher
+1. Testcase definition keywords ``vSwitch``, ``Trafficgen``, ``VNF`` and ``Tunnel Type``
+2. Parameters inside testcase definition section ``Parameters``
+3. Command line arguments (e.g. ``--test-params``, ``--vswitch``, ``--trafficgen``, etc.)
+4. Environment variables (see ``--load-env`` argument)
+5. Custom configuration file specified via ``--conf-file`` argument
+6. Standard configuration files, where higher prefix number means higher
priority.
For example, if the same configuration parameter is defined in custom configuration
diff --git a/testcases/testcase.py b/testcases/testcase.py
index 68b8aec4..809e3b34 100644
--- a/testcases/testcase.py
+++ b/testcases/testcase.py
@@ -38,8 +38,17 @@ from tools import veth
from tools.teststepstools import TestStepsTools
from tools.llc_management import rmd
+# Validation methods required for integration TCs will have following prefix before the name
+# of original method.
CHECK_PREFIX = 'validate_'
+# Several parameters can be defined by both TC definition keywords and configuration parameters.
+# Following mapping table is used to correctly evaluate priority of testcase configuration, where
+# TC definition keywords (i.e. mapping table keys) have higher priority than appropriate TC
+# parameters (i.e. mapping table values). TC parameters can be defined within "Parameters"
+# section, via CLI parameters or within configuration files.
+MAPPING_TC_CFG2CONF = {'vSwitch':'VSWITCH', 'VNF':'VNF', 'Trafficgen':'TRAFFICGEN', 'Tunnel Type':'TUNNEL_TYPE'}
+
# pylint: disable=too-many-instance-attributes
class TestCase(object):
"""TestCase base class
@@ -89,6 +98,12 @@ class TestCase(object):
test_params = copy.deepcopy(S.getValue('TEST_PARAMS'))
tc_test_params = cfg.get('Parameters', S.getValue('TEST_PARAMS'))
test_params = merge_spec(test_params, tc_test_params)
+
+ # ensure that parameters from TC definition have the highest priority, see MAPPING_TC_CFG2CONF
+ for (cfg_param, param) in MAPPING_TC_CFG2CONF.items():
+ if cfg_param in cfg and param in test_params:
+ del test_params[param]
+
S.setValue('TEST_PARAMS', test_params)
S.check_test_params()