Exemple #1
0
    def test_get_tasks_depends_on(self):
        options = self.generate_mock_options()
        suites = self.generate_mock_suites(3)

        cfg_generator = grt.EvergreenConfigGenerator(suites, options, Mock())
        cfg_generator.build_tasks = [
            {
                "display_name": "sharding_gen"
            },
            {
                "display_name": "sharding_0"
            },
            {
                "display_name": "other_task"
            },
            {
                "display_name": "other_task_2"
            },
            {
                "display_name": "sharding_1"
            },
            {
                "display_name": "compile"
            },
            {
                "display_name": "sharding_misc"
            },
        ]

        dependent_tasks = cfg_generator._get_tasks_for_depends_on("sharding")
        self.assertEqual(3, len(dependent_tasks))
        self.assertIn("sharding_0", dependent_tasks)
        self.assertIn("sharding_1", dependent_tasks)
        self.assertIn("sharding_misc", dependent_tasks)
Exemple #2
0
    def test_get_tasks_depends_on(self):
        options = self.generate_mock_options()
        suites = self.generate_mock_suites(3)

        cfg_generator = grt.EvergreenConfigGenerator(suites, options, Mock())
        cfg_generator.build_tasks = [
            {
                'display_name': 'sharding_gen'
            },
            {
                'display_name': 'sharding_0'
            },
            {
                'display_name': 'other_task'
            },
            {
                'display_name': 'other_task_2'
            },
            {
                'display_name': 'sharding_1'
            },
            {
                'display_name': 'compile'
            },
            {
                'display_name': 'sharding_misc'
            },
        ]

        dependent_tasks = cfg_generator._get_tasks_for_depends_on('sharding')
        self.assertEqual(3, len(dependent_tasks))
        self.assertIn('sharding_0', dependent_tasks)
        self.assertIn('sharding_1', dependent_tasks)
        self.assertIn('sharding_misc', dependent_tasks)
Exemple #3
0
    def test_specified_dependencies_are_added(self):
        options = self.generate_mock_options()
        options.depends_on = ['sharding']
        options.is_patch = False
        suites = self.generate_mock_suites(3)

        cfg_generator = grt.EvergreenConfigGenerator(suites, options, Mock())
        cfg_generator.build_tasks = [
            {
                'display_name': 'sharding_gen'
            },
            {
                'display_name': 'sharding_0'
            },
            {
                'display_name': 'other_task'
            },
            {
                'display_name': 'other_task_2'
            },
            {
                'display_name': 'sharding_1'
            },
            {
                'display_name': 'compile'
            },
            {
                'display_name': 'sharding_misc'
            },
        ]

        cfg_mock = Mock()
        cfg_generator._add_dependencies(cfg_mock)
        self.assertEqual(4, cfg_mock.dependency.call_count)
    def test_evg_config_has_timeouts_for_repeated_suites(self):
        options = self.generate_mock_options()
        options.repeat_suites = 5
        suites = self.generate_mock_suites(3)
        build_variant = BuildVariant("variant")

        generator = under_test.EvergreenConfigGenerator(
            suites, options, MagicMock())
        generator.generate_config(build_variant)

        shrub_project = ShrubProject.empty().add_build_variant(build_variant)
        config = shrub_project.as_dict()
        self.assertEqual(len(config["tasks"]), len(suites) + 1)
        command1 = config["tasks"][0]["commands"][2]
        self.assertIn(" --repeatSuites=5 ", command1["vars"]["resmoke_args"])
        self.assertIn(options.resmoke_args, command1["vars"]["resmoke_args"])
        timeout_cmd = config["tasks"][0]["commands"][0]
        self.assertEqual("timeout.update", timeout_cmd["command"])
        expected_timeout = under_test.calculate_timeout(
            suites[0].max_runtime, 3) * 5
        self.assertEqual(expected_timeout,
                         timeout_cmd["params"]["timeout_secs"])
        expected_exec_timeout = under_test.calculate_timeout(
            suites[0].get_runtime(), 3) * 5
        self.assertEqual(expected_exec_timeout,
                         timeout_cmd["params"]["exec_timeout_secs"])
    def test_evg_config_has_fails_if_timeout_too_high(self):
        options = self.generate_mock_options()
        options.repeat_suites = under_test.MAX_EXPECTED_TIMEOUT
        suites = self.generate_mock_suites(3)

        with self.assertRaises(ValueError):
            under_test.EvergreenConfigGenerator(suites, options, MagicMock()).generate_config()
