Ejemplo n.º 1
0
def _generate_evg_tasks(evergreen_api, shrub_config, expansions_file_data, build_variant_map, repos,
                        evg_conf):
    """
    Generate burn in tests tasks for a given shrub config and group of buildvariants.

    :param evergreen_api: Evergreen.py object.
    :param shrub_config: Shrub config object that the build variants will be built upon.
    :param expansions_file_data: Config data file to use.
    :param build_variant_map: Map of base buildvariants to their generated buildvariant.
    :param repos: Git repositories.
    """
    for build_variant, run_build_variant in build_variant_map.items():
        config_options = _get_config_options(expansions_file_data, build_variant, run_build_variant)
        tests_by_task = create_tests_by_task(build_variant, repos, evg_conf)
        if tests_by_task:
            _generate_evg_build_variant(shrub_config, build_variant, run_build_variant,
                                        expansions_file_data["build_variant"], evg_conf)
            gen_config = GenerateConfig(build_variant, config_options.project, run_build_variant,
                                        config_options.distro).validate(evg_conf)
            repeat_config = RepeatConfig(repeat_tests_min=config_options.repeat_tests_min,
                                         repeat_tests_max=config_options.repeat_tests_max,
                                         repeat_tests_secs=config_options.repeat_tests_secs)

            create_generate_tasks_config(shrub_config, tests_by_task, gen_config, repeat_config,
                                         evergreen_api, evg_conf, include_gen_task=False)
Ejemplo n.º 2
0
    def test_no_tasks_given(self):
        build_variant = BuildVariant("build variant")
        gen_config = MagicMock(run_build_variant="variant")
        repeat_config = MagicMock()

        under_test.create_generate_tasks_config(build_variant, {}, gen_config, repeat_config, None)

        evg_config_dict = build_variant.as_dict()
        self.assertEqual(0, len(evg_config_dict["tasks"]))
Ejemplo n.º 3
0
    def test_n_task_m_test(self):
        n_tasks = 3
        n_tests = 5
        build_variant = BuildVariant("build variant")
        gen_config = MagicMock(run_build_variant="variant", distro=None)
        repeat_config = MagicMock()
        tests_by_task = create_tests_by_task_mock(n_tasks, n_tests)

        under_test.create_generate_tasks_config(build_variant, tests_by_task, gen_config,
                                                repeat_config, None)

        evg_config_dict = build_variant.as_dict()
        self.assertEqual(n_tasks * n_tests, len(evg_config_dict["tasks"]))
Ejemplo n.º 4
0
def _generate_evg_tasks(evergreen_api, shrub_config, expansions_file_data, buildvariant_map):
    """
    Generate burn in tests tasks for a given shrub config and group of buildvariants.

    :param evergreen_api: Evergreen.py object.
    :param shrub_config: Shrub config object that the build variants will be built upon.
    :param expansions_file_data: Config data file to use.
    :param buildvariant_map: Map of base buildvariants to their generated buildvariant.
    """
    for buildvariant, run_buildvariant in buildvariant_map.items():
        config_options = _get_config_options(expansions_file_data, buildvariant, run_buildvariant)
        tests_by_task = create_tests_by_task(config_options)
        if tests_by_task:
            _generate_evg_buildvariant(shrub_config, buildvariant, run_buildvariant)
            create_generate_tasks_config(evergreen_api, shrub_config, config_options, tests_by_task,
                                         False)
Ejemplo n.º 5
0
    def test_no_tasks_given(self):
        evg_config = Configuration()
        gen_config = MagicMock(run_build_variant="variant")
        repeat_config = MagicMock()

        evg_config = under_test.create_generate_tasks_config(
            evg_config, {}, gen_config, repeat_config, None)

        evg_config_dict = evg_config.to_map()
        self.assertNotIn("tasks", evg_config_dict)
