diff options
Diffstat (limited to 'buildscripts')
-rw-r--r-- | buildscripts/burn_in_tests.py | 2 | ||||
-rw-r--r-- | buildscripts/ciconfig/evergreen.py | 38 | ||||
-rw-r--r-- | buildscripts/tests/ciconfig/test_evergreen.py | 78 | ||||
-rw-r--r-- | buildscripts/tests/test_burn_in_tests.py | 54 |
4 files changed, 58 insertions, 114 deletions
diff --git a/buildscripts/burn_in_tests.py b/buildscripts/burn_in_tests.py index c0f36e66dd7..99ac702269d 100644 --- a/buildscripts/burn_in_tests.py +++ b/buildscripts/burn_in_tests.py @@ -326,7 +326,7 @@ def _get_task_name(task): """Return the task var from a "generate resmoke task" instead of the task name.""" if task.is_generate_resmoke_task: - return task.get_vars_task_name(task.generate_resmoke_tasks_command["vars"]) + return task.generated_task_name return task.name diff --git a/buildscripts/ciconfig/evergreen.py b/buildscripts/ciconfig/evergreen.py index 1e0f7065c74..40d145ebf85 100644 --- a/buildscripts/ciconfig/evergreen.py +++ b/buildscripts/ciconfig/evergreen.py @@ -140,29 +140,28 @@ class Task(object): """Return True if a multiversion path is found.""" return self.multiversion_setup_command is not None or self.multiversion_path is not None - @staticmethod - def get_vars_task_name(command_vars): - """Return the command_vars task name.""" - if not isinstance(command_vars, dict): - raise TypeError("Must specify a dict") - task_name = command_vars.get("task") - if task_name is None: - raise ValueError("Missing task key") - return task_name + @property + def generated_task_name(self): + """ + Get basename of the tasks generated by this _gen task. - @staticmethod - def get_vars_suite_name(command_vars): + :return: Basename of the generated tasks. + """ + if not self.is_generate_resmoke_task: + raise TypeError("Only _gen tasks can have generated task names") + + return self.name[:-4] + + def get_vars_suite_name(self, command_vars): """Return the command_vars task or suite value, suite value overrides the task value.""" if not isinstance(command_vars, dict): raise TypeError("Must specify a dict") - suite = command_vars.get("task") - if "suite" in command_vars: - suite = command_vars["suite"] - if suite is None: - raise ValueError("Missing task key or suite key") + suite_name = self.generated_task_name + if "suite" in command_vars: + suite_name = command_vars["suite"] - return suite + return suite_name @property def multiversion_path(self): @@ -183,8 +182,9 @@ class Task(object): if self.is_generate_resmoke_task: command_vars = self.generate_resmoke_tasks_command.get("vars", {}) - return "--suites={0} {1}".format( - self.get_vars_suite_name(command_vars), command_vars.get("resmoke_args")) + suite_name = self.get_vars_suite_name(command_vars) + return "--suites={suite_name} {resmoke_args}".format( + suite_name=suite_name, resmoke_args=command_vars.get("resmoke_args")) return None @property diff --git a/buildscripts/tests/ciconfig/test_evergreen.py b/buildscripts/tests/ciconfig/test_evergreen.py index 6d18266d0d1..0996060f5a2 100644 --- a/buildscripts/tests/ciconfig/test_evergreen.py +++ b/buildscripts/tests/ciconfig/test_evergreen.py @@ -139,16 +139,14 @@ class TestTask(unittest.TestCase): # pylint: disable=too-many-public-methods self.assertIsNone(task.multiversion_path) def test_resmoke_args_gen(self): - task_name = "core" task_commands = [{ - "func": "generate resmoke tasks", - "vars": {"task": task_name, "resmoke_args": "--shellWriteMode=commands"} + "func": "generate resmoke tasks", "vars": {"resmoke_args": "--shellWriteMode=commands"} }] - task_dict = {"name": "jsCore", "commands": task_commands} + task_dict = {"name": "jsCore_gen", "commands": task_commands} task = _evergreen.Task(task_dict) - self.assertEqual("--suites=core --shellWriteMode=commands", task.resmoke_args) - self.assertEqual("core", task.resmoke_suite) + self.assertEqual("--suites=jsCore --shellWriteMode=commands", task.resmoke_args) + self.assertEqual("jsCore", task.resmoke_suite) def test_is_generate_resmoke_task(self): task_name = "core" @@ -163,16 +161,14 @@ class TestTask(unittest.TestCase): # pylint: disable=too-many-public-methods self.assertFalse(task.is_run_tests_task) def test_generate_resmoke_tasks_command(self): - task_name = "core" task_commands = [{ - "func": "generate resmoke tasks", - "vars": {"task": task_name, "resmoke_args": "--shellWriteMode=commands"} + "func": "generate resmoke tasks", "vars": {"resmoke_args": "--shellWriteMode=commands"} }] - task_dict = {"name": "jsCore", "commands": task_commands} + task_dict = {"name": "jsCore_gen", "commands": task_commands} task = _evergreen.Task(task_dict) self.assertDictEqual(task_commands[0], task.generate_resmoke_tasks_command) - self.assertEqual(task_name, task.get_vars_task_name(task_commands[0]["vars"])) + self.assertEqual("jsCore", task.generated_task_name) def test_resmoke_args_gen_with_suite(self): task_name = "jsCore" @@ -217,18 +213,17 @@ class TestTask(unittest.TestCase): # pylint: disable=too-many-public-methods self.assertEqual(len(task_dict["tags"]), len(tag_set)) def test_generate_resmoke_tasks_command_with_suite(self): - task_name = "jsCore" + task_name = "jsCore_gen" suite_name = "core" task_commands = [{ - "func": "generate resmoke tasks", "vars": { - "task": task_name, "suite": suite_name, "resmoke_args": "--shellWriteMode=commands" - } + "func": "generate resmoke tasks", + "vars": {"suite": suite_name, "resmoke_args": "--shellWriteMode=commands"} }] task_dict = {"name": task_name, "commands": task_commands} task = _evergreen.Task(task_dict) self.assertDictEqual(task_commands[0], task.generate_resmoke_tasks_command) - self.assertEqual(task_name, task.get_vars_task_name(task_commands[0]["vars"])) + self.assertEqual("jsCore", task.generated_task_name) def test_gen_resmoke_multiversion(self): multiversion_path = "/data/multiversion" @@ -257,19 +252,6 @@ class TestTask(unittest.TestCase): # pylint: disable=too-many-public-methods self.assertFalse(task.is_multiversion_task) self.assertIsNone(task.multiversion_path) - def test_get_vars_suite_name_run_tests(self): - suite_name = "core" - task_commands = [{ - "func": "run tests", - "vars": {"resmoke_args": "--suites={} --shellWriteMode=commands".format(suite_name)} - }] - - task_dict = {"name": "jsCore", "commands": task_commands} - task = _evergreen.Task(task_dict) - - with self.assertRaises(ValueError): - task.get_vars_suite_name(task_commands[0]["vars"]) - def test_get_vars_suite_name_generate_resmoke_tasks(self): task_name = "jsCore" suite_name = "core" @@ -292,42 +274,22 @@ class TestTask(unittest.TestCase): # pylint: disable=too-many-public-methods with self.assertRaises(TypeError): task.get_vars_suite_name(None) - def test_get_vars_suite_name_gen_resmoke_notask_nosuite(self): + def test_generate_task_name_non_gen_tasks(self): task_name = "jsCore" - task_commands = [{ - "func": "generate resmoke tasks", "vars": {"resmoke_args": "--shellWriteMode=commands"} - }] + task_commands = [{"func": "run tasks"}] task_dict = {"name": task_name, "commands": task_commands} task = _evergreen.Task(task_dict) - with self.assertRaises(ValueError): - task.get_vars_suite_name(task_commands[0]["vars"]) - - def test_get_vars_task_name(self): - task_name = "task_name" - task_commands = [{ - "func": "generate resmoke tasks", - "vars": {"task": task_name, "resmoke_args": "--shellWriteMode=commands"} - }] - task_dict = {"name": "jsCore", "commands": task_commands} - task = _evergreen.Task(task_dict) - self.assertEqual(task_name, task.get_vars_task_name(task_commands[0]["vars"])) - - def test_get_vars_task_name_no_task(self): - task_commands = [{ - "func": "generate resmoke tasks", "vars": {"resmoke_args": "--shellWriteMode=commands"} - }] - task_dict = {"name": "jsCore", "commands": task_commands} - task = _evergreen.Task(task_dict) - with self.assertRaises(ValueError): - task.get_vars_task_name(task_commands[0]["vars"]) + with self.assertRaises(TypeError): + task.generated_task_name # pylint: disable=pointless-statement - def test_get_vars_task_name_no_vars(self): + def test_generate_task_name(self): + task_name = "jsCore_gen" task_commands = [{"func": "generate resmoke tasks"}] - task_dict = {"name": "jsCore", "commands": task_commands} + task_dict = {"name": task_name, "commands": task_commands} task = _evergreen.Task(task_dict) - with self.assertRaises(TypeError): - task.get_vars_task_name(None) + + self.assertEqual("jsCore", task.generated_task_name) class TestTaskGroup(unittest.TestCase): diff --git a/buildscripts/tests/test_burn_in_tests.py b/buildscripts/tests/test_burn_in_tests.py index ae82d3a14bd..afbfac59737 100644 --- a/buildscripts/tests/test_burn_in_tests.py +++ b/buildscripts/tests/test_burn_in_tests.py @@ -21,34 +21,28 @@ EVG_CLIENT = "buildscripts.client.evergreen" GIT = "buildscripts.git" RESMOKELIB = "buildscripts.resmokelib" -GENERATE_RESMOKE_TASKS_NAME = "this_is_a_gen_task" +GENERATE_RESMOKE_TASKS_BASENAME = "this_is_a_gen_task" +GENERATE_RESMOKE_TASKS_NAME = GENERATE_RESMOKE_TASKS_BASENAME + "_gen" GET_GENERATE_RESMOKE_TASKS_NAME = lambda _: GENERATE_RESMOKE_TASKS_NAME GENERATE_RESMOKE_TASKS_COMMAND = { - "func": "generate resmoke tasks", "vars": { - "task": GENERATE_RESMOKE_TASKS_NAME, "suite": "suite3", - "resmoke_args": "--shellWriteMode=commands" - } + "func": "generate resmoke tasks", + "vars": {"suite": "suite3", "resmoke_args": "--shellWriteMode=commands"} } GENERATE_RESMOKE_TASKS_COMMAND2 = { - "func": "generate resmoke tasks", - "vars": {"task": GENERATE_RESMOKE_TASKS_NAME, "resmoke_args": "--shellWriteMode=commands"} + "func": "generate resmoke tasks", "vars": {"resmoke_args": "--shellWriteMode=commands"} } MULTIVERSION_PATH = "/data/multiversion" GENERATE_RESMOKE_TASKS_MULTIVERSION_COMMAND = { - "func": "generate resmoke tasks", "vars": { - "task": GENERATE_RESMOKE_TASKS_NAME, "resmoke_args": "--shellWriteMode=commands", - "use_multiversion": MULTIVERSION_PATH - } + "func": "generate resmoke tasks", + "vars": {"resmoke_args": "--shellWriteMode=commands", "use_multiversion": MULTIVERSION_PATH} } MULTIVERSION_COMMAND = {"func": "do multiversion setup"} RUN_TESTS_MULTIVERSION_COMMAND = { - "func": "run tests", "vars": { - "task": GENERATE_RESMOKE_TASKS_NAME, "resmoke_args": "--shellWriteMode=commands", - "task_path_suffix": MULTIVERSION_PATH - } + "func": "run tests", + "vars": {"resmoke_args": "--shellWriteMode=commands", "task_path_suffix": MULTIVERSION_PATH} } @@ -72,6 +66,8 @@ def tasks_mock( #pylint: disable=too-many-arguments resmoke_args, "suites") if resmoke_args else None task_list.tasks[idx].multiversion_path = multiversion_path task_list.tasks[idx].multiversion_setup_command = multiversion_setup_command + if task["name"].endswith("_gen"): + task_list.tasks[idx].generated_task_name = task["name"][:-4] return task_list @@ -385,10 +381,7 @@ class TestGetTaskName(unittest.TestCase): def test__get_task_name_generate_resmoke_task(self): task_name = "mytask" - task = Mock() - task.is_generate_resmoke_task = True - task.get_vars_task_name = lambda cmd_vars: cmd_vars["task"] - task.generate_resmoke_tasks_command = {"vars": {"task": task_name}} + task = Mock(is_generate_resmoke_task=True, generated_task_name=task_name) self.assertEqual(task_name, burn_in._get_task_name(task)) @@ -893,20 +886,9 @@ class CreateTaskList(unittest.TestCase): suite_list = _create_executor_list(suites, exclude_suites) task_list = burn_in.create_task_list(EVERGREEN_CONF, variant, suite_list, exclude_suites) self.assertEqual(len(task_list), len(VARIANTS["variant_generate_tasks"].tasks)) - self.assertIn(GENERATE_RESMOKE_TASKS_NAME, task_list) - self.assertEqual(task_list[GENERATE_RESMOKE_TASKS_NAME]["tests"], SUITE3.tests) - self.assertIsNone(task_list[GENERATE_RESMOKE_TASKS_NAME]["use_multiversion"]) - - def test_create_task_list_gen_tasks_diff_task_names(self): - variant = "variant_generate_tasks_diff_names" - suites = [SUITE3] - exclude_suites = [] - suite_list = _create_executor_list(suites, exclude_suites) - task_list = burn_in.create_task_list(EVERGREEN_CONF, variant, suite_list, exclude_suites) - self.assertEqual(len(task_list), len(VARIANTS["variant_generate_tasks"].tasks)) - self.assertIn(GENERATE_RESMOKE_TASKS_NAME, task_list) - self.assertEqual(task_list[GENERATE_RESMOKE_TASKS_NAME]["tests"], SUITE3.tests) - self.assertIsNone(task_list[GENERATE_RESMOKE_TASKS_NAME]["use_multiversion"]) + self.assertIn(GENERATE_RESMOKE_TASKS_BASENAME, task_list) + self.assertEqual(task_list[GENERATE_RESMOKE_TASKS_BASENAME]["tests"], SUITE3.tests) + self.assertIsNone(task_list[GENERATE_RESMOKE_TASKS_BASENAME]["use_multiversion"]) def test_create_task_list_gen_tasks_multiversion(self): variant = "variant_generate_tasks_multiversion" @@ -915,7 +897,7 @@ class CreateTaskList(unittest.TestCase): suite_list = _create_executor_list(suites, exclude_suites) task_list = burn_in.create_task_list(EVERGREEN_CONF, variant, suite_list, exclude_suites) self.assertEqual(len(task_list), len(VARIANTS["variant_generate_tasks_multiversion"].tasks)) - self.assertEqual(task_list[GENERATE_RESMOKE_TASKS_NAME]["use_multiversion"], + self.assertEqual(task_list[GENERATE_RESMOKE_TASKS_BASENAME]["use_multiversion"], MULTIVERSION_PATH) def test_create_task_list_gen_tasks_no_suite(self): @@ -925,8 +907,8 @@ class CreateTaskList(unittest.TestCase): suite_list = _create_executor_list(suites, exclude_suites) task_list = burn_in.create_task_list(EVERGREEN_CONF, variant, suite_list, exclude_suites) self.assertEqual(len(task_list), len(VARIANTS["variant_generate_tasks_no_suite"].tasks)) - self.assertIn(GENERATE_RESMOKE_TASKS_NAME, task_list) - self.assertEqual(task_list[GENERATE_RESMOKE_TASKS_NAME]["tests"], SUITE3.tests) + self.assertIn(GENERATE_RESMOKE_TASKS_BASENAME, task_list) + self.assertEqual(task_list[GENERATE_RESMOKE_TASKS_BASENAME]["tests"], SUITE3.tests) def test_create_task_list_no_excludes(self): variant = "variant1" |