Exemple #6
0
    def test_specified_dependencies_are_added(self):
        options = self.generate_mock_options()
        options.depends_on = ["sharding"]
        options.is_patch = False
        suites = self.generate_mock_suites(3)

        cfg_generator = grt.EvergreenConfigGenerator(suites, options, Mock())
        cfg_generator.build_tasks = [
            {
                "display_name": "sharding_gen"
            },
            {
                "display_name": "sharding_0"
            },
            {
                "display_name": "other_task"
            },
            {
                "display_name": "other_task_2"
            },
            {
                "display_name": "sharding_1"
            },
            {
                "display_name": "compile"
            },
            {
                "display_name": "sharding_misc"
            },
        ]

        cfg_mock = Mock()
        cfg_generator._add_dependencies(cfg_mock)
        self.assertEqual(4, cfg_mock.dependency.call_count)
Exemple #7
0
    def test_evg_config_does_not_overwrite_repeat_resmoke_arg_with_repeatSuites_default(self):
        options = self.generate_mock_options()
        options.resmoke_args = "resmoke_args --repeat=5"
        suites = self.generate_mock_suites(1)

        config = grt.EvergreenConfigGenerator(suites, options, Mock()).generate_config().to_map()
        command1 = config["tasks"][0]["commands"][2]
        self.assertIn("--repeat=5", command1["vars"]["resmoke_args"])
        self.assertNotIn("--repeatSuites=1", command1["vars"]["resmoke_args"])
Exemple #8
0
    def test_evg_config_does_not_fails_if_timeout_too_high_on_mainline(self):
        shrub_config = Configuration()
        options = self.generate_mock_options()
        options.is_patch = False
        options.repeat_suites = under_test.MAX_EXPECTED_TIMEOUT
        suites = self.generate_mock_suites(3)

        config = under_test.EvergreenConfigGenerator(shrub_config, suites, options,
                                                     MagicMock()).generate_config().to_map()
        self.assertEqual(len(config["tasks"]), len(suites) + 1)
    def test_build_variant_without_large_distro_defined_fails(self):
        options = self.generate_mock_options()
        options.use_large_distro = "true"
        options.large_distro_name = None
        suites = self.generate_mock_suites(3)
        build_variant = BuildVariant("variant")

        generator = under_test.EvergreenConfigGenerator(suites, options, MagicMock())
        with self.assertRaises(ValueError):
            generator.generate_config(build_variant)
    def test_suites_without_enough_info_should_not_include_timeouts(self):
        suite_without_timing_info = 1
        options = self.generate_mock_options()
        suites = self.generate_mock_suites(3)
        suites[suite_without_timing_info].should_overwrite_timeout.return_value = False

        config = grt.EvergreenConfigGenerator(suites, options, Mock()).generate_config().to_map()

        timeout_cmd = config["tasks"][suite_without_timing_info]["commands"][0]
        self.assertNotIn("command", timeout_cmd)
        self.assertEqual("do setup", timeout_cmd["func"])
    def test_evg_config_is_created(self):
        options = self.generate_mock_options()
        suites = self.generate_mock_suites(3)

        config = grt.EvergreenConfigGenerator(suites, options, Mock()).generate_config().to_map()

        self.assertEqual(len(config["tasks"]), len(suites) + 1)
        command1 = config["tasks"][0]["commands"][2]
        self.assertIn(options.resmoke_args, command1["vars"]["resmoke_args"])
        self.assertIn(options.run_multiple_jobs, command1["vars"]["run_multiple_jobs"])
        self.assertEqual("run generated tests", command1["func"])
