summaryrefslogtreecommitdiff
path: root/buildscripts/task_generation
diff options
context:
space:
mode:
authorMikhail Shchatko <mikhail.shchatko@mongodb.com>2021-10-25 11:34:21 +0300
committerEvergreen Agent <no-reply@evergreen.mongodb.com>2021-10-26 12:32:19 +0000
commita62bc5316de00b706e1308ed35a98f597b89f2dc (patch)
tree7fe2b3d86a0bd185fb01217b26d99278e89949e0 /buildscripts/task_generation
parent4a8881d3f61be8e57b55a33e076bace92b3e6aad (diff)
downloadmongo-a62bc5316de00b706e1308ed35a98f597b89f2dc.tar.gz
SERVER-49763 Run fuzzers against last-continuous and last-lts
Diffstat (limited to 'buildscripts/task_generation')
-rw-r--r--buildscripts/task_generation/constants.py5
-rw-r--r--buildscripts/task_generation/gen_task_service.py2
-rw-r--r--buildscripts/task_generation/task_types/fuzzer_tasks.py26
-rw-r--r--buildscripts/task_generation/task_types/multiversion_decorator.py105
-rw-r--r--buildscripts/task_generation/task_types/resmoke_tasks.py4
5 files changed, 127 insertions, 15 deletions
diff --git a/buildscripts/task_generation/constants.py b/buildscripts/task_generation/constants.py
index 022189dfa66..31531d3592d 100644
--- a/buildscripts/task_generation/constants.py
+++ b/buildscripts/task_generation/constants.py
@@ -17,3 +17,8 @@ EXCLUDES_TAGS_FILE_PATH = os.path.join(GENERATED_CONFIG_DIR, "multiversion_exclu
GEN_PARENT_TASK = "generator_tasks"
EXPANSION_RE = re.compile(r"\${(?P<id>[a-zA-Z0-9_]+)(\|(?P<default>.*))?}")
BACKPORT_REQUIRED_TAG = "backport_required_multiversion"
+
+# evergreen.yml function names.
+CONFIGURE_EVG_CREDENTIALS = "configure evergreen api credentials"
+DO_MULTIVERSION_SETUP = "do multiversion setup"
+RUN_GENERATED_TESTS = "run generated tests"
diff --git a/buildscripts/task_generation/gen_task_service.py b/buildscripts/task_generation/gen_task_service.py
index 349ec0ebae0..0f6d9c240ee 100644
--- a/buildscripts/task_generation/gen_task_service.py
+++ b/buildscripts/task_generation/gen_task_service.py
@@ -80,7 +80,7 @@ class GenTaskService:
return fuzzer_task
def generate_task(self, generated_suite: GeneratedSuite, build_variant: BuildVariant,
- gen_params: ResmokeGenTaskParams) -> List[Task]:
+ gen_params: ResmokeGenTaskParams) -> Set[Task]:
"""
Generate evergreen configuration for the given suite and add it to the build_variant.
diff --git a/buildscripts/task_generation/task_types/fuzzer_tasks.py b/buildscripts/task_generation/task_types/fuzzer_tasks.py
index cc4b0c9ecfd..1e62f668d4c 100644
--- a/buildscripts/task_generation/task_types/fuzzer_tasks.py
+++ b/buildscripts/task_generation/task_types/fuzzer_tasks.py
@@ -4,7 +4,9 @@ from typing import NamedTuple, Set, Optional, Dict
from shrub.v2 import Task, FunctionCall, TaskDependency
from buildscripts.patch_builds.task_generation import TimeoutInfo
-from buildscripts.task_generation.constants import ARCHIVE_DIST_TEST_DEBUG_TASK
+from buildscripts.task_generation.constants import ARCHIVE_DIST_TEST_DEBUG_TASK, CONFIGURE_EVG_CREDENTIALS, \
+ RUN_GENERATED_TESTS
+from buildscripts.task_generation.task_types.multiversion_decorator import MultiversionGenTaskDecorator
from buildscripts.util import taskname
@@ -72,6 +74,10 @@ class FuzzerGenTaskParams(NamedTuple):
class FuzzerGenTaskService:
"""A service for generating fuzzer tasks."""
+ def __init__(self):
+ """Initialize the service."""
+ self.multiversion_decorator = MultiversionGenTaskDecorator()
+
def generate_tasks(self, params: FuzzerGenTaskParams) -> FuzzerTask:
"""
Generate evergreen tasks for fuzzers based on the options given.
@@ -84,6 +90,9 @@ class FuzzerGenTaskService:
{self.build_fuzzer_sub_task(index, params)
for index in range(params.num_tasks)})
+ if params.require_multiversion_setup:
+ sub_tasks = self.multiversion_decorator.decorate_tasks(sub_tasks, params)
+
return FuzzerTask(task_name=params.task_name, sub_tasks=sub_tasks)
@staticmethod
@@ -112,22 +121,13 @@ class FuzzerGenTaskService:
timeout_info = TimeoutInfo.overridden(timeout=params.timeout_secs)
- commands = []
-
- if params.require_multiversion_setup:
- commands += [FunctionCall("git get project no modules")]
- commands += [FunctionCall("add git tag")]
-
- commands += [
+ commands = [
timeout_info.cmd,
FunctionCall("do setup"),
- FunctionCall("configure evergreen api credentials")
- if params.require_multiversion_setup else None,
- FunctionCall("do multiversion setup") if params.require_multiversion_setup else None,
+ FunctionCall(CONFIGURE_EVG_CREDENTIALS),
FunctionCall("setup jstestfuzz"),
FunctionCall("run jstestfuzz", params.jstestfuzz_params()),
- FunctionCall("run generated tests", run_tests_vars)
+ FunctionCall(RUN_GENERATED_TESTS, run_tests_vars)
]
- commands = [command for command in commands if command is not None]
return Task(sub_task_name, commands, {TaskDependency(ARCHIVE_DIST_TEST_DEBUG_TASK)})
diff --git a/buildscripts/task_generation/task_types/multiversion_decorator.py b/buildscripts/task_generation/task_types/multiversion_decorator.py
new file mode 100644
index 00000000000..beb47392828
--- /dev/null
+++ b/buildscripts/task_generation/task_types/multiversion_decorator.py
@@ -0,0 +1,105 @@
+"""Multiversion decorator for basic generated tasks."""
+import copy
+from typing import List, Set, Union, Optional
+
+from shrub.v2 import Task, FunctionCall
+from shrub.v2.command import ShrubCommand
+
+from buildscripts.task_generation.constants import DO_MULTIVERSION_SETUP, CONFIGURE_EVG_CREDENTIALS, RUN_GENERATED_TESTS
+from buildscripts.task_generation.resmoke_proxy import ResmokeProxyService
+from buildscripts.util import taskname
+
+
+class _SuiteFixtureType:
+ """Suite fixture types."""
+
+ SHELL = "shell"
+ REPL = "repl"
+ SHARD = "shard"
+ OTHER = "other"
+
+
+class MultiversionGenTaskDecorator:
+ """Multiversion decorator for basic generated tasks."""
+
+ # pylint: disable=no-self-use
+ def __init__(self):
+ """Initialize multiversion decorator."""
+ self.resmoke_proxy = ResmokeProxyService()
+ self.old_versions = ["last_lts", "last_continuous"]
+
+ def decorate_tasks(self, sub_tasks: Set[Task], params) -> Set[Task]:
+ """Make multiversion subtasks based on generated subtasks."""
+ fixture_type = self._get_suite_fixture_type(params.suite)
+ versions_combinations = self._get_versions_combinations(fixture_type)
+
+ decorated_tasks = set()
+ for old_version in self.old_versions:
+ for mixed_bin_versions in versions_combinations:
+ for index, sub_task in enumerate(sub_tasks):
+ commands = list(sub_task.commands)
+ base_task_name = self._build_name(params.task_name, old_version,
+ mixed_bin_versions.replace("-", "_"))
+ sub_task_name = taskname.name_generated_task(base_task_name, index,
+ params.num_tasks, params.variant)
+ suite_name = self._build_name(params.suite, old_version,
+ mixed_bin_versions.replace("-", "_"))
+ self._update_suite_name(commands, suite_name)
+ commands = self._add_multiversion_commands(commands)
+ decorated_tasks.add(
+ Task(name=sub_task_name, commands=commands,
+ dependencies=sub_task.dependencies))
+ return decorated_tasks
+
+ def _get_suite_fixture_type(self, suite_name: str) -> str:
+ """Return suite fixture type."""
+ source_config = self.resmoke_proxy.read_suite_config(suite_name)
+ if "fixture" not in source_config["executor"]:
+ return _SuiteFixtureType.SHELL
+ if source_config["executor"]["fixture"]["class"] == "ShardedClusterFixture":
+ return _SuiteFixtureType.SHARD
+ if source_config["executor"]["fixture"]["class"] == "ReplicaSetFixture":
+ return _SuiteFixtureType.REPL
+ return _SuiteFixtureType.OTHER
+
+ def _get_versions_combinations(self, fixture_type: str) -> List[str]:
+ return {
+ _SuiteFixtureType.SHELL: [""],
+ _SuiteFixtureType.SHARD: ["new-old-old-new"],
+ _SuiteFixtureType.REPL: ["new-new-old", "new-old-new", "old-new-new"],
+ _SuiteFixtureType.OTHER: [""],
+ }[fixture_type]
+
+ def _build_name(self, base_name: str, *suffixes: str) -> str:
+ parts = [base_name]
+ parts.extend(suffixes)
+ return "_".join(part for part in parts if part != "")
+
+ def _find_command(self, name: str, commands: List[Union[FunctionCall, ShrubCommand]]
+ ) -> (Optional[int], Optional[FunctionCall]):
+ for index, command in enumerate(commands):
+ if hasattr(command, "name") and command.name == name:
+ return index, command
+ return None, None
+
+ def _update_suite_name(self, commands: List[Union[FunctionCall, ShrubCommand]],
+ suite_name: str):
+ index, run_test_func = self._find_command(RUN_GENERATED_TESTS, commands)
+ if run_test_func is not None:
+ run_test_vars = copy.deepcopy(run_test_func.parameters)
+ run_test_vars["suite"] = suite_name
+ commands[index] = FunctionCall(RUN_GENERATED_TESTS, run_test_vars)
+
+ def _add_multiversion_commands(self, commands: List[Union[FunctionCall, ShrubCommand]]
+ ) -> List[Union[FunctionCall, ShrubCommand]]:
+ res = [
+ FunctionCall("git get project no modules"),
+ FunctionCall("add git tag"),
+ ]
+ for command in commands:
+ res.append(command)
+
+ if hasattr(command, "name") and command.name == CONFIGURE_EVG_CREDENTIALS:
+ # Run multiversion setup after getting EVG credentials.
+ res.append(FunctionCall(DO_MULTIVERSION_SETUP))
+ return res
diff --git a/buildscripts/task_generation/task_types/resmoke_tasks.py b/buildscripts/task_generation/task_types/resmoke_tasks.py
index 9a94cf0b38a..36afe72c54f 100644
--- a/buildscripts/task_generation/task_types/resmoke_tasks.py
+++ b/buildscripts/task_generation/task_types/resmoke_tasks.py
@@ -81,7 +81,9 @@ class ResmokeGenTaskService:
tasks.add(
self._create_sub_task(None, est_timeout=TimeoutEstimate.no_timeouts(),
suite=generated_suite, params=params))
-
+ if params.require_multiversion_setup:
+ # do the same thing as the fuzzer taks.
+ pass
return tasks
def _create_sub_task(self, index: Optional[int], est_timeout: TimeoutEstimate,