Fix the filter with --job option
In order to make it work with all jobs being executed in zuul, the --job option must always be parsed. In this case, if you have the list of tests with the list of jobs empty, it should assume that the test should be skipped. If the list of job is not empty, it means the job should be skipped only on those jobs matching the list. For example: test a have an empty list of jobs, and test b have job1 in the list. Both tests should be skipped on job1, but only test a is skipped in job2. Change-Id: I0224223ab9217cba516d9ac7bd06d3ea60e63890
This commit is contained in:
parent
323f169a00
commit
041c18aaa1
|
@ -20,3 +20,10 @@ format::
|
|||
$ tempest-skip list yaml --file tempest_skip.yml --job job1
|
||||
$ tempest-skip list yaml --file tempest_skip.yml --release train --job job1
|
||||
|
||||
This will return any tests that match the job, as well as tests that doesn't
|
||||
have any job configured. This is required when you configure your zuul jobs to
|
||||
always parse the --job option. In this scenario, if a job2 is parsed, and there
|
||||
is no test with job2, it would return zero tests to be skipped, which is not
|
||||
the intent. The test with no job defined, means, skip everywhere, if you
|
||||
define the job in the test yaml file, it means, skip all the tests that doesn't
|
||||
have a job defined, plus this test
|
||||
|
|
|
@ -33,11 +33,8 @@ class ListYaml(Lister):
|
|||
tests = yaml_file.get('known_failures', [])
|
||||
|
||||
if parsed_args.job:
|
||||
tests = list(
|
||||
filter(
|
||||
lambda d: parsed_args.job in d.get('jobs', []), tests
|
||||
)
|
||||
)
|
||||
self.parsed_job = parsed_args.job
|
||||
tests = list(filter(self._filter_jobs, tests))
|
||||
|
||||
if parsed_args.release:
|
||||
new_tests = []
|
||||
|
@ -49,6 +46,13 @@ class ListYaml(Lister):
|
|||
|
||||
return (('Test name',), ((test['test'],) for test in tests))
|
||||
|
||||
def _filter_jobs(self, test):
|
||||
if not test.get('jobs', []):
|
||||
return True
|
||||
if self.parsed_job in test.get('jobs'):
|
||||
return True
|
||||
return False
|
||||
|
||||
def get_parser(self, prog_name):
|
||||
parser = super(ListYaml, self).get_parser(prog_name)
|
||||
parser.add_argument('--file', dest='file',
|
||||
|
|
|
@ -109,14 +109,17 @@ class TestListYaml(base.TestCase):
|
|||
def test_list_yaml_with_job(self):
|
||||
self.parser.job = 'job1'
|
||||
cmd_result = self.cmd.take_action(self.parser)
|
||||
exptected = [('tempest_skip.tests.test_list_yaml_3',)]
|
||||
exptected = [('tempest_skip.tests.test_list_yaml',),
|
||||
('tempest_skip.tests.test_list_yaml_2',),
|
||||
('tempest_skip.tests.test_list_yaml_3',)]
|
||||
list_tests = [test for test in cmd_result[1]]
|
||||
self.assertEqual(exptected, list_tests)
|
||||
|
||||
def test_list_yaml_with_job_not_found(self):
|
||||
self.parser.job = 'job2'
|
||||
cmd_result = self.cmd.take_action(self.parser)
|
||||
exptected = []
|
||||
exptected = [('tempest_skip.tests.test_list_yaml',),
|
||||
('tempest_skip.tests.test_list_yaml_2',)]
|
||||
list_tests = [test for test in cmd_result[1]]
|
||||
self.assertEqual(exptected, list_tests)
|
||||
|
||||
|
|
|
@ -2,6 +2,6 @@
|
|||
# of appearance. Changing the order has an impact on the overall integration
|
||||
# process, which may cause wedges in the gate later.
|
||||
|
||||
flake8<3.0.0 # MIT
|
||||
flake8==3.8.3 # MIT
|
||||
oslotest>=3.2.0 # Apache-2.0
|
||||
stestr>=1.1.0 # Apache-2.0
|
||||
stestr>=1.1.0 # Apache-2.0
|
||||
|
|
Loading…
Reference in New Issue