Exemple #12
0
    def test_timeout_info_not_included_if_use_default_timeouts_set(self):
        suite_without_timing_info = 1
        options = self.generate_mock_options()
        suites = self.generate_mock_suites(3)
        options.use_default_timeouts = True

        config = grt.EvergreenConfigGenerator(suites, options, Mock()).generate_config().to_map()

        timeout_cmd = config["tasks"][suite_without_timing_info]["commands"][0]
        self.assertNotIn("command", timeout_cmd)
        self.assertEqual("do setup", timeout_cmd["func"])
    def test_evg_config_does_not_fails_if_timeout_too_high_on_mainline(self):
        options = self.generate_mock_options()
        options.is_patch = False
        options.repeat_suites = under_test.MAX_EXPECTED_TIMEOUT
        suites = self.generate_mock_suites(3)
        build_variant = BuildVariant("variant")

        generator = under_test.EvergreenConfigGenerator(suites, options, MagicMock())
        generator.generate_config(build_variant)

        config = build_variant.as_dict()
        self.assertEqual(len(config["tasks"]), len(suites) + 1)
    def test_evg_config_can_use_large_distro(self):
        options = self.generate_mock_options()
        options.use_large_distro = "true"
        options.large_distro_name = "large distro name"

        suites = self.generate_mock_suites(3)

        config = grt.EvergreenConfigGenerator(suites, options, Mock()).generate_config().to_map()

        self.assertEqual(len(config["tasks"]), len(suites) + 1)
        self.assertEqual(options.large_distro_name,
                         config["buildvariants"][0]["tasks"][0]["distros"][0])
    def test_evg_config_does_not_overwrite_repeat_resmoke_arg_with_repeatSuites_default(self):
        options = self.generate_mock_options()
        options.resmoke_args = "resmoke_args --repeat=5"
        suites = self.generate_mock_suites(1)
        build_variant = BuildVariant("variant")

        generator = under_test.EvergreenConfigGenerator(suites, options, MagicMock())
        generator.generate_config(build_variant)

        shrub_project = ShrubProject.empty().add_build_variant(build_variant)
        config = shrub_project.as_dict()
        command1 = config["tasks"][0]["commands"][2]
        self.assertIn("--repeat=5", command1["vars"]["resmoke_args"])
        self.assertNotIn("--repeatSuites=1", command1["vars"]["resmoke_args"])
Exemple #16
0
    def test_suites_without_enough_info_should_not_include_timeouts(self):
        suite_without_timing_info = 1
        options = self.generate_mock_options()
        suites = self.generate_mock_suites(3)
        suites[suite_without_timing_info].should_overwrite_timeout.return_value = False
        build_variant = BuildVariant("variant")

        generator = under_test.EvergreenConfigGenerator(suites, options, MagicMock())
        generator.generate_config(build_variant)

        shrub_project = ShrubProject.empty().add_build_variant(build_variant)
        config = shrub_project.as_dict()
        timeout_cmd = config["tasks"][suite_without_timing_info]["commands"][0]
        self.assertNotIn("command", timeout_cmd)
        self.assertEqual("do setup", timeout_cmd["func"])
    def test_timeout_info_not_included_if_use_default_timeouts_set(self):
        suite_without_timing_info = 1
        options = self.generate_mock_options()
        suites = self.generate_mock_suites(3)
        options.use_default_timeouts = True
        build_variant = BuildVariant("variant")

        generator = under_test.EvergreenConfigGenerator(suites, options, MagicMock())
        generator.generate_config(build_variant)

        shrub_project = ShrubProject.empty().add_build_variant(build_variant)
        config = shrub_project.as_dict()
        timeout_cmd = config["tasks"][suite_without_timing_info]["commands"][0]
        self.assertNotIn("command", timeout_cmd)
        self.assertEqual("do setup", timeout_cmd["func"])
    def test_evg_config_is_created(self):
        options = self.generate_mock_options()
        suites = self.generate_mock_suites(3)
        build_variant = BuildVariant("variant")

        generator = under_test.EvergreenConfigGenerator(suites, options, MagicMock())
        generator.generate_config(build_variant)

        shrub_project = ShrubProject.empty().add_build_variant(build_variant)
        config = shrub_project.as_dict()
        self.assertEqual(len(config["tasks"]), len(suites) + 1)
        command1 = config["tasks"][0]["commands"][2]
        self.assertIn(options.resmoke_args, command1["vars"]["resmoke_args"])
        self.assertIn(" --originSuite=suite", command1["vars"]["resmoke_args"])
        self.assertIn(options.run_multiple_jobs, command1["vars"]["run_multiple_jobs"])
        self.assertEqual("run generated tests", command1["func"])
    def test_evg_config_can_use_large_distro(self):
        options = self.generate_mock_options()
        options.use_large_distro = "true"
        options.large_distro_name = "large distro name"
        suites = self.generate_mock_suites(3)
        build_variant = BuildVariant("variant")

        generator = under_test.EvergreenConfigGenerator(suites, options, MagicMock())
        generator.generate_config(build_variant)

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

        self.assertEqual(len(config["tasks"]), len(suites) + 1)
        self.assertEqual(options.large_distro_name,
                         config["buildvariants"][0]["tasks"][0]["distros"][0])
