def generate_timeout_cmd( self, is_patch: bool, repeat_factor: int, test_timeout_factor: Optional[float] = None, task_timeout_factor: Optional[float] = None, use_default: bool = False) -> TimeoutInfo: """ Create the timeout info to use to create a timeout shrub command. :param is_patch: Whether the command is being created in a patch build. :param repeat_factor: How many times the suite will be repeated. :param test_timeout_factor: Scaling factor for test timeout. :param task_timeout_factor: Scaling factor for task timeout. :param use_default: Should the default timeout be used. :return: Timeout info for the task. """ if not self.is_specified or use_default: return TimeoutInfo.default_timeout() test_timeout = self.calculate_test_timeout(repeat_factor, test_timeout_factor) task_timeout = self.calculate_task_timeout(repeat_factor, task_timeout_factor) if is_patch and (test_timeout > MAX_EXPECTED_TIMEOUT or task_timeout > MAX_EXPECTED_TIMEOUT): frameinfo = getframeinfo(currentframe()) LOGGER.error( "This task looks like it is expected to run far longer than normal. This is " "likely due to setting the suite 'repeat' value very high. If you are sure " "this is something you want to do, comment this check out in your patch build " "and resubmit", repeat_value=repeat_factor, timeout=test_timeout, exec_timeout=task_timeout, code_file=frameinfo.filename, code_line=frameinfo.lineno, max_timeout=MAX_EXPECTED_TIMEOUT) raise ValueError("Failing due to expected runtime.") return TimeoutInfo.overridden(timeout=test_timeout, exec_timeout=task_timeout)
def _generate_timeouts( repeat_config: RepeatConfig, test: str, task_avg_test_runtime_stats: [TestStats]) -> TimeoutInfo: """ Add timeout.update command to list of commands for a burn in execution task. :param repeat_config: Information on how the test will repeat. :param test: Test name. :param task_avg_test_runtime_stats: Teststat data. :return: TimeoutInfo to use. """ if task_avg_test_runtime_stats: avg_test_runtime = _parse_avg_test_runtime( test, task_avg_test_runtime_stats) if avg_test_runtime: LOGGER.debug("Avg test runtime", test=test, runtime=avg_test_runtime) timeout = _calculate_timeout(avg_test_runtime) exec_timeout = _calculate_exec_timeout(repeat_config, avg_test_runtime) LOGGER.debug("Using timeout overrides", exec_timeout=exec_timeout, timeout=timeout) timeout_info = TimeoutInfo.overridden(exec_timeout, timeout) LOGGER.debug("Override runtime for test", test=test, timeout=timeout_info) return timeout_info return TimeoutInfo.default_timeout()
def generate_timeouts(self, test: str) -> TimeoutInfo: """ Add timeout.update command to list of commands for a burn in execution task. :param test: Test name. :return: TimeoutInfo to use. """ if self.task_runtime_stats: avg_test_runtime = _parse_avg_test_runtime(test, self.task_runtime_stats) if avg_test_runtime: LOGGER.debug("Avg test runtime", test=test, runtime=avg_test_runtime) timeout = _calculate_timeout(avg_test_runtime) exec_timeout = _calculate_exec_timeout(self.repeat_config, avg_test_runtime) LOGGER.debug("Using timeout overrides", exec_timeout=exec_timeout, timeout=timeout) timeout_info = TimeoutInfo.overridden(exec_timeout, timeout) LOGGER.debug("Override runtime for test", test=test, timeout=timeout_info) return timeout_info return TimeoutInfo.default_timeout()
def _get_timeout_command(self, max_test_runtime, expected_suite_runtime, use_default): """ Add an evergreen command to override the default timeouts to the list of commands. :param max_test_runtime: Maximum runtime of any test in the sub-suite. :param expected_suite_runtime: Expected runtime of the entire sub-suite. :param use_default: Use default timeouts. :return: Timeout information. """ repeat_factor = self.options.repeat_suites if (max_test_runtime or expected_suite_runtime) and not use_default: timeout = None exec_timeout = None if max_test_runtime: timeout = calculate_timeout(max_test_runtime, 3) * repeat_factor LOGGER.debug("Setting timeout", timeout=timeout, max_runtime=max_test_runtime, factor=repeat_factor) if expected_suite_runtime: exec_timeout = calculate_timeout(expected_suite_runtime, 3) * repeat_factor LOGGER.debug("Setting exec_timeout", exec_timeout=exec_timeout, suite_runtime=expected_suite_runtime, factor=repeat_factor) return TimeoutInfo.overridden(timeout=timeout, exec_timeout=exec_timeout) return TimeoutInfo.default_timeout()
def _generate_timeouts(repeat_tests_secs, test, task_avg_test_runtime_stats) -> TimeoutInfo: """ Add timeout.update command to list of commands for a burn in execution task. :param repeat_tests_secs: How long test will repeat for. :param test: Test name. :param task_avg_test_runtime_stats: Teststat data. :return: TimeoutInfo to use. """ if task_avg_test_runtime_stats: avg_test_runtime = _parse_avg_test_runtime( test, task_avg_test_runtime_stats) if avg_test_runtime: LOGGER.debug("Avg test runtime", test=test, runtime=avg_test_runtime) timeout = _calculate_timeout(avg_test_runtime) exec_timeout = _calculate_exec_timeout(repeat_tests_secs, avg_test_runtime) timeout_info = TimeoutInfo.overridden(exec_timeout, timeout) LOGGER.debug("Override runtime for test", test=test, timeout=timeout_info) return timeout_info return TimeoutInfo.default_timeout()
def _get_timeout_command(self, max_test_runtime: int, expected_suite_runtime: int, use_default: bool) -> TimeoutInfo: """ Add an evergreen command to override the default timeouts to the list of commands. :param max_test_runtime: Maximum runtime of any test in the sub-suite. :param expected_suite_runtime: Expected runtime of the entire sub-suite. :param use_default: Use default timeouts. :return: Timeout information. """ repeat_factor = self.options.repeat_suites if (max_test_runtime or expected_suite_runtime) and not use_default: timeout = None exec_timeout = None if max_test_runtime: timeout = calculate_timeout(max_test_runtime, 3) * repeat_factor LOGGER.debug("Setting timeout", timeout=timeout, max_runtime=max_test_runtime, factor=repeat_factor) if expected_suite_runtime: exec_timeout = calculate_timeout(expected_suite_runtime, 3) * repeat_factor LOGGER.debug("Setting exec_timeout", exec_timeout=exec_timeout, suite_runtime=expected_suite_runtime, factor=repeat_factor) if self.options.is_patch and \ (timeout > MAX_EXPECTED_TIMEOUT or exec_timeout > MAX_EXPECTED_TIMEOUT): frameinfo = getframeinfo(currentframe()) LOGGER.error( "This task looks like it is expected to run far longer than normal. This is " "likely due to setting the suite 'repeat' value very high. If you are sure " "this is something you want to do, comment this check out in your patch build " "and resubmit", repeat_value=repeat_factor, timeout=timeout, exec_timeout=exec_timeout, code_file=frameinfo.filename, code_line=frameinfo.lineno, max_timeout=MAX_EXPECTED_TIMEOUT) raise ValueError("Failing due to expected runtime.") return TimeoutInfo.overridden(timeout=timeout, exec_timeout=exec_timeout) return TimeoutInfo.default_timeout()
def build_defualt_timeout(self) -> TimeoutInfo: """Generate a timeout command that can be used if historic timing info is missing.""" if self.timeout_secs is not None or self.exec_timeout_secs is not None: return TimeoutInfo.overridden(self.exec_timeout_secs, self.timeout_secs) return TimeoutInfo.default_timeout()