diff options
author | David Bradford <david.bradford@mongodb.com> | 2021-07-12 09:57:26 -0400 |
---|---|---|
committer | Evergreen Agent <no-reply@evergreen.mongodb.com> | 2021-07-27 19:18:48 +0000 |
commit | ce503d131ffab70979e972e6eb95136b583d1f62 (patch) | |
tree | 635fbd0392f2002bad2847edc203e140048856d3 /buildscripts | |
parent | 3dddce5419ef0530bb5da9775531b101bde8d901 (diff) | |
download | mongo-ce503d131ffab70979e972e6eb95136b583d1f62.tar.gz |
SERVER-58087: Cleanup generate tasks setup
(cherry picked from commit b25d57c6a354cf5e4dab3237647797ccc5b30c4d)
Diffstat (limited to 'buildscripts')
-rw-r--r-- | buildscripts/ciconfig/evergreen.py | 30 | ||||
-rw-r--r-- | buildscripts/evergreen_gen_build_variant.py | 63 | ||||
-rw-r--r-- | buildscripts/task_generation/gen_task_service.py | 4 | ||||
-rw-r--r-- | buildscripts/tests/test_evergreen_gen_build_variant.py | 54 |
4 files changed, 54 insertions, 97 deletions
diff --git a/buildscripts/ciconfig/evergreen.py b/buildscripts/ciconfig/evergreen.py index 8d96bd03055..8b9823ed202 100644 --- a/buildscripts/ciconfig/evergreen.py +++ b/buildscripts/ciconfig/evergreen.py @@ -124,38 +124,12 @@ class Task(object): @property def generate_resmoke_tasks_command(self): """Return the 'generate resmoke tasks' command if found, or None.""" - func = self.find_func_command("generate resmoke tasks") - return func if func is not None else self.find_func_command( - "generate randomized multiversion tasks") - - @property - def generate_randomized_multiversion_command(self): - """Return the 'generate resmoke tasks' command if found, or None.""" - return self.find_func_command("generate randomized multiversion tasks") + return self.find_func_command("generate resmoke tasks") @property def is_generate_resmoke_task(self) -> bool: """Return True if 'generate resmoke tasks' command is found.""" - return (self.generate_resmoke_tasks_command is not None - or self.generate_randomized_multiversion_command is not None) - - def generate_fuzzer_tasks_command(self): - """Return the 'generate fuzzer tasks' command if found, or None.""" - func = self.find_func_command("generate fuzzer tasks") - return func - - def is_generate_fuzzer_task(self) -> bool: - """Return True if 'generate fuzzer tasks' command is found.""" - return self.generate_fuzzer_tasks_command() is not None - - def generate_implicit_multiversion_command(self): - """Return the 'generate implicit multiversion tasks' command if found, or None.""" - func = self.find_func_command("generate implicit multiversion tasks") - return func - - def is_generate_implicit_multiversion_task(self) -> bool: - """Return True if 'generate implicit multiverion tasks' command is found.""" - return self.generate_implicit_multiversion_command() is not None + return self.generate_resmoke_tasks_command is not None @property def run_tests_command(self): diff --git a/buildscripts/evergreen_gen_build_variant.py b/buildscripts/evergreen_gen_build_variant.py index daa239db0ed..0fe0dfb19b1 100644 --- a/buildscripts/evergreen_gen_build_variant.py +++ b/buildscripts/evergreen_gen_build_variant.py @@ -200,10 +200,7 @@ class GenerateBuildVariantOrchestrator: :return: Parameters for how task should be split. """ task = remove_gen_suffix(task_def.name) - run_func = task_def.generate_resmoke_tasks_command - if run_func is None: - run_func = task_def.generate_implicit_multiversion_command() - run_vars = run_func.get("vars", {}) + run_vars = task_def.generate_resmoke_tasks_command.get("vars", {}) suite = run_vars.get("suite", task) return SuiteSplitParameters( @@ -245,11 +242,11 @@ class GenerateBuildVariantOrchestrator: :param task_def: Task definition in evergreen project config. :param build_variant: Name of Build Variant being generated. + :param is_sharded: True if the tasks being generated are for a sharded config. + :param version_config: List of version configurations to generate. :return: Parameters for how task should be generated. """ - run_func = task_def.generate_implicit_multiversion_command() - run_vars = run_func["vars"] - + run_vars = task_def.generate_resmoke_tasks_command["vars"] task = remove_gen_suffix(task_def.name) return MultiversionGenTaskParams( @@ -271,14 +268,12 @@ class GenerateBuildVariantOrchestrator: :param task_def: Task definition in evergreen project config. :param build_variant: Name of Build Variant being generated. + :param is_sharded: True task if for a sharded configuration. + :param version_config: List of version configs task is being generated for. :return: Parameters for how a fuzzer task should be generated. """ variant = self.evg_project_config.get_variant(build_variant) - if is_sharded is not None or version_config is not None: - run_func = task_def.generate_implicit_multiversion_command() - else: - run_func = task_def.generate_fuzzer_tasks_command() - run_vars = run_func["vars"] + run_vars = task_def.generate_resmoke_tasks_command["vars"] run_vars = {k: translate_run_var(v, variant) for k, v in run_vars.items()} return FuzzerGenTaskParams( @@ -340,31 +335,35 @@ class GenerateBuildVariantOrchestrator: task_def = self.evg_project_config.get_task(task_name) if task_def.is_generate_resmoke_task: tasks_to_hide.add(task_name) - split_params = self.task_def_to_split_params(task_def, build_variant_name) - gen_params = self.task_def_to_gen_params(task_def, build_variant_name) - jobs.append(exe.submit(builder.generate_suite, split_params, gen_params)) - elif task_def.is_generate_fuzzer_task(): - tasks_to_hide.add(task_name) - fuzzer_params = self.task_def_to_fuzzer_params(task_def, build_variant_name) - jobs.append(exe.submit(builder.generate_fuzzer, fuzzer_params)) - elif task_def.is_generate_implicit_multiversion_task(): - tasks_to_hide.add(task_name) - run_func = task_def.generate_implicit_multiversion_command() - run_vars = run_func["vars"] - is_jstestjuzz = run_vars.get("is_jstestfuzz", False) - suite = run_vars["suite"] - is_sharded = self.multiversion_util.is_suite_sharded(suite) - version_list = get_version_configs(is_sharded) - if is_jstestjuzz: + + is_sharded = None + version_list = None + run_vars = task_def.generate_resmoke_tasks_command["vars"] + suite = run_vars.get("suite") + is_jstestfuzz = run_vars.get("is_jstestfuzz", False) + implicit_multiversion = run_vars.get("implicit_multiversion", False) + + if implicit_multiversion: + assert suite is not None + is_sharded = self.multiversion_util.is_suite_sharded(suite) + version_list = get_version_configs(is_sharded) + + if is_jstestfuzz: fuzzer_params = self.task_def_to_fuzzer_params( task_def, build_variant_name, is_sharded, version_list) jobs.append(exe.submit(builder.generate_fuzzer, fuzzer_params)) else: split_params = self.task_def_to_split_params(task_def, build_variant_name) - gen_params = self.task_def_to_mv_gen_params(task_def, build_variant_name, - is_sharded, version_list) - jobs.append( - exe.submit(builder.add_multiversion_suite, split_params, gen_params)) + if implicit_multiversion: + gen_params = self.task_def_to_mv_gen_params( + task_def, build_variant_name, is_sharded, version_list) + jobs.append( + exe.submit(builder.add_multiversion_suite, split_params, + gen_params)) + else: + gen_params = self.task_def_to_gen_params(task_def, build_variant_name) + jobs.append( + exe.submit(builder.generate_suite, split_params, gen_params)) [j.result() for j in jobs] # pylint: disable=expression-not-assigned diff --git a/buildscripts/task_generation/gen_task_service.py b/buildscripts/task_generation/gen_task_service.py index 6492df50995..b6231f825a9 100644 --- a/buildscripts/task_generation/gen_task_service.py +++ b/buildscripts/task_generation/gen_task_service.py @@ -96,8 +96,6 @@ class GenTaskService: :param build_variant: Build variant to add generated configuration to. :param gen_params: Parameters to configuration how tasks are generated. """ - # self.build_tasks = self.evg_api.tasks_by_build(self.options.build_id) - execution_tasks = self.resmoke_gen_task_service.generate_tasks(generated_suite, gen_params) distros = self._get_distro(build_variant.name, gen_params.use_large_distro, gen_params.large_distro_name) @@ -114,8 +112,6 @@ class GenTaskService: :param build_variant: Build variant to add generated configuration to. :param gen_params: Parameters to configuration how tasks are generated. """ - # self.build_tasks = self.evg_api.tasks_by_build(self.options.build_id) - execution_tasks = self.multiversion_gen_task_service.generate_tasks( generated_suite, gen_params) distros = self._get_distro(build_variant.name, gen_params.use_large_distro, diff --git a/buildscripts/tests/test_evergreen_gen_build_variant.py b/buildscripts/tests/test_evergreen_gen_build_variant.py index 3204c63db83..a2fa41bd5db 100644 --- a/buildscripts/tests/test_evergreen_gen_build_variant.py +++ b/buildscripts/tests/test_evergreen_gen_build_variant.py @@ -1,26 +1,10 @@ """Unit tests for the generate_resmoke_suite script.""" -from datetime import datetime, timedelta -import json -import os -from tempfile import TemporaryDirectory -import sys import unittest -import inject -import requests -import yaml -from mock import patch, MagicMock -from evergreen import EvergreenApi +from mock import MagicMock from buildscripts import evergreen_gen_build_variant as under_test -from buildscripts.ciconfig.evergreen import Variant, Task, EvergreenProjectConfig -from buildscripts.evergreen_gen_build_variant import EvgExpansions -from buildscripts.task_generation.gen_config import GenerationConfiguration -from buildscripts.task_generation.resmoke_proxy import ResmokeProxyConfig -from buildscripts.task_generation.suite_split import SuiteSplitConfig -from buildscripts.task_generation.suite_split_strategies import SplitStrategy, FallbackStrategy, \ - greedy_division, round_robin_fallback -from buildscripts.task_generation.task_types.gentask_options import GenTaskOptions +from buildscripts.ciconfig.evergreen import Variant, Task # pylint: disable=missing-docstring,invalid-name,unused-argument,no-self-use,protected-access # pylint: disable=too-many-locals,too-many-lines,too-many-public-methods,no-value-for-parameter @@ -41,13 +25,13 @@ def build_mock_build_variant(expansions=None, task_list=None): return Variant(config, task_map, {}) -def build_mock_task(name, run_cmd, run_vars=None): +def build_mock_task(name, run_vars=None): config = { "name": name, "commands": [ {"func": "do setup"}, { - "func": run_cmd, + "func": "generate resmoke tasks", "vars": run_vars if run_vars else {}, }, ] @@ -135,7 +119,7 @@ class TestTaskDefToSplitParams(unittest.TestCase): run_vars = { "resmoke_args": "run tests", } - mock_task_def = build_mock_task("my_task", "generate resmoke tasks", run_vars) + mock_task_def = build_mock_task("my_task", run_vars) mock_orchestrator = build_mock_orchestrator(task_def_list=[mock_task_def]) split_param = mock_orchestrator.task_def_to_split_params(mock_task_def, "build_variant") @@ -150,7 +134,7 @@ class TestTaskDefToSplitParams(unittest.TestCase): "resmoke_args": "run tests", "suite": "the suite", } - mock_task_def = build_mock_task("my_task", "generate resmoke tasks", run_vars) + mock_task_def = build_mock_task("my_task", run_vars) mock_orchestrator = build_mock_orchestrator(task_def_list=[mock_task_def]) split_param = mock_orchestrator.task_def_to_split_params(mock_task_def, "build_variant") @@ -166,7 +150,7 @@ class TestTaskDefToGenParams(unittest.TestCase): run_vars = { "resmoke_args": "run tests", } - mock_task_def = build_mock_task("my_task", "generate resmoke tasks", run_vars) + mock_task_def = build_mock_task("my_task", run_vars) mock_orchestrator = build_mock_orchestrator(task_def_list=[mock_task_def]) gen_params = mock_orchestrator.task_def_to_gen_params(mock_task_def, "build_variant") @@ -184,7 +168,7 @@ class TestTaskDefToGenParams(unittest.TestCase): "use_large_distro": "true", "require_multiversion": True, } - mock_task_def = build_mock_task("my_task", "generate resmoke tasks", run_vars) + mock_task_def = build_mock_task("my_task", run_vars) build_expansions = {"large_distro_name": "my large distro"} mock_orchestrator = build_mock_orchestrator(build_expansions=build_expansions, task_def_list=[mock_task_def]) @@ -205,7 +189,7 @@ class TestTaskDefToFuzzerParams(unittest.TestCase): "num_files": "5", "num_tasks": "3", } - mock_task_def = build_mock_task("my_task", "generate fuzzer tasks", run_vars) + mock_task_def = build_mock_task("my_task", run_vars) mock_orchestrator = build_mock_orchestrator(task_def_list=[mock_task_def]) fuzzer_params = mock_orchestrator.task_def_to_fuzzer_params(mock_task_def, "build_variant") @@ -226,7 +210,7 @@ class TestTaskDefToFuzzerParams(unittest.TestCase): "use_large_distro": "true", "npm_command": "aggfuzzer", } - mock_task_def = build_mock_task("my_task", "generate fuzzer tasks", run_vars) + mock_task_def = build_mock_task("my_task", run_vars) build_expansions = {"large_distro_name": "my large distro"} mock_orchestrator = build_mock_orchestrator(build_expansions=build_expansions, task_def_list=[mock_task_def]) @@ -248,11 +232,16 @@ class TestGenerateBuildVariant(unittest.TestCase): gen_run_vars = { "resmoke_args": "run tests", } - mv_gen_run_vars = {"resmoke_args": "run tests", "suite": "multiversion suite"} + mv_gen_run_vars = { + "resmoke_args": "run tests", + "suite": "multiversion suite", + "implicit_multiversion": "True", + } fuzz_run_vars = { "name": "my_fuzzer", "num_files": "5", "num_tasks": "3", + "is_jstestfuzz": "True", } mv_fuzz_run_vars = { "name": "my_fuzzer", @@ -260,14 +249,13 @@ class TestGenerateBuildVariant(unittest.TestCase): "num_tasks": "3", "is_jstestfuzz": "True", "suite": "aggfuzzer", + "implicit_multiversion": "True", } mock_task_defs = [ - build_mock_task("my_gen_task", "generate resmoke tasks", gen_run_vars), - build_mock_task("my_fuzzer_task", "generate fuzzer tasks", fuzz_run_vars), - build_mock_task("my_mv_fuzzer_task", "generate implicit multiversion tasks", - mv_fuzz_run_vars), - build_mock_task("my_mv_gen_task", "generate implicit multiversion tasks", - mv_gen_run_vars), + build_mock_task("my_gen_task", gen_run_vars), + build_mock_task("my_fuzzer_task", fuzz_run_vars), + build_mock_task("my_mv_fuzzer_task", mv_fuzz_run_vars), + build_mock_task("my_mv_gen_task", mv_gen_run_vars), ] mock_orchestrator = build_mock_orchestrator(task_def_list=mock_task_defs) builder = MagicMock() |