Exemple #20
0
    def test_evg_config_is_created_with_diff_task_and_suite(self):
        shrub_config = Configuration()
        options = self.generate_mock_options()
        options.task = "task"
        options.generate_display_task.return_value = DisplayTaskDefinition("task")
        suites = self.generate_mock_suites(3)

        config = under_test.EvergreenConfigGenerator(shrub_config, suites, options,
                                                     MagicMock()).generate_config().to_map()

        self.assertEqual(len(config["tasks"]), len(suites) + 1)
        display_task = config["buildvariants"][0]["display_tasks"][0]
        self.assertEqual(options.task, display_task["name"])

        task = config["tasks"][0]
        self.assertIn(options.variant, task["name"])
        self.assertIn(options.suite, task["commands"][2]["vars"]["resmoke_args"])
    def test_evg_config_has_timeouts_for_repeated_suites(self):
        options = self.generate_mock_options()
        options.repeat_suites = 5
        suites = self.generate_mock_suites(3)

        config = grt.EvergreenConfigGenerator(suites, options, Mock()).generate_config().to_map()

        self.assertEqual(len(config["tasks"]), len(suites) + 1)
        command1 = config["tasks"][0]["commands"][2]
        self.assertIn(" --repeatSuites=5 ", command1["vars"]["resmoke_args"])
        self.assertIn(options.resmoke_args, command1["vars"]["resmoke_args"])
        timeout_cmd = config["tasks"][0]["commands"][0]
        self.assertEqual("timeout.update", timeout_cmd["command"])
        expected_timeout = grt.calculate_timeout(suites[0].max_runtime, 3) * 5
        self.assertEqual(expected_timeout, timeout_cmd["params"]["timeout_secs"])
        expected_exec_timeout = grt.calculate_timeout(suites[0].get_runtime(), 3) * 5
        self.assertEqual(expected_exec_timeout, timeout_cmd["params"]["exec_timeout_secs"])
    def test_evg_config_is_created_with_diff_task_and_suite(self):
        options = self.generate_mock_options()
        options.task = "task"
        suites = self.generate_mock_suites(3)

        config = grt.EvergreenConfigGenerator(suites, options, Mock()).generate_config().to_map()

        self.assertEqual(len(config["tasks"]), len(suites) + 1)
        display_task = config["buildvariants"][0]["display_tasks"][0]
        self.assertEqual(options.task, display_task["name"])
        self.assertEqual(len(suites) + 2, len(display_task["execution_tasks"]))
        self.assertIn(options.task + "_gen", display_task["execution_tasks"])
        self.assertIn(options.task + "_misc_" + options.variant, display_task["execution_tasks"])

        task = config["tasks"][0]
        self.assertIn(options.variant, task["name"])
        self.assertIn(task["name"], display_task["execution_tasks"])
        self.assertIn(options.suite, task["commands"][2]["vars"]["resmoke_args"])
    def test_build_variant_without_large_distro_defined_can_be_ignored(self):
        options = self.generate_mock_options()
        options.use_large_distro = "true"
        options.large_distro_name = None
        suites = self.generate_mock_suites(3)
        build_variant = BuildVariant("variant")
        generate_config = under_test.GenerationConfiguration(
            build_variant_large_distro_exceptions={"variant"})

        generator = under_test.EvergreenConfigGenerator(suites, options, MagicMock(),
                                                        generate_config)
        generator.generate_config(build_variant)

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

        self.assertEqual(len(config["tasks"]), len(suites) + 1)
        self.assertIsNone(config["buildvariants"][0]["tasks"][0].get("distros"))
    def test_specified_dependencies_are_added(self):
        options = self.generate_mock_options()
        options.depends_on = ["sharding"]
        options.is_patch = False
        suites = self.generate_mock_suites(3)

        cfg_generator = under_test.EvergreenConfigGenerator(suites, options, MagicMock())
        cfg_generator.build_tasks = [
            MagicMock(display_name="sharding_gen"),
            MagicMock(display_name="sharding_0"),
            MagicMock(display_name="other_task"),
            MagicMock(display_name="other_task_2"),
            MagicMock(display_name="sharding_1"),
            MagicMock(display_name="compile"),
            MagicMock(display_name="sharding_misc"),
        ]

        dependencies = cfg_generator._get_dependencies()
        self.assertEqual(4, len(dependencies))
