diff options
-rwxr-xr-x | buildscripts/evergreen_task_timeout.py | 1 | ||||
-rw-r--r-- | buildscripts/tests/util/test_teststats.py | 54 | ||||
-rw-r--r-- | buildscripts/timeouts/timeout_service.py | 5 | ||||
-rw-r--r-- | buildscripts/util/teststats.py | 4 |
4 files changed, 63 insertions, 1 deletions
diff --git a/buildscripts/evergreen_task_timeout.py b/buildscripts/evergreen_task_timeout.py index f35a6c6c897..f5eb60bf29e 100755 --- a/buildscripts/evergreen_task_timeout.py +++ b/buildscripts/evergreen_task_timeout.py @@ -378,6 +378,7 @@ def main(): os.path.expanduser(options.timeout_overrides_file)) enable_logging(verbose=False) + LOGGER.info("Determining timeouts", cli_args=options) def dependencies(binder: inject.Binder) -> None: binder.bind( diff --git a/buildscripts/tests/util/test_teststats.py b/buildscripts/tests/util/test_teststats.py index 4c54952368c..ec8c57d2174 100644 --- a/buildscripts/tests/util/test_teststats.py +++ b/buildscripts/tests/util/test_teststats.py @@ -21,6 +21,60 @@ class NormalizeTestNameTest(unittest.TestCase): under_test.normalize_test_name("\\home\\user\\test.js")) +class TestHistoricTestInfo(unittest.TestCase): + def test_total_test_runtime_not_passing_test_no_hooks(self): + test_info = under_test.HistoricTestInfo( + test_name='jstests/test.js', + num_pass=0, + avg_duration=0.0, + hooks=[], + ) + + self.assertEqual(0.0, test_info.total_test_runtime()) + + def test_total_test_runtime_not_passing_test_with_hooks(self): + test_info = under_test.HistoricTestInfo( + test_name='jstests/test.js', + num_pass=0, + avg_duration=0.0, + hooks=[ + under_test.HistoricHookInfo( + hook_id='test:hook', + num_pass=10, + avg_duration=5.0, + ), + ], + ) + + self.assertEqual(0.0, test_info.total_test_runtime()) + + def test_total_test_runtime_passing_test_no_hooks(self): + test_info = under_test.HistoricTestInfo( + test_name='jstests/test.js', + num_pass=10, + avg_duration=23.0, + hooks=[], + ) + + self.assertEqual(23.0, test_info.total_test_runtime()) + + def test_total_test_runtime_passing_test_with_hooks(self): + test_info = under_test.HistoricTestInfo( + test_name='jstests/test.js', + num_pass=10, + avg_duration=23.0, + hooks=[ + under_test.HistoricHookInfo( + hook_id='test:hook', + num_pass=10, + avg_duration=5.0, + ), + ], + ) + + self.assertEqual(28.0, test_info.total_test_runtime()) + + class TestHistoricTaskData(unittest.TestCase): def test_no_hooks(self): evg_results = [ diff --git a/buildscripts/timeouts/timeout_service.py b/buildscripts/timeouts/timeout_service.py index 68238010092..bc16e35f07e 100644 --- a/buildscripts/timeouts/timeout_service.py +++ b/buildscripts/timeouts/timeout_service.py @@ -125,11 +125,16 @@ class TimeoutService: :return: Historic test results if they exist. """ try: + LOGGER.info( + "Getting historic runtime information", evg_project=timeout_params.evg_project, + build_variant=timeout_params.build_variant, task_name=timeout_params.task_name) evg_stats = HistoricTaskData.from_s3( timeout_params.evg_project, timeout_params.task_name, timeout_params.build_variant) if not evg_stats: LOGGER.warning("No historic runtime information available") return None + LOGGER.info("Found historic runtime information", + evg_stats=evg_stats.historic_test_results) return evg_stats except Exception: # pylint: disable=broad-except # If we have any trouble getting the historic runtime information, log the issue, but diff --git a/buildscripts/util/teststats.py b/buildscripts/util/teststats.py index bc941917c2b..0d3a7f791b3 100644 --- a/buildscripts/util/teststats.py +++ b/buildscripts/util/teststats.py @@ -141,7 +141,9 @@ class HistoricTestInfo(NamedTuple): def total_test_runtime(self) -> float: """Get the average runtime of this test and it's non-task level hooks.""" - return self.avg_duration + self.total_hook_runtime(lambda h: not h.is_task_level_hook()) + if self.num_pass > 0: + return self.avg_duration + self.total_hook_runtime(lambda h: not h.is_task_level_hook()) + return 0.0 def get_hook_overhead(self) -> float: """Get the average runtime of this test and it's non-task level hooks.""" |