Ejemplo n.º 1
0
def create_generate_tasks_config(
        evg_config: Configuration,
        tests_by_task: Dict,
        generate_config: GenerateConfig,
        repeat_config: RepeatConfig,
        evg_api: Optional[EvergreenApi],
        include_gen_task: bool = True,
        task_prefix: str = "burn_in") -> Configuration:
    # pylint: disable=too-many-arguments,too-many-locals
    """
    Create the config for the Evergreen generate.tasks file.

    :param evg_config: Shrub configuration to add to.
    :param tests_by_task: Dictionary of tests to generate tasks for.
    :param generate_config: Configuration of what to generate.
    :param repeat_config: Configuration of how to repeat tests.
    :param evg_api: Evergreen API.
    :param include_gen_task: Should generating task be include in display task.
    :param task_prefix: Prefix all task names with this.
    :return: Shrub configuration with added tasks.
    """
    task_list = TaskList(evg_config)
    resmoke_options = repeat_config.generate_resmoke_options()
    for task in sorted(tests_by_task):
        test_list = tests_by_task[task]["tests"]
        for index, test in enumerate(test_list):
            # TODO: Extract multiversion related code into separate tooling - SERVER-47137
            multiversion_path = tests_by_task[task].get("use_multiversion")
            display_task_name = tests_by_task[task]["display_task_name"]
            task_runtime_stats = _get_task_runtime_history(
                evg_api, generate_config.project, display_task_name,
                generate_config.build_variant)
            resmoke_args = tests_by_task[task]["resmoke_args"]
            distro = tests_by_task[task].get("distro", generate_config.distro)
            # Evergreen always uses a unix shell, even on Windows, so instead of using os.path.join
            # here, just use the forward slash; otherwise the path separator will be treated as
            # the escape character on Windows.
            sub_task_name = name_generated_task(
                f"{task_prefix}:{display_task_name}", index, len(test_list),
                generate_config.run_build_variant)
            LOGGER.debug("Generating sub-task", sub_task=sub_task_name)

            test_unix_style = test.replace('\\', '/')
            run_tests_vars = {
                "resmoke_args":
                f"{resmoke_args} {resmoke_options} {test_unix_style}"
            }
            if multiversion_path:
                run_tests_vars["task_path_suffix"] = multiversion_path
            timeout = _generate_timeouts(repeat_config, test,
                                         task_runtime_stats)
            commands = resmoke_commands("run tests", run_tests_vars, timeout,
                                        multiversion_path)

            task_list.add_task(sub_task_name, commands, ["compile"], distro)

    existing_tasks = [BURN_IN_TESTS_GEN_TASK] if include_gen_task else None
    task_list.add_to_variant(generate_config.run_build_variant,
                             BURN_IN_TESTS_TASK, existing_tasks)
    return evg_config
Ejemplo n.º 2
0
def create_generate_tasks_config(
        evg_config: Configuration,
        tests_by_task: Dict,
        generate_config: GenerateConfig,
        repeat_config: RepeatConfig,
        evg_api: Optional[EvergreenApi],
        include_gen_task: bool = True,
        task_prefix: str = "burn_in") -> Configuration:
    # pylint: disable=too-many-arguments,too-many-locals
    """
    Create the config for the Evergreen generate.tasks file.

    :param evg_config: Shrub configuration to add to.
    :param tests_by_task: Dictionary of tests to generate tasks for.
    :param generate_config: Configuration of what to generate.
    :param repeat_config: Configuration of how to repeat tests.
    :param evg_api: Evergreen API.
    :param include_gen_task: Should generating task be include in display task.
    :param task_prefix: Prefix all task names with this.
    :return: Shrub configuration with added tasks.
    """
    task_list = TaskList(evg_config)
    resmoke_options = repeat_config.generate_resmoke_options()
    for task in sorted(tests_by_task):
        multiversion_path = tests_by_task[task].get("use_multiversion")
        task_runtime_stats = _get_task_runtime_history(
            evg_api, generate_config.project, task,
            generate_config.build_variant)
        resmoke_args = tests_by_task[task]["resmoke_args"]
        test_list = tests_by_task[task]["tests"]
        distro = tests_by_task[task].get("distro", generate_config.distro)
        for index, test in enumerate(test_list):
            sub_task_name = name_generated_task(
                f"{task_prefix}:{task}", index, len(test_list),
                generate_config.run_build_variant)
            LOGGER.debug("Generating sub-task", sub_task=sub_task_name)

            run_tests_vars = {
                "resmoke_args": f"{resmoke_args} {resmoke_options} {test}"
            }
            if multiversion_path:
                run_tests_vars["task_path_suffix"] = multiversion_path
            timeout = _generate_timeouts(repeat_config.repeat_tests_secs, test,
                                         task_runtime_stats)
            commands = resmoke_commands("run tests", run_tests_vars, timeout,
                                        multiversion_path)

            task_list.add_task(sub_task_name, commands, ["compile"], distro)

    existing_tasks = [BURN_IN_TESTS_GEN_TASK] if include_gen_task else None
    task_list.add_to_variant(generate_config.run_build_variant,
                             BURN_IN_TESTS_TASK, existing_tasks)
    return evg_config