Exemple #25
0
    def test_get_tasks_depends_on(self):
        options = self.generate_mock_options()
        suites = self.generate_mock_suites(3)

        cfg_generator = under_test.EvergreenConfigGenerator(suites, options, MagicMock())
        cfg_generator.build_tasks = [
            MagicMock(display_name="sharding_gen"),
            MagicMock(display_name="sharding_0"),
            MagicMock(display_name="other_task"),
            MagicMock(display_name="other_task_2"),
            MagicMock(display_name="sharding_1"),
            MagicMock(display_name="compile"),
            MagicMock(display_name="sharding_misc"),
        ]

        dependent_tasks = cfg_generator._get_tasks_for_depends_on("sharding")
        self.assertEqual(3, len(dependent_tasks))
        self.assertIn("sharding_0", dependent_tasks)
        self.assertIn("sharding_1", dependent_tasks)
        self.assertIn("sharding_misc", dependent_tasks)
    def test_evg_config_is_created_with_diff_task_and_suite(self):
        options = self.generate_mock_options()
        options.task = "task"
        options.display_task_name = "display task"
        options.generate_display_task.return_value = DisplayTaskDefinition("task")
        suites = self.generate_mock_suites(3)
        build_variant = BuildVariant("variant")

        generator = under_test.EvergreenConfigGenerator(suites, options, MagicMock())
        generator.generate_config(build_variant)

        shrub_project = ShrubProject.empty().add_build_variant(build_variant)
        config = shrub_project.as_dict()
        self.assertEqual(len(config["tasks"]), len(suites) + 1)
        display_task = config["buildvariants"][0]["display_tasks"][0]
        self.assertEqual(options.display_task_name, display_task["name"])

        task = config["tasks"][0]
        self.assertIn(options.variant, task["name"])
        self.assertIn(options.suite, task["commands"][2]["vars"]["resmoke_args"])
Exemple #27
0
    def test_specified_dependencies_are_added(self):
        options = self.generate_mock_options()
        options.depends_on = ["sharding"]
        options.is_patch = False
        suites = self.generate_mock_suites(3)

        cfg_generator = under_test.EvergreenConfigGenerator(
            suites, options, MagicMock())
        cfg_generator.build_tasks = [
            self.mock_task("sharding_gen"),
            self.mock_task("sharding_0"),
            self.mock_task("other_task"),
            self.mock_task("other_task_2"),
            self.mock_task("sharding_1"),
            self.mock_task("compile"),
            self.mock_task("sharding_misc"),
        ]

        cfg_mock = MagicMock()
        cfg_generator._add_dependencies(cfg_mock)
        self.assertEqual(4, cfg_mock.dependency.call_count)