Merge "Add '--slowest' option to 'tempest run'"

This commit is contained in:
Zuul 2024-02-08 20:28:08 +00:00 committed by Gerrit Code Review
commit 16131abab5
2 changed files with 15 additions and 0 deletions

View File

@ -269,6 +269,8 @@ class TempestRun(command.Command):
return_code = commands.run_command(
**params, blacklist_file=ex_list,
whitelist_file=in_list, black_regex=ex_regex)
if parsed_args.slowest:
commands.slowest_command()
if return_code > 0:
sys.exit(return_code)
return return_code
@ -392,6 +394,9 @@ class TempestRun(command.Command):
help='Combine the output of this run with the '
"previous run's as a combined stream in the "
"stestr repository after it finish")
parser.add_argument('--slowest', action='store_true',
help='Show the longest running tests in the '
'stestr repository after it finishes')
parser.set_defaults(parallel=True)
return parser

View File

@ -225,6 +225,11 @@ class TestRunReturnCode(base.TestCase):
'%s=%s' % (self.exclude_list, path),
'--regex', 'fail'], 1)
def test_tempest_run_with_slowest(self):
out, err = self.assertRunExit(['tempest', 'run', '--regex', 'passing',
'--slowest'], 0)
self.assertRegex(str(out), r'Test id\s+Runtime \(s\)')
class TestOldArgRunReturnCode(TestRunReturnCode):
"""A class for testing deprecated but still supported args.
@ -363,6 +368,7 @@ class TestTakeAction(base.TestCase):
parsed_args.state = None
parsed_args.list_tests = False
parsed_args.config_file = path
parsed_args.slowest = False
with mock.patch('stestr.commands.run_command') as m:
m.return_value = 0
@ -393,6 +399,7 @@ class TestTakeAction(base.TestCase):
parsed_args.state = None
parsed_args.list_tests = False
parsed_args.config_file = path
parsed_args.slowest = False
with mock.patch('stestr.commands.run_command') as m:
m.return_value = 0
@ -409,6 +416,7 @@ class TestTakeAction(base.TestCase):
parsed_args.state = None
parsed_args.list_tests = False
parsed_args.config_file = ''
parsed_args.slowest = False
with mock.patch('stestr.commands.run_command') as m:
m.return_value = 0
@ -441,6 +449,7 @@ class TestTakeAction(base.TestCase):
parsed_args.state = True
parsed_args.list_tests = False
parsed_args.config_file = ''
parsed_args.slowest = False
with mock.patch('stestr.commands.run_command') as m:
m.return_value = 0
@ -460,6 +469,7 @@ class TestTakeAction(base.TestCase):
parsed_args.state = True
parsed_args.list_tests = False
parsed_args.config_file = path
parsed_args.slowest = False
with mock.patch('stestr.commands.run_command') as m:
m.return_value = 0