diff options
author | Cedric Ollivier <cedric.ollivier@orange.com> | 2017-07-11 08:04:32 +0000 |
---|---|---|
committer | Gerrit Code Review <gerrit@opnfv.org> | 2017-07-11 08:04:32 +0000 |
commit | 88f7c0eaa0846b9480a13f7c142098cf6059b03b (patch) | |
tree | 78c653a46a132587b76c5786941dee55fb67b342 /functest/opnfv_tests | |
parent | 30569ceb06419dee62b8c2a25d589409397caf34 (diff) | |
parent | 053bc5f800de4c5543452f0cf27e26d6e5d9d96b (diff) |
Merge "Allow regex for blacklist scenarios/installers"
Diffstat (limited to 'functest/opnfv_tests')
-rw-r--r-- | functest/opnfv_tests/openstack/rally/blacklist.txt | 3 | ||||
-rw-r--r-- | functest/opnfv_tests/openstack/rally/rally.py | 44 |
2 files changed, 36 insertions, 11 deletions
diff --git a/functest/opnfv_tests/openstack/rally/blacklist.txt b/functest/opnfv_tests/openstack/rally/blacklist.txt index 3a17fa61..95bea2b7 100644 --- a/functest/opnfv_tests/openstack/rally/blacklist.txt +++ b/functest/opnfv_tests/openstack/rally/blacklist.txt @@ -1,8 +1,7 @@ scenario: - scenarios: - - os-nosdn-lxd-ha - - os-nosdn-lxd-noha + - '^os-nosdn-lxd-(no)?ha$' installers: - joid tests: diff --git a/functest/opnfv_tests/openstack/rally/rally.py b/functest/opnfv_tests/openstack/rally/rally.py index 24c9147c..d5acb1b2 100644 --- a/functest/opnfv_tests/openstack/rally/rally.py +++ b/functest/opnfv_tests/openstack/rally/rally.py @@ -188,21 +188,44 @@ class RallyBase(testcase.OSGCTestCase): installer_type = CONST.__getattribute__('INSTALLER_TYPE') deploy_scenario = CONST.__getattribute__('DEPLOY_SCENARIO') - if (bool(installer_type) * bool(deploy_scenario)): - if 'scenario' in black_list_yaml.keys(): - for item in black_list_yaml['scenario']: - scenarios = item['scenarios'] - installers = item['installers'] - if (deploy_scenario in scenarios and - installer_type in installers): - tests = item['tests'] - black_tests.extend(tests) + if (bool(installer_type) and bool(deploy_scenario) and + 'scenario' in black_list_yaml.keys()): + for item in black_list_yaml['scenario']: + scenarios = item['scenarios'] + installers = item['installers'] + in_it = RallyBase.in_iterable_re + if (in_it(deploy_scenario, scenarios) and + in_it(installer_type, installers)): + tests = item['tests'] + black_tests.extend(tests) except Exception: logger.debug("Scenario exclusion not applied.") return black_tests @staticmethod + def in_iterable_re(needle, haystack): + """ + Check if given needle is in the iterable haystack, using regex. + + :param needle: string to be matched + :param haystack: iterable of strings (optionally regex patterns) + :return: True if needle is eqial to any of the elements in haystack, + or if a nonempty regex pattern in haystack is found in needle. + """ + + # match without regex + if needle in haystack: + return True + + for pattern in haystack: + # match if regex pattern is set and found in the needle + if pattern and re.search(pattern, needle) is not None: + return True + else: + return False + + @staticmethod def excl_func(): black_tests = [] func_list = [] @@ -235,6 +258,9 @@ class RallyBase(testcase.OSGCTestCase): black_tests = list(set(RallyBase.excl_func() + RallyBase.excl_scenario())) + if black_tests: + logger.debug("Blacklisted tests: " + str(black_tests)) + include = True for cases_line in cases_file: if include: |