def create_multiversion_generate_tasks_config(evg_config: Configuration, tests_by_task: Dict, evg_api: EvergreenApi, generate_config: GenerateConfig) -> Configuration: """ Create the multiversion 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 evg_api: Evergreen API. :param generate_config: Configuration of what to generate. :return: Shrub configuration with added tasks. """ dt = DisplayTaskDefinition(BURN_IN_MULTIVERSION_TASK) if tests_by_task: # Get the multiversion suites that will run in as part of burn_in_multiversion. multiversion_suites = get_named_suites_with_root_level_key(MULTIVERSION_CONFIG_KEY) for suite in multiversion_suites: idx = 0 if suite["origin"] not in tests_by_task.keys(): # Only generate burn in multiversion tasks for suites that would run the detected # changed tests. continue LOGGER.debug("Generating multiversion suite", suite=suite["multiversion_name"]) # We hardcode the number of fallback sub suites and the target resmoke time here # since burn_in_tests cares about individual tests and not entire suites. The config # options here are purely used to generate the proper multiversion suites to run # tests against. config_options = { "suite": suite["origin"], "fallback_num_sub_suites": 1, "project": generate_config.project, "build_variant": generate_config.build_variant, "task_id": generate_config.task_id, "task_name": suite["multiversion_name"], "target_resmoke_time": 60, } config_options.update(gen_resmoke.DEFAULT_CONFIG_VALUES) config_generator = gen_multiversion.EvergreenConfigGenerator( evg_api, evg_config, gen_resmoke.ConfigOptions(config_options)) test_list = tests_by_task[suite["origin"]]["tests"] for test in test_list: # Exclude files that should be blacklisted from multiversion testing. files_to_exclude = gen_multiversion.get_exclude_files(suite["multiversion_name"], TASK_PATH_SUFFIX) LOGGER.debug("Files to exclude", files_to_exclude=files_to_exclude, test=test, suite=suite["multiversion_name"]) if test not in files_to_exclude: # Generate the multiversion tasks for each test. config_generator.generate_evg_tasks(test, idx) idx += 1 dt.execution_tasks(config_generator.task_names) evg_config.variant(generate_config.build_variant).tasks(config_generator.task_specs) dt.execution_task(f"{BURN_IN_MULTIVERSION_TASK}_gen") evg_config.variant(generate_config.build_variant).display_task(dt) return evg_config
def create_generate_tasks_config( evg_config: Configuration, tests_by_task: Dict, generate_config: GenerateConfig, repeat_config: RepeatConfig, evg_api: Optional[EvergreenApi], evg_project_config: EvergreenProjectConfig, 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): if task in evg_project_config.get_task_names_by_tag(RANDOM_MULTIVERSION_REPLSETS_TAG): # Exclude files that should be blacklisted from multiversion testing. task_name = gen_resmoke.remove_gen_suffix(task) files_to_exclude = gen_multiversion.get_exclude_files(task_name, TASK_PATH_SUFFIX) if test in files_to_exclude: LOGGER.debug("Files to exclude", files_to_exclude=files_to_exclude, test=test, suite=task) continue 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