示例#1
0
def create_generate_tasks_file(tests_by_task: Dict,
                               generate_config: GenerateConfig,
                               repeat_config: RepeatConfig,
                               evg_api: Optional[EvergreenApi],
                               task_prefix: str = 'burn_in',
                               include_gen_task: bool = True) -> str:
    """
    Create an Evergreen generate.tasks file to run the given tasks and tests.

    :param tests_by_task: Dictionary of tests and tasks to run.
    :param generate_config: Information about how burn_in should generate tasks.
    :param repeat_config: Information about how burn_in should repeat tests.
    :param evg_api: Evergreen api.
    :param task_prefix: Prefix to start generated task's name with.
    :param include_gen_task: Should the generating task be included in the display task.
    :returns: Configuration to pass to 'generate.tasks'.
    """
    build_variant = BuildVariant(generate_config.run_build_variant)
    create_generate_tasks_config(build_variant,
                                 tests_by_task,
                                 generate_config,
                                 repeat_config,
                                 evg_api,
                                 include_gen_task=include_gen_task,
                                 task_prefix=task_prefix)

    shrub_project = ShrubProject.empty()
    shrub_project.add_build_variant(build_variant)

    if not validate_task_generation_limit(shrub_project):
        sys.exit(1)

    return shrub_project.json()
示例#2
0
    def build(self, config_file_name: str) -> GeneratedConfiguration:
        """
        Build the specified configuration and return the files needed to create it.

        :param config_file_name: Filename to use for evergreen configuration.
        :return: Dictionary of files and contents that are needed to create configuration.
        """
        for build_variant in self.build_variants.values():
            self.shrub_config.add_build_variant(build_variant)
        if not validate_task_generation_limit(self.shrub_config):
            raise ValueError("Attempting to generate more than max tasks in single generator")

        self.generated_files.append(GeneratedFile(config_file_name, self.shrub_config.json()))
        return GeneratedConfiguration(self.generated_files)
    def create_generate_tasks_configuration(self, tests_by_task: Dict[str, TaskInfo]) -> str:
        """
        Create the configuration with the configuration to generate the burn_in tasks.

        :param tests_by_task: Dictionary of tasks and test to generate.
        :return: Configuration to use to create generated tasks.
        """
        build_variant = BuildVariant(self.generate_config.run_build_variant)
        self.add_config_for_build_variant(build_variant, tests_by_task)

        shrub_project = ShrubProject.empty()
        shrub_project.add_build_variant(build_variant)

        if not validate_task_generation_limit(shrub_project):
            sys.exit(1)

        return shrub_project.json()
示例#4
0
    def execute(self, tests_by_task: Dict[str, TaskInfo]) -> None:
        """
        Execute the given tests in the given tasks.

        :param tests_by_task: Dictionary of tasks to run with tests to run in each.
        """

        build_variant = BuildVariant(self.generate_config.run_build_variant)
        self.generate_tasks_for_variant(tests_by_task, build_variant)

        shrub_project = ShrubProject.empty()
        shrub_project.add_build_variant(build_variant)
        if not validate_task_generation_limit(shrub_project):
            sys.exit(1)

        assert self.generate_tasks_file is not None
        if self.generate_tasks_file:
            write_file(self.generate_tasks_file, shrub_project.json())
示例#5
0
def burn_in(task_expansions: Dict[str, Any], evg_conf: EvergreenProjectConfig,
            evergreen_api: RetryingEvergreenApi, repos: List[Repo]):
    """
    Execute main program.

    :param task_expansions: Dictionary of expansions for the running task.
    :param evg_conf: Evergreen configuration.
    :param evergreen_api: Evergreen.py object.
    :param repos: Git repositories.
    """
    shrub_project = ShrubProject.empty()
    build_variant_map = _create_evg_build_variant_map(task_expansions)
    _generate_evg_tasks(evergreen_api, shrub_project, task_expansions,
                        build_variant_map, repos, evg_conf)

    if not validate_task_generation_limit(shrub_project):
        sys.exit(1)
    write_file_to_dir(CONFIG_DIRECTORY, CONFIG_FILE, shrub_project.json())
