summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--buildscripts/patch_builds/selected_tests/__init__.py1
-rw-r--r--buildscripts/patch_builds/selected_tests/selected_tests_client.py171
-rw-r--r--buildscripts/patch_builds/selected_tests/selected_tests_service.py52
-rw-r--r--buildscripts/selected_tests.py517
-rw-r--r--buildscripts/tests/patch_builds/selected_tests/__init__.py1
-rw-r--r--buildscripts/tests/patch_builds/selected_tests/test_selected_tests_client.py87
-rw-r--r--buildscripts/tests/patch_builds/selected_tests/test_selected_tests_service.py87
-rw-r--r--buildscripts/tests/test_selected_tests.py412
-rw-r--r--etc/evergreen.yml13
-rw-r--r--etc/evergreen_yml_components/definitions.yml59
-rwxr-xr-xevergreen/functions/selected_tests_credentials_configure.sh12
-rw-r--r--evergreen/selected_tests_generate.sh13
12 files changed, 0 insertions, 1425 deletions
diff --git a/buildscripts/patch_builds/selected_tests/__init__.py b/buildscripts/patch_builds/selected_tests/__init__.py
deleted file mode 100644
index 4b7a2bb941b..00000000000
--- a/buildscripts/patch_builds/selected_tests/__init__.py
+++ /dev/null
@@ -1 +0,0 @@
-"""Empty."""
diff --git a/buildscripts/patch_builds/selected_tests/selected_tests_client.py b/buildscripts/patch_builds/selected_tests/selected_tests_client.py
deleted file mode 100644
index afb50730df4..00000000000
--- a/buildscripts/patch_builds/selected_tests/selected_tests_client.py
+++ /dev/null
@@ -1,171 +0,0 @@
-#!/usr/bin/env python3
-"""Client for accessing selected test app."""
-
-from typing import Set, List, Dict, Any
-from urllib.parse import urlparse
-
-import requests
-import yaml
-from pydantic import BaseModel
-
-
-class TestFileInstance(BaseModel):
- """
- Frequency of how often a test file was seen.
-
- name: Name of test file.
- test_file_seen_count: Occurrences of test file.
- """
-
- name: str
- test_file_seen_count: int
-
-
-class TestMapping(BaseModel):
- """
- How tests map to the specified source files.
-
- branch: Git branch being analyzed.
- project: Evergreen project being analyzed.
- repo: Git repo being analyzed.
- source_file: Source file of mappings.
- source_file_seen_count: Number of occurrences of source file.
- test_files: Test files that have been changed with the source file.
- """
-
- branch: str
- project: str
- repo: str
- source_file: str
- source_file_seen_count: int
- test_files: List[TestFileInstance]
-
-
-class TestMappingsResponse(BaseModel):
- """
- Response from the test mappings end point.
-
- test_mappings: List of source files with correlated test files.
- """
-
- test_mappings: List[TestMapping]
-
-
-class TaskMapInstance(BaseModel):
- """
- Frequency of how often a task is impacted by a source file change.
-
- name: Name of task that was impacted.
- variant: Name of build variant task was run on.
- flip_count: Number of times the task was impacted by the source file.
- """
-
- name: str
- variant: str
- flip_count: int
-
-
-class TaskMapping(BaseModel):
- """
- How tasks map to the specified source files.
-
- branch: Git branch being analyzed.
- project: Evergreen project being analyzed.
- repo: Git repo being analyzed.
- source_file: Source file of mappings.
- source_file_seen_count: Number of occurrences of source file.
- tasks: Tasks that have been impacted by the source file.
- """
-
- branch: str
- project: str
- repo: str
- source_file: str
- source_file_seen_count: int
- tasks: List[TaskMapInstance]
-
-
-class TaskMappingsResponse(BaseModel):
- """
- Response from the task mappings end point.
-
- task_mappings: List of source files with correlated tasks.
- """
-
- task_mappings: List[TaskMapping]
-
-
-class SelectedTestsClient(object):
- """Selected-tests client object."""
-
- def __init__(self, url: str, project: str, auth_user: str, auth_token: str) -> None:
- """
- Create selected-tests client object.
-
- :param url: Selected-tests service url.
- :param project: Selected-tests service project.
- :param auth_user: Selected-tests service auth user to authenticate request.
- :param auth_token: Selected-tests service auth token to authenticate request.
- """
- self.url = url
- self.project = project
- self.session = requests.Session()
- adapter = requests.adapters.HTTPAdapter()
- self.session.mount(f"{urlparse(self.url).scheme}://", adapter)
- self.session.cookies.update({"auth_user": auth_user, "auth_token": auth_token})
- self.session.headers.update(
- {"Content-type": "application/json", "Accept": "application/json"})
-
- @classmethod
- def from_file(cls, filename: str) -> "SelectedTestsClient":
- """
- Read config from given filename.
-
- :param filename: Filename to read config.
- :return: Config read from file.
- """
- with open(filename, 'r') as fstream:
- config = yaml.safe_load(fstream)
- if config:
- return cls(config["url"], config["project"], config["auth_user"],
- config["auth_token"])
-
- raise ValueError(f"Could not determine selected tests configuration from {filename}")
-
- def _call_api(self, endpoint: str, payload: Dict[str, Any]) -> Dict[str, Any]:
- """
- Make a call to the selected tests service and return the response.
-
- :param endpoint: Endpoint to call.
- :param payload: Payload to call with.
- :return: Response from service.
- """
- url = f"{self.url}{endpoint}"
- response = self.session.get(url, params=payload)
- response.raise_for_status()
-
- return response.json()
-
- def get_test_mappings(self, threshold: float, changed_files: Set[str]) -> TestMappingsResponse:
- """
- Request related test files from selected-tests service.
-
- :param threshold: Threshold for test file correlation.
- :param changed_files: Set of changed_files.
- :return: Related test files returned by selected-tests service.
- """
- payload = {"threshold": threshold, "changed_files": ",".join(changed_files)}
- response = self._call_api(f"/projects/{self.project}/test-mappings", payload)
- return TestMappingsResponse(**response)
-
- def get_task_mappings(self, threshold: float, changed_files: Set[str]) -> TaskMappingsResponse:
- """
- Request related tasks from selected-tests service.
-
- :param threshold: Threshold for test file correlation.
- :param changed_files: Set of changed_files.
- :return: Related tasks returned by selected-tests service.
- """
- payload = {"threshold": threshold, "changed_files": ",".join(changed_files)}
- response = self._call_api(f"/projects/{self.project}/task-mappings", payload)
- return TaskMappingsResponse(**response)
diff --git a/buildscripts/patch_builds/selected_tests/selected_tests_service.py b/buildscripts/patch_builds/selected_tests/selected_tests_service.py
deleted file mode 100644
index 88e1355b33a..00000000000
--- a/buildscripts/patch_builds/selected_tests/selected_tests_service.py
+++ /dev/null
@@ -1,52 +0,0 @@
-#!/usr/bin/env python3
-"""Selected Tests service."""
-from typing import Set
-
-import inject
-
-from buildscripts.burn_in_tests import is_file_a_test_file
-from buildscripts.patch_builds.selected_tests.selected_tests_client import SelectedTestsClient
-
-DEFAULT_THRESHOLD = 0
-
-
-class SelectedTestsService:
- """A service for interacting with selected tests."""
-
- @inject.autoparams()
- def __init__(self, selected_tests_client: SelectedTestsClient) -> None:
- """
- Initialize the service.
-
- :param selected_tests_client: Client to query selected tests.
- """
- self.selected_tests_client = selected_tests_client
-
- def find_selected_test_files(self, changed_files: Set[str]) -> Set[str]:
- """
- Request related test files from selected-tests service and filter invalid files.
-
- :param changed_files: Set of changed_files.
- :return: Set of test files returned by selected-tests service that are valid test files.
- """
- test_mappings = self.selected_tests_client.get_test_mappings(DEFAULT_THRESHOLD,
- changed_files)
- return {
- test_file.name
- for test_mapping in test_mappings.test_mappings for test_file in test_mapping.test_files
- if is_file_a_test_file(test_file.name)
- }
-
- def find_selected_tasks(self, changed_files: Set[str]) -> Set[str]:
- """
- Request tasks from selected-tests.
-
- :param changed_files: Set of changed_files.
- :return: Set of tasks returned by selected-tests service that should not be excluded.
- """
- task_mappings = self.selected_tests_client.get_task_mappings(DEFAULT_THRESHOLD,
- changed_files)
- return {
- task.name
- for task_mapping in task_mappings.task_mappings for task in task_mapping.tasks
- }
diff --git a/buildscripts/selected_tests.py b/buildscripts/selected_tests.py
deleted file mode 100644
index f39666a0c37..00000000000
--- a/buildscripts/selected_tests.py
+++ /dev/null
@@ -1,517 +0,0 @@
-#!/usr/bin/env python3
-"""Command line utility for determining what jstests should run for the given changed files."""
-import os
-import re
-import sys
-import hashlib
-from datetime import datetime, timedelta
-from functools import partial
-from typing import Any, Dict, List, Set, Optional
-
-import click
-import inject
-import structlog
-from pydantic import BaseModel
-from structlog.stdlib import LoggerFactory
-from git import Repo
-from evergreen.api import EvergreenApi, RetryingEvergreenApi
-
-if __name__ == "__main__" and __package__ is None:
- sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
-
-# pylint: disable=wrong-import-position
-# Get relative imports to work when the package is not installed on the PYTHONPATH.
-from buildscripts.patch_builds.change_data import find_changed_files_in_repos
-from buildscripts.patch_builds.evg_change_data import generate_revision_map_from_manifest
-from buildscripts.patch_builds.selected_tests.selected_tests_client import SelectedTestsClient
-from buildscripts.task_generation.evg_config_builder import EvgConfigBuilder
-from buildscripts.task_generation.gen_config import GenerationConfiguration
-from buildscripts.task_generation.generated_config import GeneratedConfiguration
-from buildscripts.task_generation.suite_split import SuiteSplitParameters, 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.task_generation.task_types.resmoke_tasks import ResmokeGenTaskParams
-from buildscripts.util.cmdutils import enable_logging
-from buildscripts.util.fileops import read_yaml_file
-from buildscripts.burn_in_tests import DEFAULT_REPO_LOCATIONS, create_task_list_for_tests, \
- TaskInfo
-from buildscripts.ciconfig.evergreen import (
- EvergreenProjectConfig,
- Task,
- parse_evergreen_file,
- Variant,
-)
-from buildscripts.patch_builds.selected_tests.selected_tests_service import SelectedTestsService
-
-structlog.configure(logger_factory=LoggerFactory())
-LOGGER = structlog.getLogger(__name__)
-
-TASK_ID_EXPANSION = "task_id"
-EVERGREEN_FILE = "etc/evergreen.yml"
-EVG_CONFIG_FILE = ".evergreen.yml"
-SELECTED_TESTS_CONFIG_DIR = "generated_resmoke_config"
-RELATION_THRESHOLD = 0
-LOOKBACK_DURATION_DAYS = 14
-
-COMPILE_TASK_PATTERN = re.compile(".*compile.*")
-CONCURRENCY_TASK_PATTERN = re.compile("concurrency.*")
-INTEGRATION_TASK_PATTERN = re.compile("integration.*")
-FUZZER_TASK_PATTERN = re.compile(".*fuzz.*")
-GENERATE_TASK_PATTERN = re.compile("burn_in.*")
-MULTIVERSION_TASK_PATTERN = re.compile(".*multiversion.*")
-LINT_TASK_PATTERN = re.compile("lint.*")
-STITCH_TASK_PATTERN = re.compile("stitch.*")
-EXCLUDE_TASK_PATTERNS = [
- COMPILE_TASK_PATTERN, CONCURRENCY_TASK_PATTERN, INTEGRATION_TASK_PATTERN, FUZZER_TASK_PATTERN,
- GENERATE_TASK_PATTERN, LINT_TASK_PATTERN, MULTIVERSION_TASK_PATTERN, STITCH_TASK_PATTERN
-]
-
-CPP_TASK_NAMES = [
- "dbtest",
- "idl_tests",
- "run_unittests",
-]
-PUBLISH_TASK_NAMES = [
- "package",
- "publish_packages",
- "push",
-]
-PYTHON_TESTS = ["buildscripts_test"]
-EXCLUDE_TASK_LIST = [
- *CPP_TASK_NAMES,
- *PYTHON_TESTS,
- *PUBLISH_TASK_NAMES,
-]
-POSSIBLE_RUN_TASK_FUNCS = [
- "generate resmoke tasks",
- "run tests",
-]
-
-
-class EvgExpansions(BaseModel):
- """
- Evergreen expansions needed for selected tests.
-
- task_id: ID of task being run.
- task_name: Name of task being run.
- build_variant: Name of build variant being run on.
- build_id: ID of build being run.
- is_patch: Is this task run as part of a patch build.
- project: Evergreen project being run.
- revision: git revision being run against.
- version_id: ID of version being run.
- """
-
- task_id: str
- task_name: str
- build_variant: str
- build_id: str
- is_patch: Optional[bool] = None
- project: str
- revision: str
- version_id: str
-
- @classmethod
- def from_yaml_file(cls, path: str) -> "EvgExpansions":
- """Read the generation configuration from the given file."""
- return cls(**read_yaml_file(path))
-
- def build_gen_task_options(self) -> GenTaskOptions:
- """Build options needed to generate tasks."""
- return GenTaskOptions(create_misc_suite=False,
- generated_config_dir=SELECTED_TESTS_CONFIG_DIR, is_patch=self.is_patch
- or False, use_default_timeouts=False, timeout_secs=None,
- exec_timeout_secs=None)
-
- def build_suite_split_config(self, start_date: datetime,
- end_date: datetime) -> SuiteSplitConfig:
- """
- Build options need to split suite into sub-suites.
-
- :param start_date: Start date to look at historic results.
- :param end_date: End date to look at historic results.
- :return: Options for splitting suites.
- """
- return SuiteSplitConfig(
- evg_project=self.project,
- target_resmoke_time=60,
- max_sub_suites=5,
- max_tests_per_suite=100,
- start_date=start_date,
- end_date=end_date,
- include_build_variant_in_name=True,
- )
-
- def get_config_location(self) -> str:
- """Get the location the generated configuration will be stored."""
- file = f"{self.build_variant}/{self.revision}/generate_tasks/{self.task_name}-{self.build_id}"
- # hash 'file' to shorten the file path dramatically
- sha1 = hashlib.sha1()
- sha1.update(file.encode('utf-8'))
- return f"gtcl/{sha1.hexdigest()}.tgz"
-
-
-class TaskConfigService:
- """Service for generating selected tests task configuration."""
-
- @staticmethod
- def get_evg_task_config(task: Task, build_variant_config: Variant) -> Dict[str, Any]:
- """
- Look up task config of the task to be generated.
-
- :param task: Task to get info for.
- :param build_variant_config: Config of build variant to collect task info from.
- :return: Task configuration values.
- """
- LOGGER.info("Calculating evg_task_config values for task", task=task.name)
- task_vars = {}
- for run_task_func in POSSIBLE_RUN_TASK_FUNCS:
- task_def = task.find_func_command(run_task_func)
- if task_def:
- task_vars = task_def.get("vars", {})
- break
-
- task_vars.update({"suite": task.get_suite_name()})
-
- task_name = task.name[:-4] if task.name.endswith("_gen") else task.name
- return {
- "task_name": task_name,
- "build_variant": build_variant_config.name,
- **task_vars,
- "large_distro_name": build_variant_config.expansion("large_distro_name"),
- }
-
- def get_task_configs_for_test_mappings(self, tests_by_task: Dict[str, TaskInfo],
- build_variant_config: Variant) -> Dict[str, dict]:
- """
- For test mappings, generate a dict containing task names and their config settings.
-
- :param tests_by_task: Dictionary of tests and tasks to run.
- :param build_variant_config: Config of build variant to collect task info from.
- :return: Dict of task names and their config settings.
- """
- evg_task_configs = {}
- for task_name, test_list_info in tests_by_task.items():
- task = _find_task(build_variant_config, task_name)
- if task and not _exclude_task(task):
- evg_task_config = self.get_evg_task_config(task, build_variant_config)
- evg_task_config.update({"selected_tests_to_run": set(test_list_info.tests)})
- evg_task_configs[task.name] = evg_task_config
-
- return evg_task_configs
-
- def get_task_configs_for_task_mappings(self, related_tasks: List[str],
- build_variant_config: Variant) -> Dict[str, dict]:
- """
- For task mappings, generate a dict containing task names and their config settings.
-
- :param related_tasks: List of tasks to run.
- :param build_variant_config: Config of build variant to collect task info from.
- :return: Dict of task names and their config settings.
- """
- evg_task_configs = {}
- for task_name in related_tasks:
- task = _find_task(build_variant_config, task_name)
- if task and not _exclude_task(task):
- evg_task_config = self.get_evg_task_config(task, build_variant_config)
- evg_task_configs[task.name] = evg_task_config
-
- return evg_task_configs
-
-
-def _exclude_task(task: Task) -> bool:
- """
- Check whether a task should be excluded.
-
- :param task: Task to get info for.
- :return: True if this task should be excluded.
- """
- if task.name in EXCLUDE_TASK_LIST or any(
- regex.match(task.name) for regex in EXCLUDE_TASK_PATTERNS):
- LOGGER.debug("Excluding task from analysis because it is not a jstest", task=task.name)
- return True
- return False
-
-
-def _find_task(build_variant_config: Variant, task_name: str) -> Task:
- """
- Look up shrub config for task.
-
- :param build_variant_config: Config of build variant to collect task info from.
- :param task_name: Name of task to get info for.
- :return: Task configuration.
- """
- task = build_variant_config.get_task(task_name)
- if not task:
- task = build_variant_config.get_task(task_name + "_gen")
- return task
-
-
-def _remove_repo_path_prefix(file_path: str) -> str:
- """
- Remove the repo path prefix from the filepath.
-
- :param file_path: Path of the changed file.
- :return: Path of the changed file without prefix.
- """
- for repo_path in DEFAULT_REPO_LOCATIONS:
- if repo_path != ".":
- if repo_path.startswith("./"):
- repo_path = repo_path[2:]
- file_path = re.sub(repo_path + "/", '', file_path)
- return file_path
-
-
-def filter_set(item: str, input_set: Set[str]) -> bool:
- """
- Filter to determine if the given item is in the given set.
-
- :param item: Item to search for.
- :param input_set: Set to search.
- :return: True if the item is contained in the list.
- """
- return item in input_set
-
-
-class SelectedTestsOrchestrator:
- """Orchestrator for generating selected test builds."""
-
- # pylint: disable=too-many-arguments
- @inject.autoparams()
- def __init__(self, evg_api: EvergreenApi, evg_conf: EvergreenProjectConfig,
- selected_tests_service: SelectedTestsService,
- task_config_service: TaskConfigService, evg_expansions: EvgExpansions) -> None:
- """
- Initialize the orchestrator.
-
- :param evg_api: Evergreen API client.
- :param evg_conf: Evergreen Project configuration.
- :param selected_tests_service: Selected tests service.
- :param task_config_service: Task Config service.
- :param evg_expansions: Evergreen expansions.
- """
- self.evg_api = evg_api
- self.evg_conf = evg_conf
- self.selected_tests_service = selected_tests_service
- self.task_config_service = task_config_service
- self.evg_expansions = evg_expansions
-
- def find_changed_files(self, repos: List[Repo], task_id: str) -> Set[str]:
- """
- Determine what files have changed in the given repos.
-
- :param repos: List of git repos to query.
- :param task_id: ID of task being run.
- :return: Set of files that contain changes.
- """
- revision_map = generate_revision_map_from_manifest(repos, task_id, self.evg_api)
- changed_files = find_changed_files_in_repos(repos, revision_map)
- changed_files = {_remove_repo_path_prefix(file_path) for file_path in changed_files}
- changed_files = {
- file_path
- for file_path in changed_files if not file_path.startswith("src/third_party")
- }
- LOGGER.info("Found changed files", files=changed_files)
- return changed_files
-
- def get_task_config(self, build_variant_config: Variant,
- changed_files: Set[str]) -> Dict[str, Dict]:
- """
- Get task configurations for the tasks to be generated.
-
- :param build_variant_config: Config of build variant to collect task info from.
- :param changed_files: Set of changed_files.
- :return: Task configurations.
- """
- existing_tasks = self.get_existing_tasks(self.evg_expansions.version_id,
- build_variant_config.name)
- task_configs = {}
-
- related_test_files = self.selected_tests_service.find_selected_test_files(changed_files)
- LOGGER.info("related test files found", related_test_files=related_test_files,
- variant=build_variant_config.name)
-
- if related_test_files:
- tests_by_task = create_task_list_for_tests(related_test_files,
- build_variant_config.name, self.evg_conf)
- LOGGER.info("tests and tasks found", tests_by_task=tests_by_task)
- tests_by_task = {
- task: tests
- for task, tests in tests_by_task.items() if task not in existing_tasks
- }
-
- test_mapping_task_configs = self.task_config_service.get_task_configs_for_test_mappings(
- tests_by_task, build_variant_config)
- task_configs.update(test_mapping_task_configs)
-
- related_tasks = self.selected_tests_service.find_selected_tasks(changed_files)
- LOGGER.info("related tasks found", related_tasks=related_tasks,
- variant=build_variant_config.name)
- related_tasks = {task for task in related_tasks if task not in existing_tasks}
- if related_tasks:
- task_mapping_task_configs = self.task_config_service.get_task_configs_for_task_mappings(
- list(related_tasks), build_variant_config)
- # task_mapping_task_configs will overwrite test_mapping_task_configs
- # because task_mapping_task_configs will run all tests rather than a subset of tests
- # and we should err on the side of running all tests
- task_configs.update(task_mapping_task_configs)
-
- return task_configs
-
- def get_existing_tasks(self, version_id: str, build_variant: str) -> Set[str]:
- """
- Get the set of tasks that already exist in the given build.
-
- :param version_id: ID of version to query.
- :param build_variant: Name of build variant to query.
- :return: Set of task names that already exist in the specified build.
- """
- version = self.evg_api.version_by_id(version_id)
-
- try:
- build = version.build_by_variant(build_variant)
- except KeyError:
- LOGGER.debug("No build exists on this build variant for this version yet",
- variant=build_variant)
- return set()
-
- if build:
- tasks_already_in_build = build.get_tasks()
- return {task.display_name for task in tasks_already_in_build}
-
- return set()
-
- def generate_build_variant(self, build_variant_config: Variant, changed_files: Set[str],
- builder: EvgConfigBuilder) -> None:
- """
- Generate the selected tasks on the specified build variant.
-
- :param build_variant_config: Configuration of build variant to generate.
- :param changed_files: List of file changes to determine what to run.
- :param builder: Builder to create new configuration.
- """
- build_variant_name = build_variant_config.name
- LOGGER.info("Generating build variant", build_variant=build_variant_name)
- task_configs = self.get_task_config(build_variant_config, changed_files)
-
- for task_config in task_configs.values():
- task_def = Task(task_config)
- test_filter = None
- if "selected_tests_to_run" in task_config:
- test_filter = partial(filter_set, input_set=task_config["selected_tests_to_run"])
- split_params = SuiteSplitParameters(
- build_variant=build_variant_name,
- task_name=task_config["task_name"],
- suite_name=task_config.get("suite", task_config["task_name"]),
- filename=task_config.get("suite", task_config["task_name"]),
- test_file_filter=test_filter,
- is_asan=build_variant_config.is_asan_build(),
- )
- gen_params = ResmokeGenTaskParams(
- use_large_distro=task_config.get("use_large_distro", False),
- large_distro_name=task_config.get("large_distro_name"),
- require_multiversion_setup=task_def.require_multiversion_setup(),
- require_multiversion_version_combo=False,
- repeat_suites=task_config.get("repeat_suites", 1),
- resmoke_args=task_config.get("resmoke_args", ""),
- resmoke_jobs_max=task_config.get("resmoke_jobs_max"),
- config_location=self.evg_expansions.get_config_location(),
- dependencies={depends_on["name"]
- for depends_on in task_def.depends_on},
- )
- builder.generate_suite(split_params, gen_params)
-
- def generate(self, repos: List[Repo], task_id: str) -> None:
- """
- Build and generate the configuration to create selected tests.
-
- :param repos: List of git repos containing changes to check.
- :param task_id: ID of task being run.
- """
- changed_files = self.find_changed_files(repos, task_id)
- generated_config = self.generate_version(changed_files)
- generated_config.write_all_to_dir(SELECTED_TESTS_CONFIG_DIR)
-
- with open(os.path.join(SELECTED_TESTS_CONFIG_DIR, '..',
- 'gtcl_update_expansions.yml')) as fh:
- fh.write(f"gtcl: {self.evg_expansions.get_config_location()}")
-
- def generate_version(self, changed_files: Set[str]) -> GeneratedConfiguration:
- """
- Generate selected tests configuration for the given file changes.
-
- :param changed_files: Set of files that contain changes.
- :return: Configuration to generate selected-tests tasks.
- """
- builder = EvgConfigBuilder() # pylint: disable=no-value-for-parameter
- for build_variant_config in self.evg_conf.get_required_variants():
- self.generate_build_variant(build_variant_config, changed_files, builder)
-
- return builder.build("selected_tests_config.json")
-
-
-@click.command()
-@click.option("--verbose", "verbose", default=False, is_flag=True, help="Enable extra logging.")
-@click.option(
- "--expansion-file",
- "expansion_file",
- type=str,
- required=True,
- help="Location of expansions file generated by evergreen.",
-)
-@click.option(
- "--evg-api-config",
- "evg_api_config",
- default=EVG_CONFIG_FILE,
- metavar="FILE",
- help="Configuration file with connection info for Evergreen API.",
-)
-@click.option(
- "--selected-tests-config",
- "selected_tests_config",
- required=True,
- metavar="FILE",
- help="Configuration file with connection info for selected tests service.",
-)
-def main(
- verbose: bool,
- expansion_file: str,
- evg_api_config: str,
- selected_tests_config: str,
-):
- """
- Select tasks to be run based on changed files in a patch build.
-
- :param verbose: Log extra debug information.
- :param expansion_file: Configuration file.
- :param evg_api_config: Location of configuration file to connect to evergreen.
- :param selected_tests_config: Location of config file to connect to elected-tests service.
- """
- enable_logging(verbose)
-
- end_date = datetime.utcnow().replace(microsecond=0)
- start_date = end_date - timedelta(days=LOOKBACK_DURATION_DAYS)
-
- evg_expansions = EvgExpansions.from_yaml_file(expansion_file)
-
- def dependencies(binder: inject.Binder) -> None:
- binder.bind(EvgExpansions, evg_expansions)
- binder.bind(EvergreenApi, RetryingEvergreenApi.get_api(config_file=evg_api_config))
- binder.bind(EvergreenProjectConfig, parse_evergreen_file(EVERGREEN_FILE))
- binder.bind(SelectedTestsClient, SelectedTestsClient.from_file(selected_tests_config))
- binder.bind(SuiteSplitConfig, evg_expansions.build_suite_split_config(start_date, end_date))
- binder.bind(SplitStrategy, greedy_division)
- binder.bind(FallbackStrategy, round_robin_fallback)
- binder.bind(GenTaskOptions, evg_expansions.build_gen_task_options())
- binder.bind(GenerationConfiguration, GenerationConfiguration.from_yaml_file())
-
- inject.configure(dependencies)
-
- repos = [Repo(x) for x in DEFAULT_REPO_LOCATIONS if os.path.isdir(x)]
- selected_tests = SelectedTestsOrchestrator() # pylint: disable=no-value-for-parameter
- selected_tests.generate(repos, evg_expansions.task_id)
-
-
-if __name__ == "__main__":
- main() # pylint: disable=no-value-for-parameter
diff --git a/buildscripts/tests/patch_builds/selected_tests/__init__.py b/buildscripts/tests/patch_builds/selected_tests/__init__.py
deleted file mode 100644
index 4b7a2bb941b..00000000000
--- a/buildscripts/tests/patch_builds/selected_tests/__init__.py
+++ /dev/null
@@ -1 +0,0 @@
-"""Empty."""
diff --git a/buildscripts/tests/patch_builds/selected_tests/test_selected_tests_client.py b/buildscripts/tests/patch_builds/selected_tests/test_selected_tests_client.py
deleted file mode 100644
index 974d4cd9e25..00000000000
--- a/buildscripts/tests/patch_builds/selected_tests/test_selected_tests_client.py
+++ /dev/null
@@ -1,87 +0,0 @@
-"""Unit tests for the selected_tests service."""
-import os
-import unittest
-
-from tempfile import TemporaryDirectory
-import requests
-from mock import MagicMock, patch
-
-# pylint: disable=wrong-import-position
-import buildscripts.patch_builds.selected_tests.selected_tests_client as under_test
-
-# pylint: disable=missing-docstring
-
-
-def build_mock_test_mapping(source_file, test_file):
- return under_test.TestMapping(
- branch="branch", project="project", repo="repo", source_file=source_file,
- source_file_seen_count=5, test_files=[
- under_test.TestFileInstance(name=test_file, test_file_seen_count=3),
- ])
-
-
-def build_mock_task_mapping(source_file, task):
- return under_test.TaskMapping(
- branch="branch", project="project", repo="repo", source_file=source_file,
- source_file_seen_count=5, tasks=[
- under_test.TaskMapInstance(name=task, variant="variant", flip_count=3),
- ])
-
-
-class TestSelectedTestsClient(unittest.TestCase):
- def test_from_file_with_valid_file(self):
- with TemporaryDirectory() as tmpdir:
- config_file = os.path.join(tmpdir, "selected_tests_test_config.yml")
- with open(config_file, "w") as fh:
- fh.write("url: url\n")
- fh.write("project: project\n")
- fh.write("auth_user: user\n")
- fh.write("auth_token: token\n")
-
- selected_tests_service = under_test.SelectedTestsClient.from_file(config_file)
-
- self.assertEqual(selected_tests_service.url, "url")
- self.assertEqual(selected_tests_service.project, "project")
- self.assertEqual(selected_tests_service.session.cookies["auth_user"], "user")
- self.assertEqual(selected_tests_service.session.cookies["auth_token"], "token")
-
- def test_from_file_with_invalid_file(self):
- with self.assertRaises(FileNotFoundError):
- under_test.SelectedTestsClient.from_file("")
-
- @patch("requests.Session")
- def test_files_returned_from_selected_tests_service(self, requests_mock):
- changed_files = {"src/file1.cpp", "src/file2.js"}
- response_object = under_test.TestMappingsResponse(test_mappings=[
- build_mock_test_mapping("src/file1.cpp", "jstests/file-1.js"),
- build_mock_test_mapping("src/file2.cpp", "jstests/file-3.js"),
- ])
- requests_mock.return_value.get.return_value.json.return_value = response_object.dict()
-
- related_test_files = under_test.SelectedTestsClient("my-url.com", "my-project", "auth_user",
- "auth_token").get_test_mappings(
- 0.1, changed_files)
-
- self.assertEqual(related_test_files, response_object)
-
- @patch("requests.Session")
- def test_selected_tests_service_unavailable(self, requests_mock):
- changed_files = {"src/file1.cpp", "src/file2.js"}
- response = MagicMock(status_code=requests.codes.SERVICE_UNAVAILABLE)
- requests_mock.return_value.get.side_effect = requests.HTTPError(response=response)
-
- with self.assertRaises(requests.exceptions.HTTPError):
- under_test.SelectedTestsClient("my-url.com", "my-project", "auth_user",
- "auth_token").get_test_mappings(0.1, changed_files)
-
- @patch("requests.Session")
- def test_no_files_returned(self, requests_mock):
- changed_files = {"src/file1.cpp", "src/file2.js"}
- response_object = under_test.TestMappingsResponse(test_mappings=[])
- requests_mock.return_value.get.return_value.json.return_value = response_object.dict()
-
- related_test_files = under_test.SelectedTestsClient("my-url.com", "my-project", "auth_user",
- "auth_token").get_test_mappings(
- 0.1, changed_files)
-
- self.assertEqual(related_test_files, response_object)
diff --git a/buildscripts/tests/patch_builds/selected_tests/test_selected_tests_service.py b/buildscripts/tests/patch_builds/selected_tests/test_selected_tests_service.py
deleted file mode 100644
index a04d2818588..00000000000
--- a/buildscripts/tests/patch_builds/selected_tests/test_selected_tests_service.py
+++ /dev/null
@@ -1,87 +0,0 @@
-"""Unit tests for selected_tests_service.py."""
-import unittest
-from unittest.mock import MagicMock, patch
-
-import buildscripts.patch_builds.selected_tests.selected_tests_service as under_test
-from buildscripts.patch_builds.selected_tests.selected_tests_client import TestMappingsResponse, \
- TestMapping, TestFileInstance, TaskMappingsResponse, TaskMapping, TaskMapInstance
-
-# pylint: disable=missing-docstring,invalid-name,unused-argument,no-self-use,protected-access,no-value-for-parameter
-
-
-def build_mock_test_mapping(source_file, test_file):
- return TestMapping(branch="branch", project="project", repo="repo", source_file=source_file,
- source_file_seen_count=5, test_files=[
- TestFileInstance(name=test_file, test_file_seen_count=3),
- ])
-
-
-def build_mock_task_mapping(source_file, task):
- return TaskMapping(branch="branch", project="project", repo="repo", source_file=source_file,
- source_file_seen_count=5, tasks=[
- TaskMapInstance(name=task, variant="variant", flip_count=3),
- ])
-
-
-class TestFindSelectedTestFiles(unittest.TestCase):
- @patch("os.path.isfile")
- def test_related_files_returned_from_selected_tests_service(self, mock_is_file):
- mock_is_file.return_value = True
- changed_files = {"src/file1.cpp", "src/file2.js"}
- mock_selected_tests_client = MagicMock()
- mock_selected_tests_client.get_test_mappings.return_value = TestMappingsResponse(
- test_mappings=[
- build_mock_test_mapping("src/file1.cpp", "jstests/file-1.js"),
- build_mock_test_mapping("src/file2.cpp", "jstests/file-3.js"),
- ])
- selected_tests = under_test.SelectedTestsService(mock_selected_tests_client)
-
- related_test_files = selected_tests.find_selected_test_files(changed_files)
-
- self.assertEqual(related_test_files, {"jstests/file-1.js", "jstests/file-3.js"})
-
- @patch("os.path.isfile")
- def test_related_files_returned_are_not_valid_test_files(self, mock_is_file):
- mock_is_file.return_value = False
- changed_files = {"src/file1.cpp", "src/file2.js"}
- mock_selected_tests_client = MagicMock()
- mock_selected_tests_client.get_test_mappings.return_value = TestMappingsResponse(
- test_mappings=[
- build_mock_test_mapping("src/file1.cpp", "jstests/file-1.js"),
- build_mock_test_mapping("src/file2.cpp", "jstests/file-3.js"),
- ])
- selected_tests = under_test.SelectedTestsService(mock_selected_tests_client)
-
- related_test_files = selected_tests.find_selected_test_files(changed_files)
-
- self.assertEqual(related_test_files, set())
-
- def test_no_related_files_returned(self):
- changed_files = {"src/file1.cpp", "src/file2.js"}
- mock_selected_tests_client = MagicMock()
- mock_selected_tests_client.get_test_mappings.return_value = TestMappingsResponse(
- test_mappings=[
- build_mock_test_mapping("src/file1.cpp", "jstests/file-1.js"),
- build_mock_test_mapping("src/file2.cpp", "jstests/file-3.js"),
- ])
- selected_tests = under_test.SelectedTestsService(mock_selected_tests_client)
-
- related_test_files = selected_tests.find_selected_test_files(changed_files)
-
- self.assertEqual(related_test_files, set())
-
-
-class TestFindSelectedTasks(unittest.TestCase):
- def test_related_tasks_returned_from_selected_tests_service(self):
- changed_files = {"src/file1.cpp", "src/file2.js"}
- mock_selected_tests_client = MagicMock()
- mock_selected_tests_client.get_task_mappings.return_value = TaskMappingsResponse(
- task_mappings=[
- build_mock_task_mapping("src/file1.cpp", "my_task_1"),
- build_mock_task_mapping("src/file2.cpp", "my_task_2"),
- ])
- selected_tests = under_test.SelectedTestsService(mock_selected_tests_client)
-
- related_tasks = selected_tests.find_selected_tasks(changed_files)
-
- self.assertEqual(related_tasks, {"my_task_1", "my_task_2"})
diff --git a/buildscripts/tests/test_selected_tests.py b/buildscripts/tests/test_selected_tests.py
deleted file mode 100644
index 70689345b69..00000000000
--- a/buildscripts/tests/test_selected_tests.py
+++ /dev/null
@@ -1,412 +0,0 @@
-"""Unit tests for the selected_tests script."""
-import json
-import sys
-import unittest
-from datetime import datetime, timedelta
-from typing import Dict, Any
-
-import inject
-from mock import MagicMock, patch
-from evergreen import EvergreenApi
-
-# pylint: disable=wrong-import-position
-import buildscripts.ciconfig.evergreen as _evergreen
-from buildscripts.burn_in_tests import TaskInfo
-from buildscripts.patch_builds.selected_tests.selected_tests_client import SelectedTestsClient, \
- TestMappingsResponse, TestMapping, TestFileInstance, TaskMappingsResponse, TaskMapInstance, \
- TaskMapping
-from buildscripts.selected_tests import EvgExpansions
-from buildscripts.task_generation.gen_config import GenerationConfiguration
-from buildscripts.task_generation.suite_split import SuiteSplitConfig
-from buildscripts.task_generation.suite_split_strategies import SplitStrategy, greedy_division, \
- FallbackStrategy, round_robin_fallback
-from buildscripts.task_generation.task_types.gentask_options import GenTaskOptions
-from buildscripts.tests.test_burn_in_tests import get_evergreen_config, mock_changed_git_files
-from buildscripts import selected_tests as under_test
-
-# pylint: disable=missing-docstring,invalid-name,unused-argument,protected-access,no-value-for-parameter
-
-NS = "buildscripts.selected_tests"
-
-
-def ns(relative_name): # pylint: disable=invalid-name
- """Return a full name from a name relative to the test module"s name space."""
- return NS + "." + relative_name
-
-
-def empty_build_variant(variant_name: str) -> Dict[str, Any]:
- return {
- "buildvariants": [{
- "name": variant_name,
- "tasks": [],
- }],
- "tasks": [],
- }
-
-
-def configure_dependencies(evg_api, evg_expansions, evg_project_config, selected_test_client):
- start_date = datetime.utcnow()
- end_date = start_date - timedelta(weeks=2)
-
- def dependencies(binder: inject.Binder) -> None:
- binder.bind(EvgExpansions, evg_expansions)
- binder.bind(_evergreen.EvergreenProjectConfig, evg_project_config)
- binder.bind(SuiteSplitConfig, evg_expansions.build_suite_split_config(start_date, end_date))
- binder.bind(SplitStrategy, greedy_division)
- binder.bind(FallbackStrategy, round_robin_fallback)
- binder.bind(GenTaskOptions, evg_expansions.build_gen_task_options())
- binder.bind(EvergreenApi, evg_api)
- binder.bind(GenerationConfiguration, GenerationConfiguration.from_yaml_file())
- binder.bind(SelectedTestsClient, selected_test_client)
-
- inject.clear_and_configure(dependencies)
-
-
-class TestAcceptance(unittest.TestCase):
- """A suite of Acceptance tests for selected_tests."""
-
- @staticmethod
- def _mock_evg_api():
- evg_api_mock = MagicMock()
- task_mock = evg_api_mock.task_by_id.return_value
- task_mock.execution = 0
- return evg_api_mock
-
- @unittest.skipIf(sys.platform.startswith("win"), "not supported on windows")
- def test_when_no_mappings_are_found_for_changed_files(self):
- mock_evg_api = self._mock_evg_api()
- mock_evg_config = get_evergreen_config("etc/evergreen.yml")
- mock_evg_expansions = under_test.EvgExpansions(
- task_id="task_id",
- task_name="selected_tests_gen",
- build_variant="selected-tests",
- build_id="my_build_id",
- project="mongodb-mongo-master",
- revision="abc123",
- version_id="my_version",
- )
- mock_selected_tests_client = MagicMock()
- mock_selected_tests_client.get_test_mappings.return_value = TestMappingsResponse(
- test_mappings=[])
- configure_dependencies(mock_evg_api, mock_evg_expansions, mock_evg_config,
- mock_selected_tests_client)
- repos = [mock_changed_git_files([])]
-
- selected_tests = under_test.SelectedTestsOrchestrator()
- changed_files = selected_tests.find_changed_files(repos, "task_id")
- generated_config = selected_tests.generate_version(changed_files)
-
- # assert that config_dict does not contain keys for any generated task configs
- self.assertEqual(len(generated_config.file_list), 1)
- self.assertEqual(generated_config.file_list[0].file_name, "selected_tests_config.json")
-
- @unittest.skipIf(sys.platform.startswith("win"), "not supported on windows")
- def test_when_test_mappings_are_found_for_changed_files(self):
- mock_evg_api = self._mock_evg_api()
- mock_evg_config = get_evergreen_config("etc/evergreen.yml")
- mock_evg_expansions = under_test.EvgExpansions(
- task_id="task_id",
- task_name="selected_tests_gen",
- build_variant="selected-tests",
- build_id="my_build_id",
- project="mongodb-mongo-master",
- revision="abc123",
- version_id="my_version",
- )
- mock_test_mapping = TestMapping(
- branch="master", project="mongodb-mongo-master", repo="mongodb/mongo",
- source_file="src/file1.cpp", source_file_seen_count=8,
- test_files=[TestFileInstance(name="jstests/auth/auth1.js", test_file_seen_count=3)])
- mock_selected_tests_client = MagicMock()
- mock_selected_tests_client.get_test_mappings.return_value = TestMappingsResponse(
- test_mappings=[mock_test_mapping])
- configure_dependencies(mock_evg_api, mock_evg_expansions, mock_evg_config,
- mock_selected_tests_client)
- repos = [mock_changed_git_files(["src/file1.cpp"])]
-
- selected_tests = under_test.SelectedTestsOrchestrator()
- changed_files = selected_tests.find_changed_files(repos, "task_id")
- generated_config = selected_tests.generate_version(changed_files)
-
- files_to_generate = {gen_file.file_name for gen_file in generated_config.file_list}
- self.assertIn("selected_tests_config.json", files_to_generate)
-
- # assert that generated suite files have the suite name and the variant name in the
- # filename, to prevent tasks on different variants from using the same suite file
- self.assertIn("auth_enterprise-rhel-80-64-bit-dynamic-required_0.yml", files_to_generate)
-
- generated_evg_config_raw = [
- gen_file.content for gen_file in generated_config.file_list
- if gen_file.file_name == "selected_tests_config.json"
- ][0]
-
- generated_evg_config = json.loads(generated_evg_config_raw)
- build_variants_with_generated_tasks = generated_evg_config["buildvariants"]
- # jstests/auth/auth1.js belongs to two suites, auth and auth_audit,
- rhel_80_with_generated_tasks = next(
- (variant for variant in build_variants_with_generated_tasks
- if variant["name"] == "enterprise-rhel-80-64-bit-dynamic-required"), None)
- self.assertEqual(len(rhel_80_with_generated_tasks["tasks"]), 2)
-
- @unittest.skipIf(sys.platform.startswith("win"), "not supported on windows")
- def test_when_task_mappings_are_found_for_changed_files(self):
- mock_evg_api = self._mock_evg_api()
- mock_evg_config = get_evergreen_config("etc/evergreen.yml")
- mock_evg_expansions = under_test.EvgExpansions(
- task_id="task_id",
- task_name="selected_tests_gen",
- build_variant="selected-tests",
- build_id="my_build_id",
- project="mongodb-mongo-master",
- revision="abc123",
- version_id="my_version",
- )
- mock_task_mapping = TaskMapping(
- branch="master", project="mongodb-mongo-master", repo="mongodb/mongo",
- source_file="src/file1.cpp", source_file_seen_count=8,
- tasks=[TaskMapInstance(name="auth", variant="enterprise-rhel-80", flip_count=5)])
- mock_selected_tests_client = MagicMock()
- mock_selected_tests_client.get_task_mappings.return_value = TaskMappingsResponse(
- task_mappings=[mock_task_mapping])
- configure_dependencies(mock_evg_api, mock_evg_expansions, mock_evg_config,
- mock_selected_tests_client)
- repos = [mock_changed_git_files(["src/file1.cpp"])]
-
- selected_tests = under_test.SelectedTestsOrchestrator()
- changed_files = selected_tests.find_changed_files(repos, "task_id")
- generated_config = selected_tests.generate_version(changed_files)
-
- files_to_generate = {gen_file.file_name for gen_file in generated_config.file_list}
- self.assertIn("selected_tests_config.json", files_to_generate)
-
- generated_evg_config_raw = [
- gen_file.content for gen_file in generated_config.file_list
- if gen_file.file_name == "selected_tests_config.json"
- ][0]
- generated_evg_config = json.loads(generated_evg_config_raw)
- # the auth task's generator task, max_sub_suites is 3,
- # resulting in 3 subtasks being generated, plus a _misc task, hence 4
- # tasks total
- build_variants_with_generated_tasks = generated_evg_config["buildvariants"]
- rhel_80_with_generated_tasks = next(
- (variant for variant in build_variants_with_generated_tasks
- if variant["name"] == "enterprise-rhel-80-64-bit-dynamic-required"), None)
- self.assertEqual(len(rhel_80_with_generated_tasks["tasks"]), 5)
-
-
-class TestExcludeTask(unittest.TestCase):
- def test_task_should_not_be_excluded(self):
- task = _evergreen.Task({"name": "regular_task"})
-
- self.assertEqual(under_test._exclude_task(task), False)
-
- def test_task_should_be_excluded(self):
- excluded_task = under_test.EXCLUDE_TASK_LIST[0]
- task = _evergreen.Task({"name": excluded_task})
-
- self.assertEqual(under_test._exclude_task(task), True)
-
- def test_task_matches_excluded_pattern(self):
- task_that_matches_exclude_pattern = "compile_all"
- task = _evergreen.Task({"name": task_that_matches_exclude_pattern})
-
- self.assertEqual(under_test._exclude_task(task), True)
-
-
-def build_mock_evg_task(name, cmd_func="generate resmoke tasks",
- resmoke_args="--storageEngine=wiredTiger"):
- return _evergreen.Task({
- "name": name,
- "commands": [{
- "func": cmd_func,
- "vars": {"resmoke_args": resmoke_args, },
- }],
- })
-
-
-class TestGetEvgTaskConfig(unittest.TestCase):
- def test_task_is_a_generate_resmoke_task(self):
- build_variant_conf = MagicMock()
- build_variant_conf.name = "variant"
- task = build_mock_evg_task("auth_gen")
-
- task_config_service = under_test.TaskConfigService()
- evg_task_config = task_config_service.get_evg_task_config(task, build_variant_conf)
-
- self.assertEqual(evg_task_config["task_name"], "auth")
- self.assertEqual(evg_task_config["build_variant"], "variant")
- self.assertEqual(evg_task_config.get("suite"), "auth")
- self.assertEqual(
- evg_task_config["resmoke_args"],
- "--storageEngine=wiredTiger",
- )
-
- def test_task_is_not_a_generate_resmoke_task(self):
- build_variant_conf = MagicMock()
- build_variant_conf.name = "variant"
- task = build_mock_evg_task("jsCore_auth", "run tests", "--storageEngine=wiredTiger")
-
- task_config_service = under_test.TaskConfigService()
- evg_task_config = task_config_service.get_evg_task_config(task, build_variant_conf)
-
- self.assertEqual(evg_task_config["task_name"], "jsCore_auth")
- self.assertEqual(evg_task_config["build_variant"], "variant")
- self.assertEqual(evg_task_config["suite"], "jsCore_auth")
- self.assertEqual(
- evg_task_config["resmoke_args"],
- "--storageEngine=wiredTiger",
- )
-
-
-class TestGetTaskConfigsForTestMappings(unittest.TestCase):
- @patch(ns("_exclude_task"))
- @patch(ns("_find_task"))
- def test_get_config_for_test_mapping(self, find_task_mock, exclude_task_mock):
- find_task_mock.side_effect = [
- build_mock_evg_task("jsCore_auth", "run tests"),
- build_mock_evg_task("auth_gen", "run tests",
- "--suites=core_auth --storageEngine=wiredTiger"),
- ]
- exclude_task_mock.return_value = False
- tests_by_task = {
- "jsCore_auth":
- TaskInfo(
- display_task_name="task 1",
- tests=[
- "jstests/core/currentop_waiting_for_latch.js",
- "jstests/core/latch_analyzer.js",
- ],
- resmoke_args="",
- require_multiversion_setup=False,
- distro="",
- suite="core_auth",
- build_variant="dummy_variant",
- ),
- "auth_gen":
- TaskInfo(
- display_task_name="task 2",
- tests=["jstests/auth/auth3.js"],
- resmoke_args="",
- require_multiversion_setup=False,
- distro="",
- suite="auth",
- build_variant="dummy_variant",
- ),
- }
-
- task_config_service = under_test.TaskConfigService()
- task_configs = task_config_service.get_task_configs_for_test_mappings(
- tests_by_task, MagicMock())
-
- self.assertEqual(task_configs["jsCore_auth"]["resmoke_args"], "--storageEngine=wiredTiger")
- self.assertEqual(
- task_configs["jsCore_auth"]["selected_tests_to_run"],
- {"jstests/core/currentop_waiting_for_latch.js", "jstests/core/latch_analyzer.js"})
- self.assertEqual(task_configs["auth_gen"]["suite"], "auth_gen")
- self.assertEqual(task_configs["auth_gen"]["selected_tests_to_run"],
- {'jstests/auth/auth3.js'})
-
- @patch(ns("_exclude_task"))
- @patch(ns("_find_task"))
- def test_get_config_for_test_mapping_when_task_should_be_excluded(self, find_task_mock,
- exclude_task_mock):
- find_task_mock.return_value = build_mock_evg_task(
- "jsCore_auth", "run tests", "--suites=core_auth --storageEngine=wiredTiger")
- exclude_task_mock.return_value = True
- tests_by_task = {
- "jsCore_auth":
- TaskInfo(
- display_task_name="task 1",
- tests=[
- "jstests/core/currentop_waiting_for_latch.js",
- "jstests/core/latch_analyzer.js",
- ],
- resmoke_args="",
- require_multiversion_setup=False,
- distro="",
- suite="core",
- build_variant="dummy_variant",
- ),
- }
-
- task_config_service = under_test.TaskConfigService()
- task_configs = task_config_service.get_task_configs_for_test_mappings(
- tests_by_task, MagicMock())
-
- self.assertEqual(task_configs, {})
-
- @patch(ns("_find_task"))
- def test_get_config_for_test_mapping_when_task_does_not_exist(self, find_task_mock):
- find_task_mock.return_value = None
- tests_by_task = {
- "jsCore_auth":
- TaskInfo(
- display_task_name="task 1",
- tests=[
- "jstests/core/currentop_waiting_for_latch.js",
- "jstests/core/latch_analyzer.js",
- ],
- resmoke_args="",
- require_multiversion_setup=False,
- distro="",
- suite="core",
- build_variant="dummy_variant",
- ),
- }
-
- task_config_service = under_test.TaskConfigService()
- task_configs = task_config_service.get_task_configs_for_test_mappings(
- tests_by_task, MagicMock())
-
- self.assertEqual(task_configs, {})
-
-
-class TestGetTaskConfigsForTaskMappings(unittest.TestCase):
- @patch(ns("_exclude_task"))
- @patch(ns("_find_task"))
- def test_get_config_for_task_mapping(self, find_task_mock, exclude_task_mock):
- find_task_mock.side_effect = [build_mock_evg_task("task_1"), build_mock_evg_task("task_2")]
- exclude_task_mock.return_value = False
- tasks = ["task_1", "task_2"]
-
- task_config_service = under_test.TaskConfigService()
- task_configs = task_config_service.get_task_configs_for_task_mappings(tasks, MagicMock())
-
- self.assertEqual(task_configs["task_1"]["resmoke_args"], "--storageEngine=wiredTiger")
- self.assertEqual(task_configs["task_2"]["resmoke_args"], "--storageEngine=wiredTiger")
-
- @patch(ns("_exclude_task"))
- @patch(ns("_find_task"))
- def test_get_config_for_task_mapping_when_task_should_be_excluded(self, find_task_mock,
- exclude_task_mock):
- find_task_mock.return_value = build_mock_evg_task("task_1")
- exclude_task_mock.return_value = True
- tasks = ["task_1"]
-
- task_config_service = under_test.TaskConfigService()
- task_configs = task_config_service.get_task_configs_for_task_mappings(tasks, MagicMock())
-
- self.assertEqual(task_configs, {})
-
- @patch(ns("_find_task"))
- def test_get_config_for_task_mapping_when_task_does_not_exist(self, find_task_mock):
- find_task_mock.return_value = None
- tasks = ["task_1"]
-
- task_config_service = under_test.TaskConfigService()
- task_configs = task_config_service.get_task_configs_for_task_mappings(tasks, MagicMock())
-
- self.assertEqual(task_configs, {})
-
-
-class TestRemoveRepoPathPrefix(unittest.TestCase):
- def test_file_is_in_enterprise_modules(self):
- filepath = under_test._remove_repo_path_prefix(
- "src/mongo/db/modules/enterprise/src/file1.cpp")
-
- self.assertEqual(filepath, "src/file1.cpp")
-
- def test_file_is_not_in_enterprise_modules(self):
- filepath = under_test._remove_repo_path_prefix("other_directory/src/file1.cpp")
-
- self.assertEqual(filepath, "other_directory/src/file1.cpp")
diff --git a/etc/evergreen.yml b/etc/evergreen.yml
index 72e4ae257d6..792439def0f 100644
--- a/etc/evergreen.yml
+++ b/etc/evergreen.yml
@@ -2978,19 +2978,6 @@ buildvariants:
tasks:
- name: win_shared_scons_cache_pruning
-- name: selected-tests
- display_name: "~ Selected Tests"
- modules:
- - enterprise
- run_on:
- - rhel80-small
- cron: "0 4 * * 0" # From the ${project_weekly_cron} parameter
- stepback: false
- expansions:
- selected_tests_buildvariants: enterprise-windows-required linux-64-debug-required enterprise-ubuntu-dynamic-1604-clang rhel80-debug-aubsan-lite-required
- tasks:
- - name: selected_tests_gen
-
- <<: *enterprise-rhel-80-64-bit-dynamic-required-template
name: commit-queue
display_name: "~ Commit Queue"
diff --git a/etc/evergreen_yml_components/definitions.yml b/etc/evergreen_yml_components/definitions.yml
index 1426dad0cb9..8dadad95eb0 100644
--- a/etc/evergreen_yml_components/definitions.yml
+++ b/etc/evergreen_yml_components/definitions.yml
@@ -400,19 +400,6 @@ functions:
args:
- "src/evergreen/functions/evergreen_api_credentials_configure.sh"
- "configure selected tests credentials": &configure_selected_tests_credentials
- command: subprocess.exec
- type: test
- params:
- binary: bash
- silent: true
- args:
- - "src/evergreen/functions/selected_tests_credentials_configure.sh"
- env:
- project: ${project}
- selected_tests_auth_user: ${selected_tests_auth_user}
- selected_tests_auth_token: ${selected_tests_auth_token}
-
"git get project": &git_get_project
command: git.get_project
params:
@@ -995,40 +982,6 @@ functions:
args:
- "./src/evergreen/jstestfuzz_minimize.sh"
- "generate selected tests":
- - *f_expansions_write
- - *configure_evergreen_api_credentials
- - *configure_selected_tests_credentials
- - command: subprocess.exec
- type: test
- params:
- binary: bash
- args:
- - "./src/evergreen/selected_tests_generate.sh"
- - *f_expansions_write
- - command: archive.targz_pack
- params:
- target: generate_tasks_config.tgz
- source_dir: src/generated_resmoke_config
- include:
- - "*"
- - command: s3.put
- params:
- aws_key: ${aws_key}
- aws_secret: ${aws_secret}
- local_file: generate_tasks_config.tgz
- remote_file: ${project}/${revision}/generate_tasks/generated-config-${version_id}.tgz
- bucket: mciuploads
- permissions: public-read
- content_type: ${content_type|application/gzip}
- display_name: Generated Task Config - Execution ${execution}
- optional: true
- - command: generate.tasks
- params:
- optional: true
- files:
- - src/generated_resmoke_config/*.json
-
"generate version":
- *f_expansions_write
- *configure_evergreen_api_credentials
@@ -4222,18 +4175,6 @@ tasks:
- func: "upload pip requirements"
- func: "generate version"
-- name: selected_tests_gen
- tags: []
- commands:
- - command: manifest.load
- - func: "git get project and add git tag"
- - *f_expansions_write
- - *kill_processes
- - *cleanup_environment
- - func: "set up venv"
- - func: "upload pip requirements"
- - func: "generate selected tests"
-
- <<: *gen_task_template
name: auth_audit_gen
tags: ["auth", "audit"]
diff --git a/evergreen/functions/selected_tests_credentials_configure.sh b/evergreen/functions/selected_tests_credentials_configure.sh
deleted file mode 100755
index 253880c2c85..00000000000
--- a/evergreen/functions/selected_tests_credentials_configure.sh
+++ /dev/null
@@ -1,12 +0,0 @@
-DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" > /dev/null 2>&1 && pwd)"
-. "$DIR/../prelude.sh"
-
-cd src
-
-# Create the Evergreen API credentials
-cat > .selected_tests.yml << END_OF_CREDS
-url: "https://selected-tests.server-tig.prod.corp.mongodb.com"
-project: "${project}"
-auth_user: "${selected_tests_auth_user}"
-auth_token: "${selected_tests_auth_token}"
-END_OF_CREDS
diff --git a/evergreen/selected_tests_generate.sh b/evergreen/selected_tests_generate.sh
deleted file mode 100644
index ba268b1d5d2..00000000000
--- a/evergreen/selected_tests_generate.sh
+++ /dev/null
@@ -1,13 +0,0 @@
-DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" > /dev/null 2>&1 && pwd)"
-. "$DIR/prelude.sh"
-
-cd src
-
-set -o errexit
-set -o verbose
-
-# Only run on master branch
-if [ "${project}" == "mongodb-mongo-master" -a "${is_patch}" == "true" ]; then
- activate_venv
- PATH=$PATH:$HOME $python buildscripts/selected_tests.py --expansion-file ../expansions.yml --selected-tests-config .selected_tests.yml
-fi