Add 'all' wildcard for releases

In order to avoid set releases key for each release we are supporting,
adding the release 'all' will filter the list of tests to be executed to
all releases, no matter the name. If we need to filter it for particular
releases, the 'all' release must be removed and then specify the list of
releases.

Change-Id: I139a948ce4934e06276cf590c9be6124a2574904
This commit is contained in:
Arx Cruz 2021-09-20 15:06:04 +02:00
parent 66682120a1
commit d257a2c0ba
3 changed files with 39 additions and 2 deletions

View File

@ -37,3 +37,10 @@ Release filter
The release filter, which is default to master, filter based on group or job
for an specific release.
Wildcard filter for releases
----------------------------
If in the releases list in the yaml file, the release ``all`` is set, that
means, it will not matter which release is passed to ``tempest-skip`` command,
it will be included in the final list.

View File

@ -47,7 +47,8 @@ class ListAllowedYaml(Lister):
x.get('name', '') == parsed_args.group, everything))
group_tests = list(filter(
lambda x:
parsed_args.release in x.get('releases', []),
any(r in ['all', parsed_args.release] for r in x.get(
'releases', [])),
group_tests))
if len(group_tests) > 0:
tests = group_tests
@ -58,7 +59,8 @@ class ListAllowedYaml(Lister):
everything))
job_tests = list(filter(
lambda x:
parsed_args.release in x.get('releases', []),
any(r in ['all', parsed_args.release] for r in x.get(
'releases', [])),
job_tests))
if len(job_tests) > 0:
tests = job_tests

View File

@ -28,6 +28,12 @@ class TestListYamlAllowed(base.TestCase):
- test_group_2
releases:
- master
- name: group2
tests:
- test_group_2_1
- test_group_2_2
releases:
- all
jobs:
- name: job1
tests:
@ -43,6 +49,12 @@ class TestListYamlAllowed(base.TestCase):
- test5
releases:
- master
- name: job3
tests:
- test6
- test7
releases:
- all
"""
self.path = self.write_yaml_file(self.list_file)
@ -119,6 +131,22 @@ class TestListYamlAllowed(base.TestCase):
list_tests = [test for test in cmd_result[1]]
self.assertEqual([], list_tests)
def test_list_allowed_job_with_release_all(self):
self.parser.job = 'job3'
self.parser.release = 'whatever'
cmd_result = self.cmd.take_action(self.parser)
expected = [('test6',), ('test7',)]
list_tests = [test for test in cmd_result[1]]
self.assertEqual(expected, list_tests)
def test_list_allowed_group_with_release_all(self):
self.parser.group = 'group2'
self.parser.release = 'whatever'
cmd_result = self.cmd.take_action(self.parser)
expected = [('test_group_2_1',), ('test_group_2_2',)]
list_tests = [test for test in cmd_result[1]]
self.assertEqual(expected, list_tests)
def test_list_allowed_with_no_release(self):
self.parser.release = 'no-exist'
cmd_result = self.cmd.take_action(self.parser)