def main(build_variant, run_build_variant, distro, project,
         generate_tasks_file, evg_api_config, verbose, task_id):
    """
    Run new or changed tests in repeated mode to validate their stability.

    Running burn_in_tests_multiversion will run new or changed tests against the appropriate generated multiversion
    suites. The purpose of these tests are to signal bugs in the generated multiversion suites as these tasks are
    excluded from the required build variants and are only run in certain daily build variants. As such, we only expect
    the burn-in multiversion tests to be run once for each binary version configuration, and `--repeat-*` arguments
    should be None when executing this script.

    There are two modes that burn_in_tests_multiversion can run in:

    (1) Normal mode: by default burn_in_tests will attempt to run all detected tests the
    configured number of times. This is useful if you have a test or tests you would like to
    check before submitting a patch to evergreen.

    (2) By specifying the `--generate-tasks-file`, burn_in_tests will run generate a configuration
    file that can then be sent to the Evergreen 'generate.tasks' command to create evergreen tasks
    to do all the test executions. This is the mode used to run tests in patch builds.

    NOTE: There is currently a limit of the number of tasks burn_in_tests will attempt to generate
    in evergreen. The limit is 1000. If you change enough tests that more than 1000 tasks would
    be generated, burn_in_test will fail. This is to avoid generating more tasks than evergreen
    can handle.
    \f

    :param build_variant: Build variant to query tasks from.
    :param run_build_variant:Build variant to actually run against.
    :param distro: Distro to run tests on.
    :param project: Project to run tests on.
    :param generate_tasks_file: Create a generate tasks configuration in this file.
    :param evg_api_config: Location of configuration file to connect to evergreen.
    :param verbose: Log extra debug information.
    """
    _configure_logging(verbose)

    evg_conf = parse_evergreen_file(EVERGREEN_FILE)
    generate_config = GenerateConfig(build_variant=build_variant,
                                     run_build_variant=run_build_variant,
                                     distro=distro,
                                     project=project,
                                     task_id=task_id)  # yapf: disable
    generate_config.validate(evg_conf)

    repos = [Repo(x) for x in DEFAULT_REPO_LOCATIONS if os.path.isdir(x)]
    evg_api = RetryingEvergreenApi.get_api(config_file=evg_api_config)

    change_detector = EvergreenFileChangeDetector(task_id, evg_api)
    changed_tests = change_detector.find_changed_tests(repos)
    tests_by_task = create_tests_by_task(generate_config.build_variant,
                                         evg_conf, changed_tests)
    LOGGER.debug("tests and tasks found", tests_by_task=tests_by_task)

    multiversion_tasks = evg_conf.get_task_names_by_tag(
        MULTIVERSION_PASSTHROUGH_TAG)
    LOGGER.debug("Multiversion tasks by tag",
                 tasks=multiversion_tasks,
                 tag=MULTIVERSION_PASSTHROUGH_TAG)
    # We expect the number of suites with MULTIVERSION_PASSTHROUGH_TAG to be the same as in
    # multiversion_suites. Multiversion passthrough suites must include
    # MULTIVERSION_CONFIG_KEY as a root level key and must be set to true.
    multiversion_suites = get_named_suites_with_root_level_key(
        MULTIVERSION_CONFIG_KEY)
    assert len(multiversion_tasks) == len(multiversion_suites)

    build_variant = create_multiversion_generate_tasks_config(
        tests_by_task, evg_api, generate_config)
    shrub_project = ShrubProject.empty()
    shrub_project.add_build_variant(build_variant)

    if not validate_task_generation_limit(shrub_project):
        sys.exit(1)

    write_file(generate_tasks_file, shrub_project.json())