diff options
author | Rob Guo <robert.guo@mongodb.com> | 2022-10-23 23:29:50 -0400 |
---|---|---|
committer | Evergreen Agent <no-reply@evergreen.mongodb.com> | 2022-10-24 13:26:49 +0000 |
commit | 7ec72a366c71c9d36fd1d6c283390d2dc93b20ce (patch) | |
tree | 10b089c6b37ced316c205ac38318cd022692be14 /buildscripts | |
parent | 525334b580816f2320d9a518b7d9eff908678ce9 (diff) | |
download | mongo-7ec72a366c71c9d36fd1d6c283390d2dc93b20ce.tar.gz |
SERVER-65040 Consolidate compile tasks for required variants
Diffstat (limited to 'buildscripts')
-rwxr-xr-x | buildscripts/evergreen_activate_gen_tasks.py | 8 | ||||
-rw-r--r-- | buildscripts/tests/test_evergreen_activate_gen_tasks.py | 36 |
2 files changed, 17 insertions, 27 deletions
diff --git a/buildscripts/evergreen_activate_gen_tasks.py b/buildscripts/evergreen_activate_gen_tasks.py index a800edc15ee..5c20b285e6b 100755 --- a/buildscripts/evergreen_activate_gen_tasks.py +++ b/buildscripts/evergreen_activate_gen_tasks.py @@ -73,14 +73,15 @@ def activate_task(expansions: EvgExpansions, evg_api: EvergreenApi) -> None: for base_build_variant in expansions.burn_in_tag_buildvariants_list: build_variant = f"{base_build_variant}-required" try: - build = version.build_by_variant(build_variant) + build_id = version.build_variants_map[build_variant] except KeyError: LOGGER.warning( "It is likely nothing to burn_in, so burn_in_tags build variant" " was not generated. Skipping...", build_variant=build_variant) continue - task_list = build.get_tasks() + task_list = evg_api.tasks_by_build(build_id) + for task in task_list: if task.display_name == BURN_IN_TESTS: LOGGER.info("Activating task", task_id=task.task_id, @@ -88,8 +89,7 @@ def activate_task(expansions: EvgExpansions, evg_api: EvergreenApi) -> None: evg_api.configure_task(task.task_id, activated=True) else: - build = evg_api.build_by_id(expansions.build_id) - task_list = build.get_tasks() + task_list = evg_api.tasks_by_build(expansions.build_id) for task in task_list: if task.display_name == expansions.task: LOGGER.info("Activating task", task_id=task.task_id, task_name=task.display_name) diff --git a/buildscripts/tests/test_evergreen_activate_gen_tasks.py b/buildscripts/tests/test_evergreen_activate_gen_tasks.py index 47cc32cd9fc..1632fab75ea 100644 --- a/buildscripts/tests/test_evergreen_activate_gen_tasks.py +++ b/buildscripts/tests/test_evergreen_activate_gen_tasks.py @@ -17,18 +17,17 @@ def build_mock_task_list(num_tasks): return [build_mock_task(f"task_{i}", f"id_{i}") for i in range(num_tasks)] -def build_mock_build(mock_task_list): - mock_build = MagicMock(spec_set=Build) - mock_build.get_tasks.return_value = mock_task_list - return mock_build +def build_mock_evg_api(mock_tasks_list, variant_map_side_effects=None): + class VersionPatchedSpec(Version): + """A patched `Version` with instance properties included for magic mock spec.""" + build_variants_map = MagicMock() + mock_version = MagicMock(spec_set=VersionPatchedSpec) + mock_version.build_variants_map.side_effect = variant_map_side_effects -def build_mock_evg_api(mock_current_build, mock_other_builds_list): - mock_version = MagicMock(spec_set=Version) - mock_version.build_by_variant.side_effect = mock_other_builds_list mock_evg_api = MagicMock(spec_set=EvergreenApi) mock_evg_api.version_by_id.return_value = mock_version - mock_evg_api.build_by_id.return_value = mock_current_build + mock_evg_api.tasks_by_build.side_effect = mock_tasks_list return mock_evg_api @@ -40,7 +39,7 @@ class TestActivateTask(unittest.TestCase): "task_name": "task_3_gen", }) mock_task_list = build_mock_task_list(5) - mock_evg_api = build_mock_evg_api(build_mock_build(mock_task_list), []) + mock_evg_api = build_mock_evg_api([mock_task_list]) under_test.activate_task(expansions, mock_evg_api) @@ -53,7 +52,7 @@ class TestActivateTask(unittest.TestCase): "task_name": "not_an_existing_task", }) mock_task_list = build_mock_task_list(5) - mock_evg_api = build_mock_evg_api(build_mock_build(mock_task_list), []) + mock_evg_api = build_mock_evg_api([mock_task_list]) under_test.activate_task(expansions, mock_evg_api) @@ -67,17 +66,11 @@ class TestActivateTask(unittest.TestCase): "task_name": "burn_in_tags_gen", "burn_in_tag_buildvariants": "build_variant_2 build_variant_3", }) - mock_task_list_1 = build_mock_task_list(5) - mock_task_list_1.append(build_mock_task("burn_in_tags_gen", "burn_in_tags_gen_id_1")) mock_task_list_2 = build_mock_task_list(5) mock_task_list_2.append(build_mock_task("burn_in_tests", "burn_in_tests_id_2")) mock_task_list_3 = build_mock_task_list(5) mock_task_list_3.append(build_mock_task("burn_in_tests", "burn_in_tests_id_3")) - mock_evg_api = build_mock_evg_api( - build_mock_build(mock_task_list_1), [ - build_mock_build(mock_task_list_2), - build_mock_build(mock_task_list_3), - ]) + mock_evg_api = build_mock_evg_api([mock_task_list_2, mock_task_list_3]) under_test.activate_task(expansions, mock_evg_api) @@ -98,11 +91,8 @@ class TestActivateTask(unittest.TestCase): mock_task_list_1.append(build_mock_task("burn_in_tags_gen", "burn_in_tags_gen_id_1")) mock_task_list_2 = build_mock_task_list(5) mock_task_list_2.append(build_mock_task("burn_in_tests", "burn_in_tests_id_2")) - mock_evg_api = build_mock_evg_api( - build_mock_build(mock_task_list_1), [ - KeyError, - build_mock_build(mock_task_list_2), - ]) + mock_evg_api = build_mock_evg_api([mock_task_list_1, mock_task_list_2], + [None, KeyError, None]) under_test.activate_task(expansions, mock_evg_api) @@ -116,7 +106,7 @@ class TestActivateTask(unittest.TestCase): }) mock_task_list_1 = build_mock_task_list(5) mock_task_list_1.append(build_mock_task("burn_in_tags_gen", "burn_in_tags_gen_id_1")) - mock_evg_api = build_mock_evg_api(build_mock_build(mock_task_list_1), []) + mock_evg_api = build_mock_evg_api(mock_task_list_1) under_test.activate_task(expansions, mock_evg_api) |