Ejemplo n.º 6
0
def _generate_evg_tasks(evergreen_api: EvergreenApi,
                        shrub_project: ShrubProject,
                        task_expansions: Dict[str, Any],
                        build_variant_map: Dict[str, str], repos: List[Repo],
                        evg_conf: EvergreenProjectConfig) -> None:
    """
    Generate burn in tests tasks for a given shrub config and group of build variants.

    :param evergreen_api: Evergreen.py object.
    :param shrub_project: Shrub config object that the build variants will be built upon.
    :param task_expansions: Dictionary of expansions for the running task.
    :param build_variant_map: Map of base buildvariants to their generated buildvariant.
    :param repos: Git repositories.
    """
    for build_variant, run_build_variant in build_variant_map.items():
        config_options = _get_config_options(task_expansions, build_variant,
                                             run_build_variant)
        task_id = task_expansions[TASK_ID_EXPANSION]
        changed_tests = find_changed_tests(repos,
                                           evg_api=evergreen_api,
                                           task_id=task_id)
        tests_by_task = create_tests_by_task(build_variant, evg_conf,
                                             changed_tests)
        if tests_by_task:
            shrub_build_variant = _generate_evg_build_variant(
                evg_conf.get_variant(build_variant), run_build_variant,
                task_expansions["build_variant"])
            gen_config = GenerateConfig(
                build_variant, config_options.project, run_build_variant,
                config_options.distro).validate(evg_conf)
            repeat_config = RepeatConfig(
                repeat_tests_min=config_options.repeat_tests_min,
                repeat_tests_max=config_options.repeat_tests_max,
                repeat_tests_secs=config_options.repeat_tests_secs)

            create_generate_tasks_config(shrub_build_variant,
                                         tests_by_task,
                                         gen_config,
                                         repeat_config,
                                         evergreen_api,
                                         include_gen_task=False)
            shrub_project.add_build_variant(shrub_build_variant)
    def test_multiversion_path_is_used(self):
        n_tasks = 1
        n_tests = 1
        build_variant = BuildVariant("variant")
        gen_config = MagicMock(run_build_variant="variant", distro=None)
        repeat_config = MagicMock()
        tests_by_task = create_tests_by_task_mock(n_tasks, n_tests)
        first_task = "task_0_gen"
        multiversion_path = "multiversion_path"
        tests_by_task[first_task]["use_multiversion"] = multiversion_path

        create_generate_tasks_config(build_variant, tests_by_task, gen_config,
                                     repeat_config, None)

        shrub_project = ShrubProject.empty().add_build_variant(build_variant)
        evg_config_dict = shrub_project.as_dict()
        tasks = evg_config_dict["tasks"]
        self.assertEqual(n_tasks * n_tests, len(tasks))
        self.assertEqual(multiversion_path,
                         tasks[0]["commands"][2]["vars"]["task_path_suffix"])
Ejemplo n.º 8
0
    def test_one_task_one_test(self):
        n_tasks = 1
        n_tests = 1
        resmoke_options = "options for resmoke"
        build_variant = BuildVariant("build variant")
        gen_config = MagicMock(run_build_variant="variant", distro=None)
        repeat_config = MagicMock()
        repeat_config.generate_resmoke_options.return_value = resmoke_options
        tests_by_task = create_tests_by_task_mock(n_tasks, n_tests)

        under_test.create_generate_tasks_config(build_variant, tests_by_task, gen_config,
                                                repeat_config, None)

        shrub_config = ShrubProject.empty().add_build_variant(build_variant)
        evg_config_dict = shrub_config.as_dict()
        tasks = evg_config_dict["tasks"]
        self.assertEqual(n_tasks * n_tests, len(tasks))
        cmd = tasks[0]["commands"]
        self.assertIn(resmoke_options, cmd[1]["vars"]["resmoke_args"])
        self.assertIn("--suites=suite_0", cmd[1]["vars"]["resmoke_args"])
        self.assertIn("tests_0", cmd[1]["vars"]["resmoke_args"])
Ejemplo n.º 9
0
    def test_n_task_m_test(self):
        n_tasks = 3
        n_tests = 5
        evg_config = Configuration()
        gen_config = MagicMock(run_build_variant="variant", distro=None)
        repeat_config = MagicMock()
        tests_by_task = create_tests_by_task_mock(n_tasks, n_tests)

        evg_config = under_test.create_generate_tasks_config(
            evg_config, tests_by_task, gen_config, repeat_config, None)

        evg_config_dict = evg_config.to_map()
        self.assertEqual(n_tasks * n_tests, len(evg_config_dict["tasks"]))
Ejemplo n.º 10
0
    def test_multiversion_path_is_used(self):
        n_tasks = 1
        n_tests = 1
        evg_config = Configuration()
        gen_config = MagicMock(run_build_variant="variant", distro=None)
        repeat_config = MagicMock()
        tests_by_task = create_tests_by_task_mock(n_tasks, n_tests)
        first_task = "task_0"
        multiversion_path = "multiversion_path"
        tests_by_task[first_task]["use_multiversion"] = multiversion_path

        evg_config = under_test.create_generate_tasks_config(evg_config, tests_by_task, gen_config,
                                                             repeat_config, None)

        evg_config_dict = evg_config.to_map()
        tasks = evg_config_dict["tasks"]
        self.assertEqual(n_tasks * n_tests, len(tasks))
        self.assertEqual(multiversion_path, tasks[0]["commands"][2]["vars"]["task_path_suffix"])
Ejemplo n.º 11
0
    def test_one_task_one_test(self):
        n_tasks = 1
        n_tests = 1
        resmoke_options = "options for resmoke"
        evg_config = Configuration()
        gen_config = MagicMock(run_build_variant="variant", distro=None)
        repeat_config = MagicMock()
        repeat_config.generate_resmoke_options.return_value = resmoke_options
        tests_by_task = create_tests_by_task_mock(n_tasks, n_tests)

        evg_config = under_test.create_generate_tasks_config(
            evg_config, tests_by_task, gen_config, repeat_config, None)

        evg_config_dict = evg_config.to_map()
        tasks = evg_config_dict["tasks"]
        self.assertEqual(n_tasks * n_tests, len(tasks))
        cmd = tasks[0]["commands"]
        self.assertIn(resmoke_options, cmd[1]["vars"]["resmoke_args"])
        self.assertIn("--suites=suite_0", cmd[1]["vars"]["resmoke_args"])
        self.assertIn("tests_0", cmd[1]["vars"]["resmoke_args"])