コード例 #1
0
ファイル: burn_in_tests.py プロジェクト: nferreira/mongo
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()
コード例 #2
0
    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()
コード例 #3
0
    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)
コード例 #4
0
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()
コード例 #5
0
    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()
コード例 #6
0
    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()
コード例 #7
0
    def build_fuzzer_sub_task(task_index: int, params: FuzzerGenTaskParams) -> Task:
        """
        Build a shrub task to run the fuzzer.

        :param task_index: Index of sub task being generated.
        :param params: Parameters describing how tasks should be generated.
        :return: Shrub task to run the fuzzer.
        """
        sub_task_name = taskname.name_generated_task(params.task_name, task_index, params.num_tasks,
                                                     params.variant)

        run_tests_vars = {
            "continue_on_failure": params.continue_on_failure,
            "resmoke_args": params.get_resmoke_args(),
            "resmoke_jobs_max": params.resmoke_jobs_max,
            "should_shuffle": params.should_shuffle,
            "require_multiversion_setup": params.require_multiversion_setup,
            "timeout_secs": params.timeout_secs,
            "task": params.task_name,
            "gen_task_config_location": params.config_location,
            "suite": params.suite,
        }  # yapf: disable

        timeout_info = TimeoutInfo.overridden(timeout=params.timeout_secs)

        commands = [
            timeout_info.cmd,
            FunctionCall("do setup"),
            FunctionCall(CONFIGURE_EVG_CREDENTIALS),
            FunctionCall("setup jstestfuzz"),
            FunctionCall("run jstestfuzz", params.jstestfuzz_params()),
            FunctionCall(RUN_GENERATED_TESTS, run_tests_vars)
        ]

        return Task(sub_task_name, commands, {TaskDependency(ARCHIVE_DIST_TEST_DEBUG_TASK)})
コード例 #8
0
ファイル: fuzzer_tasks.py プロジェクト: XueruiFa/mongo
    def build_fuzzer_sub_task(task_index: int, params: FuzzerGenTaskParams,
                              version: str) -> Task:
        """
        Build a shrub task to run the fuzzer.

        :param task_index: Index of sub task being generated.
        :param params: Parameters describing how tasks should be generated.
        :param version: Multiversion version to generate against.
        :return: Shrub task to run the fuzzer.
        """
        sub_task_name = taskname.name_generated_task(
            params.get_task_name(version), task_index, params.num_tasks,
            params.variant)

        suite_arg = f"--suites={params.suite}"
        run_tests_vars = {
            "continue_on_failure": params.continue_on_failure,
            "resmoke_args": f"{suite_arg} {params.get_resmoke_args()}",
            "resmoke_jobs_max": params.resmoke_jobs_max,
            "should_shuffle": params.should_shuffle,
            "require_multiversion": params.require_multiversion,
            "timeout_secs": params.timeout_secs,
            "task": params.get_task_name(version),
            "gen_task_config_location": params.config_location,
        }  # yapf: disable

        timeout_info = TimeoutInfo.overridden(timeout=params.timeout_secs)

        commands = []

        if params.require_multiversion:
            commands += [FunctionCall("git get project no modules")]

        commands += [
            timeout_info.cmd,
            FunctionCall("do setup"),
            FunctionCall("configure evergreen api credentials")
            if params.require_multiversion else None,
            FunctionCall("do multiversion setup")
            if params.require_multiversion else None,
            FunctionCall("setup jstestfuzz"),
            FunctionCall("run jstestfuzz", params.jstestfuzz_params()),
            FunctionCall("run generated tests", run_tests_vars)
        ]
        commands = [command for command in commands if command is not None]

        return Task(sub_task_name, commands,
                    {TaskDependency(ARCHIVE_DIST_TEST_DEBUG_TASK)})
コード例 #9
0
    def build_fuzzer_sub_task(task_index: int,
                              params: FuzzerGenTaskParams) -> Task:
        """
        Build a shrub task to run the fuzzer.

        :param task_index: Index of sub task being generated.
        :param params: Parameters describing how tasks should be generated.
        :return: Shrub task to run the fuzzer.
        """
        sub_task_name = taskname.name_generated_task(params.task_name,
                                                     task_index,
                                                     params.num_tasks,
                                                     params.variant)

        run_tests_vars = {
            "continue_on_failure": params.continue_on_failure,
            "resmoke_args": params.get_resmoke_args(),
            "resmoke_jobs_max": params.resmoke_jobs_max,
            "should_shuffle": params.should_shuffle,
            "require_multiversion_setup": params.require_multiversion_setup,
            "timeout_secs": params.timeout_secs,
            "task": params.task_name,
            # This expansion's name was shortened to reduce the overall size of
            # the generated configuration file
            # gtcl = gen_task_config_location
            "gtcl": params.config_location,
            "suite": params.suite,
        }  # yapf: disable

        timeout_info = TimeoutInfo.overridden(timeout=params.timeout_secs)

        commands = [
            timeout_info.cmd,
            FunctionCall("do setup"),
            FunctionCall(CONFIGURE_EVG_CREDENTIALS),
            FunctionCall("setup jstestfuzz"),
            FunctionCall("run jstestfuzz", params.jstestfuzz_params()),
            FunctionCall(RUN_GENERATED_TESTS, run_tests_vars),
            FunctionCall("minimize jstestfuzz")
        ]

        dependencies = {
            TaskDependency(dependency)
            for dependency in params.dependencies
        }

        return Task(sub_task_name, commands, dependencies)
コード例 #10
0
 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()