diff options
author | XueruiFa <xuerui.fa@mongodb.com> | 2021-09-02 15:22:22 +0000 |
---|---|---|
committer | Evergreen Agent <no-reply@evergreen.mongodb.com> | 2021-09-02 18:19:48 +0000 |
commit | 9ed67ce0823d4b7fc5051831125e50f7f9cebb2b (patch) | |
tree | 233f2707832b0cc8be1c7ba8ac5469575082782f /buildscripts | |
parent | c4d2ed3292b0e113135dd85185c27a8235ea1814 (diff) | |
download | mongo-9ed67ce0823d4b7fc5051831125e50f7f9cebb2b.tar.gz |
SERVER-59012: Revert calculating FCV constants in resmoke
Diffstat (limited to 'buildscripts')
16 files changed, 59 insertions, 262 deletions
diff --git a/buildscripts/resmokeconfig/setup_multiversion/setup_multiversion_config.yml b/buildscripts/resmokeconfig/setup_multiversion/setup_multiversion_config.yml index 59ab80667f3..90232faa64a 100644 --- a/buildscripts/resmokeconfig/setup_multiversion/setup_multiversion_config.yml +++ b/buildscripts/resmokeconfig/setup_multiversion/setup_multiversion_config.yml @@ -4,6 +4,15 @@ # # PLEASE DO NOT REMOVE ANYTHING, unless a build variant no longer runs in any Evergreen project. + +evergreen_projects: + - mongodb-mongo-master + - mongodb-mongo-v5.0 + - mongodb-mongo-v4.4 + - mongodb-mongo-v4.2 + - mongodb-mongo-v4.0 + + evergreen_buildvariants: - name: ubuntu1604 edition: targeted diff --git a/buildscripts/resmokeconfig/suites/replica_sets_multiversion.yml b/buildscripts/resmokeconfig/suites/replica_sets_multiversion.yml index e587fa8107a..e0f94ecd936 100644 --- a/buildscripts/resmokeconfig/suites/replica_sets_multiversion.yml +++ b/buildscripts/resmokeconfig/suites/replica_sets_multiversion.yml @@ -5,8 +5,6 @@ selector: - jstests/replsets/*.js exclude_with_any_tags: - multiversion_incompatible - # TODO (SERVER-55857): Remove this hardcoded tag once tests are filtered out using the - # 'REQUIRES_FCV_TAG' list in 'multiversion_constants.py'. - requires_fcv_51 - backport_required_multiversion - replica_sets_multiversion_backport_required_multiversion diff --git a/buildscripts/resmokeconfig/suites/sharding_last_lts_mongos_and_mixed_shards.yml b/buildscripts/resmokeconfig/suites/sharding_last_lts_mongos_and_mixed_shards.yml index a09d1af5a97..d574e323de5 100644 --- a/buildscripts/resmokeconfig/suites/sharding_last_lts_mongos_and_mixed_shards.yml +++ b/buildscripts/resmokeconfig/suites/sharding_last_lts_mongos_and_mixed_shards.yml @@ -10,8 +10,6 @@ selector: # - jstests/sharding/change_streams/*.js # exclude_with_any_tags: # - multiversion_incompatible -# TODO (SERVER-55857): Remove this hardcoded tag once tests are filtered out using the -# 'REQUIRES_FCV_TAG' list in 'multiversion_constants.py'. # - requires_fcv_47 # - requires_fcv_48 # - requires_fcv_49 diff --git a/buildscripts/resmokeconfig/suites/sharding_multiversion.yml b/buildscripts/resmokeconfig/suites/sharding_multiversion.yml index 0ab1b77d1e8..24aaa47e96c 100644 --- a/buildscripts/resmokeconfig/suites/sharding_multiversion.yml +++ b/buildscripts/resmokeconfig/suites/sharding_multiversion.yml @@ -7,8 +7,6 @@ selector: - jstests/sharding/query/*.js exclude_with_any_tags: - multiversion_incompatible - # TODO (SERVER-55857): Remove this hardcoded tag once tests are filtered out using the - # 'REQUIRES_FCV_TAG' list in 'multiversion_constants.py'. - requires_fcv_51 - backport_required_multiversion - replica_sets_multiversion_backport_required_multiversion diff --git a/buildscripts/resmokelib/__init__.py b/buildscripts/resmokelib/__init__.py index a4d8ac6df6e..d96348ee2e8 100644 --- a/buildscripts/resmokelib/__init__.py +++ b/buildscripts/resmokelib/__init__.py @@ -3,6 +3,7 @@ from buildscripts.resmokelib import config from buildscripts.resmokelib import errors from buildscripts.resmokelib import logging +from buildscripts.resmokelib import multiversionconstants from buildscripts.resmokelib import parser from buildscripts.resmokelib import reportfile from buildscripts.resmokelib import sighandler diff --git a/buildscripts/resmokelib/generate_fcv_constants/__init__.py b/buildscripts/resmokelib/generate_fcv_constants/__init__.py deleted file mode 100644 index fab4be5abd9..00000000000 --- a/buildscripts/resmokelib/generate_fcv_constants/__init__.py +++ /dev/null @@ -1,52 +0,0 @@ -"""Generate FCV constants for consumption by non-C++ integration tests.""" -import argparse - -from buildscripts.resmokelib.plugin import PluginInterface, Subcommand - -_COMMAND = "generate-fcv-constants" - - -class GenerateFCVConstants(Subcommand): - """Interact with generating FCV constants.""" - - def __init__(self): - """Constructor.""" - - def execute(self) -> None: - """ - Work your magic. - - :return: None - """ - # This will cause multiversion constants to be generated. - import buildscripts.resmokelib.multiversionconstants # pylint: disable=unused-import - pass - - -class GenerateFCVConstantsPlugin(PluginInterface): - """Interact with generating FCV constants.""" - - def add_subcommand(self, subparsers): - """ - Add 'generate-fcv-constants' subcommand. - - :param subparsers: argparse parser to add to - :return: None - """ - # Can't hide this subcommand due to a Python bug. https://bugs.python.org/issue22848. - subparsers.add_parser(_COMMAND, help=argparse.SUPPRESS) - - def parse(self, subcommand, parser, parsed_args, **kwargs): - """ - Return the FCV constants subcommand for execution. - - :param subcommand: equivalent to parsed_args.command - :param parser: parser used - :param parsed_args: output of parsing - :param kwargs: additional args - :return: None or a Subcommand - """ - if subcommand != _COMMAND: - return None - - return GenerateFCVConstants() diff --git a/buildscripts/resmokelib/multiversionconstants.py b/buildscripts/resmokelib/multiversionconstants.py index 456eae65036..bc440209727 100644 --- a/buildscripts/resmokelib/multiversionconstants.py +++ b/buildscripts/resmokelib/multiversionconstants.py @@ -1,140 +1,10 @@ """FCV and Server binary version constants used for multiversion testing.""" +LAST_LTS_BIN_VERSION = "5.0" +LAST_CONTINUOUS_BIN_VERSION = "5.0" -from bisect import bisect_left, bisect_right -import os -import re -import shutil -from subprocess import call, CalledProcessError, check_output, STDOUT -import structlog -import yaml - -from packaging.version import Version - -LOGGER = structlog.getLogger(__name__) - -# These values must match the include paths for artifacts.tgz in evergreen.yml. -MONGO_VERSION_YAML = ".resmoke_mongo_version.yml" -RELEASES_YAML = ".resmoke_mongo_release_values.yml" - - -def generate_data_files(): - """Generate the yaml files. Should only be called if the git repo is installed.""" - # Copy the 'releases.yml' file from the source tree. - releases_yaml_path = os.path.join("src", "mongo", "util", "version", "releases.yml") - if not os.path.isfile(releases_yaml_path): - LOGGER.warning( - 'Expected file .resmoke_mongo_release_values.yml does not exist at path {}'.format( - releases_yaml_path)) - shutil.copyfile(releases_yaml_path, RELEASES_YAML) - - try: - res = check_output("git describe", shell=True, text=True) - except CalledProcessError as exp: - raise ChildProcessError("Failed to run git describe to get the latest tag") from exp - - # Write the current MONGO_VERSION to a data file. - with open(MONGO_VERSION_YAML, 'w') as mongo_version_fh: - # E.g. res = 'r5.1.0-alpha-597-g8c345c6693\n' - res = res[1:] # Remove the leading "r" character. - mongo_version_fh.write("mongo_version: " + res) - - -def in_git_root_dir(): - """Return True if we are in the root of a git directory.""" - if call(["git", "branch"], stderr=STDOUT, stdout=open(os.devnull, 'w')) != 0: - # We are not in a git directory. - return False - - git_root_dir = check_output("git rev-parse --show-toplevel", shell=True, text=True).strip() - # Always use forward slash for the cwd path to resolve inconsistent formatting with Windows. - curr_dir = os.getcwd().replace("\\", "/") - return git_root_dir == curr_dir - - -if in_git_root_dir(): - generate_data_files() -else: - LOGGER.info("Skipping generating version constants since we're not in the root of a git repo") - - -class FCVConstantValues(object): - """Object to hold the calculated FCV constants.""" - - def __init__(self, latest, last_continuous, last_lts, requires_fcv_tag_list, - fcvs_less_than_latest): - """ - Initialize the object. - - :param latest: Latest FCV. - :param last_continuous: Last continuous FCV. - :param last_lts: Last LTS FCV. - :param requires_fcv_tag_list: List of FCVs that we need to generate a tag for. - :param fcvs_less_than_latest: List of all FCVs that are less than latest, starting from v4.0. - """ - self.latest = latest - self.last_continuous = last_continuous - self.last_lts = last_lts - self.requires_fcv_tag_list = requires_fcv_tag_list - self.fcvs_less_than_latest = fcvs_less_than_latest - - -def calculate_fcv_constants(): - """Calculate multiversion constants from data files.""" - mongo_version_yml_file = open(MONGO_VERSION_YAML, 'r') - mongo_version_yml = yaml.safe_load(mongo_version_yml_file) - mongo_version = mongo_version_yml['mongo_version'] - latest = Version(re.match(r'^[0-9]+\.[0-9]+', mongo_version).group(0)) - - releases_yml_file = open(RELEASES_YAML, 'r') - releases_yml = yaml.safe_load(releases_yml_file) - - mongo_version_yml_file.close() - releases_yml_file.close() - - fcvs = releases_yml['featureCompatibilityVersions'] - fcvs = list(map(Version, fcvs)) - lts = releases_yml['longTermSupportReleases'] - lts = list(map(Version, lts)) - - # Highest release less than latest. - last_continuous = fcvs[bisect_left(fcvs, latest) - 1] - - # Highest LTS release less than latest. - last_lts = lts[bisect_left(lts, latest) - 1] - - # All FCVs greater than last LTS, up to latest. - requires_fcv_tag_list = fcvs[bisect_right(fcvs, last_lts):bisect_right(fcvs, latest)] - - # All FCVs less than latest. - fcvs_less_than_latest = fcvs[:bisect_left(fcvs, latest)] - - return FCVConstantValues(latest, last_continuous, last_lts, requires_fcv_tag_list, - fcvs_less_than_latest) - - -def version_str(version): - """Return a string of the given version in 'MAJOR.MINOR' form.""" - return '{}.{}'.format(version.major, version.minor) - - -def tag_str(version): - """Return a tag for the given version.""" - return 'requires_fcv_{}{}'.format(version.major, version.minor) - - -def evg_project_str(version): - """Return the evergreen project name for the given version.""" - return 'mongodb-mongo-v{}.{}'.format(version.major, version.minor) - - -fcv_constants = calculate_fcv_constants() - -LAST_LTS_BIN_VERSION = version_str(fcv_constants.last_lts) -LAST_CONTINUOUS_BIN_VERSION = version_str(fcv_constants.last_continuous) - -LAST_LTS_FCV = version_str(fcv_constants.last_lts) -LAST_CONTINUOUS_FCV = version_str(fcv_constants.last_continuous) -LATEST_FCV = version_str(fcv_constants.latest) +LAST_LTS_FCV = "5.0" +LAST_CONTINUOUS_FCV = "5.0" +LATEST_FCV = "5.1" LAST_CONTINUOUS_MONGO_BINARY = "mongo-" + LAST_CONTINUOUS_BIN_VERSION LAST_CONTINUOUS_MONGOD_BINARY = "mongod-" + LAST_CONTINUOUS_BIN_VERSION @@ -144,12 +14,7 @@ LAST_LTS_MONGO_BINARY = "mongo-" + LAST_LTS_BIN_VERSION LAST_LTS_MONGOD_BINARY = "mongod-" + LAST_LTS_BIN_VERSION LAST_LTS_MONGOS_BINARY = "mongos-" + LAST_LTS_BIN_VERSION -REQUIRES_FCV_TAG_LATEST = tag_str(fcv_constants.latest) - -# Generate tags for all FCVS in (lastLTS, latest]. -# All multiversion tests should be run with these tags excluded. -REQUIRES_FCV_TAG = [tag_str(fcv) for fcv in fcv_constants.requires_fcv_tag_list] +REQUIRES_FCV_TAG_LATEST = "requires_fcv_51" -# Generate evergreen project names for all FCVs less than latest. -EVERGREEN_PROJECTS = ['mongodb-mongo-master'] -EVERGREEN_PROJECTS.extend([evg_project_str(fcv) for fcv in fcv_constants.fcvs_less_than_latest]) +# TODO: rename this to REQUIRES_FCV_TAGS (plural) when `requires_fcv_52` is added to it. +REQUIRES_FCV_TAG = REQUIRES_FCV_TAG_LATEST diff --git a/buildscripts/resmokelib/parser.py b/buildscripts/resmokelib/parser.py index 9442634edca..433152a8bcd 100644 --- a/buildscripts/resmokelib/parser.py +++ b/buildscripts/resmokelib/parser.py @@ -4,7 +4,6 @@ import argparse import shlex from buildscripts.resmokelib import configure_resmoke -from buildscripts.resmokelib.generate_fcv_constants import GenerateFCVConstantsPlugin from buildscripts.resmokelib.hang_analyzer import HangAnalyzerPlugin from buildscripts.resmokelib.powercycle import PowercyclePlugin from buildscripts.resmokelib.run import RunPlugin @@ -21,7 +20,6 @@ _PLUGINS = [ PowercyclePlugin(), SymbolizerPlugin(), BisectPlugin(), - GenerateFCVConstantsPlugin(), ] diff --git a/buildscripts/resmokelib/run/generate_multiversion_exclude_tags.py b/buildscripts/resmokelib/run/generate_multiversion_exclude_tags.py index 54c0a0ea3d8..b26159e3b65 100755 --- a/buildscripts/resmokelib/run/generate_multiversion_exclude_tags.py +++ b/buildscripts/resmokelib/run/generate_multiversion_exclude_tags.py @@ -9,6 +9,7 @@ from subprocess import check_output import requests from buildscripts.ciconfig import tags as _tags +from buildscripts.resmokelib import multiversionconstants from buildscripts.resmokelib.config import MultiversionOptions from buildscripts.resmokelib.core.programs import get_path_env_var from buildscripts.resmokelib.utils import is_windows @@ -87,8 +88,6 @@ def generate_exclude_yaml(old_bin_version: str, output: str, logger: logging.Log # Get the state of the backports_required_for_multiversion_tests.yml file for the old # binary we are running tests against. We do this by using the commit hash from the old # mongo shell executable. - from buildscripts.resmokelib import multiversionconstants - shell_version = { MultiversionOptions.LAST_LTS: multiversionconstants.LAST_LTS_MONGO_BINARY, MultiversionOptions.LAST_CONTINUOUS: multiversionconstants.LAST_CONTINUOUS_MONGO_BINARY, diff --git a/buildscripts/resmokelib/setup_multiversion/setup_multiversion.py b/buildscripts/resmokelib/setup_multiversion/setup_multiversion.py index 9e85258888a..c3e531773f5 100644 --- a/buildscripts/resmokelib/setup_multiversion/setup_multiversion.py +++ b/buildscripts/resmokelib/setup_multiversion/setup_multiversion.py @@ -5,7 +5,6 @@ to include its version) into an install directory and symlinks the binaries with versions to another directory. This script supports community and enterprise builds. """ -from itertools import chain import logging import os import re @@ -17,8 +16,6 @@ from typing import Optional, Dict, Any import structlog import yaml -from requests.exceptions import HTTPError - from buildscripts.resmokelib.plugin import PluginInterface, Subcommand from buildscripts.resmokelib.setup_multiversion import config, download, github_conn from buildscripts.resmokelib.utils import evergreen_conn, is_windows @@ -64,8 +61,8 @@ class SetupMultiversion(Subcommand): # pylint: disable=too-many-instance-attributes def __init__(self, download_options, install_dir="", link_dir="", mv_platform=None, edition=None, architecture=None, use_latest=None, versions=None, - install_last_lts=None, install_last_continuous=None, evergreen_config=None, - github_oauth_token=None, debug=None, ignore_failed_push=False): + evergreen_config=None, github_oauth_token=None, debug=None, + ignore_failed_push=False): """Initialize.""" setup_logging(debug) self.install_dir = os.path.abspath(install_dir) @@ -76,8 +73,6 @@ class SetupMultiversion(Subcommand): self.architecture = architecture.lower() if architecture else None self.use_latest = use_latest self.versions = versions - self.install_last_lts = install_last_lts - self.install_last_continuous = install_last_continuous self.ignore_failed_push = ignore_failed_push self.download_binaries = download_options.download_binaries @@ -112,13 +107,6 @@ class SetupMultiversion(Subcommand): def execute(self): """Execute setup multiversion mongodb.""" - from buildscripts.resmokelib import multiversionconstants - - if self.install_last_lts: - self.versions.append(multiversionconstants.LAST_LTS_FCV) - if self.install_last_continuous: - self.versions.append(multiversionconstants.LAST_CONTINUOUS_FCV) - self.versions = list(set(self.versions)) for version in self.versions: LOGGER.info("Setting up version.", version=version) @@ -199,28 +187,25 @@ class SetupMultiversion(Subcommand): """Return latest urls.""" urls = {} - # Assuming that project names contain <major>.<minor> version evg_project = f"mongodb-mongo-v{version}" if version == "master": evg_project = "mongodb-mongo-master" - evg_versions = evergreen_conn.get_evergreen_versions(self.evg_api, evg_project) - evg_version = None - try: - evg_version = next(evg_versions) - except HTTPError as err: - # Evergreen currently returns 500 if the version does not exist. - # TODO (SERVER-59675): Remove the check for 500 once evergreen returns 404 instead. - if not (err.response.status_code == 500 or err.response.status_code == 404): - raise - buildvariant_name = self.get_buildvariant_name(version) + if evg_project not in self.config.evergreen_projects: + return urls + LOGGER.debug("Found evergreen project.", evergreen_project=evg_project) + # Assuming that project names contain <major>.<minor> version major_minor_version = version + + buildvariant_name = self.get_buildvariant_name(major_minor_version) LOGGER.debug("Found buildvariant.", buildvariant_name=buildvariant_name) + evg_versions = evergreen_conn.get_evergreen_versions(self.evg_api, evg_project) + found_start_revision = start_from_revision is None - for evg_version in chain(iter([evg_version]), evg_versions): + for evg_version in evg_versions: # Skip all versions until we get the revision we should start looking from if found_start_revision is False and evg_version.revision != start_from_revision: LOGGER.warning("Skipping evergreen version.", evg_version=evg_version) @@ -252,10 +237,10 @@ class SetupMultiversion(Subcommand): LOGGER.info("Found git attributes.", git_tag=git_tag, commit_hash=commit_hash) evg_project, evg_version = evergreen_conn.get_evergreen_project_and_version( - self.evg_api, commit_hash) + self.config, self.evg_api, commit_hash) else: evg_project, evg_version = evergreen_conn.get_evergreen_project( - self.evg_api, evergreen_version) + self.config, self.evg_api, evergreen_version) LOGGER.debug("Found evergreen project.", evergreen_project=evg_project) @@ -355,13 +340,12 @@ class SetupMultiversionPlugin(PluginInterface): da=args.download_artifacts, dv=args.download_python_venv) - return SetupMultiversion( - install_dir=args.install_dir, link_dir=args.link_dir, mv_platform=args.platform, - edition=args.edition, architecture=args.architecture, use_latest=args.use_latest, - versions=args.versions, install_last_lts=args.install_last_lts, - install_last_continuous=args.install_last_continuous, download_options=download_options, - evergreen_config=args.evergreen_config, github_oauth_token=args.github_oauth_token, - debug=args.debug) + return SetupMultiversion(install_dir=args.install_dir, link_dir=args.link_dir, + mv_platform=args.platform, edition=args.edition, + architecture=args.architecture, use_latest=args.use_latest, + versions=args.versions, download_options=download_options, + evergreen_config=args.evergreen_config, + github_oauth_token=args.github_oauth_token, debug=args.debug) @classmethod def _add_args_to_parser(cls, parser): @@ -394,11 +378,6 @@ class SetupMultiversionPlugin(PluginInterface): "Examples: 4.0, 4.0.1, 4.0.0-rc0. If 'rc' is included in the version name, we'll use the exact rc, " "otherwise we'll pull the highest non-rc version compatible with the version specified." ) - parser.add_argument("--installLastLTS", dest="install_last_lts", action="store_true", - help="If specified, the last LTS version will be installed") - parser.add_argument("--installLastContinuous", dest="install_last_continuous", - action="store_true", - help="If specified, the last continuous version will be installed") parser.add_argument("-db", "--downloadBinaries", dest="download_binaries", action="store_true", default=True, diff --git a/buildscripts/resmokelib/testing/fixtures/_builder.py b/buildscripts/resmokelib/testing/fixtures/_builder.py index 91efed55d2a..f3d90fc4240 100644 --- a/buildscripts/resmokelib/testing/fixtures/_builder.py +++ b/buildscripts/resmokelib/testing/fixtures/_builder.py @@ -7,7 +7,7 @@ from git import Repo import buildscripts.resmokelib.utils.registry as registry import buildscripts.resmokelib.config as config -from buildscripts.resmokelib import errors +from buildscripts.resmokelib import errors, multiversionconstants from buildscripts.resmokelib.utils import default_if_none from buildscripts.resmokelib.utils import autoloader from buildscripts.resmokelib.testing.fixtures.fixturelib import FixtureLib @@ -68,7 +68,6 @@ class ReplSetBuilder(FixtureBuilder): def build_fixture(self, logger, job_num, fixturelib, *args, **kwargs): # pylint: disable=too-many-locals """Build a replica set.""" - from buildscripts.resmokelib import multiversionconstants # We hijack the mixed_bin_versions passed to the fixture. mixed_bin_versions = kwargs.pop("mixed_bin_versions", config.MIXED_BIN_VERSIONS) old_bin_version = kwargs.pop("old_bin_version", config.MULTIVERSION_BIN_VERSION) diff --git a/buildscripts/resmokelib/testing/fixtures/fixturelib.py b/buildscripts/resmokelib/testing/fixtures/fixturelib.py index 60d01badef8..f38b71e944f 100644 --- a/buildscripts/resmokelib/testing/fixtures/fixturelib.py +++ b/buildscripts/resmokelib/testing/fixtures/fixturelib.py @@ -8,6 +8,7 @@ from buildscripts.resmokelib import logging from buildscripts.resmokelib.core import network from buildscripts.resmokelib.utils.history import make_historic as _make_historic from buildscripts.resmokelib.testing.fixtures import _builder +from buildscripts.resmokelib.multiversionconstants import LAST_LTS_MONGOD_BINARY, LAST_LTS_MONGOS_BINARY, LAST_CONTINUOUS_MONGOD_BINARY, LAST_CONTINUOUS_MONGOS_BINARY class FixtureLib(object): @@ -100,8 +101,6 @@ class _FixtureConfig(object): # pylint: disable=too-many-instance-attributes def __init__(self): """Initialize FixtureConfig, setting values.""" - from buildscripts.resmokelib.multiversionconstants import LAST_LTS_MONGOD_BINARY, LAST_LTS_MONGOS_BINARY, LAST_CONTINUOUS_MONGOD_BINARY, LAST_CONTINUOUS_MONGOS_BINARY - # pylint: disable=invalid-name self.MONGOD_EXECUTABLE = config.MONGOD_EXECUTABLE self.DEFAULT_MONGOD_EXECUTABLE = config.DEFAULT_MONGOD_EXECUTABLE diff --git a/buildscripts/resmokelib/testing/fixtures/interface.py b/buildscripts/resmokelib/testing/fixtures/interface.py index 006b19fd6df..025bbfc4ea6 100644 --- a/buildscripts/resmokelib/testing/fixtures/interface.py +++ b/buildscripts/resmokelib/testing/fixtures/interface.py @@ -9,6 +9,7 @@ from typing import List import pymongo import pymongo.errors +import buildscripts.resmokelib.multiversionconstants as multiversion import buildscripts.resmokelib.utils.registry as registry _VERSIONS = {} # type: ignore diff --git a/buildscripts/resmokelib/utils/evergreen_conn.py b/buildscripts/resmokelib/utils/evergreen_conn.py index d3d4de20b1a..5cdb6774dc1 100644 --- a/buildscripts/resmokelib/utils/evergreen_conn.py +++ b/buildscripts/resmokelib/utils/evergreen_conn.py @@ -109,11 +109,10 @@ def get_generic_buildvariant_name(config, major_minor_version): return generic_buildvariant_name -def get_evergreen_project_and_version(evg_api, commit_hash): +def get_evergreen_project_and_version(config, evg_api, commit_hash): """Return evergreen project and version by commit hash.""" - from buildscripts.resmokelib import multiversionconstants - for evg_project in multiversionconstants.EVERGREEN_PROJECTS: + for evg_project in config.evergreen_projects: try: version_id = evg_project.replace("-", "_") + "_" + commit_hash evg_version = evg_api.version_by_id(version_id) @@ -127,11 +126,10 @@ def get_evergreen_project_and_version(evg_api, commit_hash): raise EvergreenConnError(f"Evergreen version for commit hash {commit_hash} not found.") -def get_evergreen_project(evg_api, evergreen_version_id): +def get_evergreen_project(config, evg_api, evergreen_version_id): """Return evergreen project for a given Evergreen version.""" - from buildscripts.resmokelib import multiversionconstants - for evg_project in multiversionconstants.EVERGREEN_PROJECTS: + for evg_project in config.evergreen_projects: try: evg_version = evg_api.version_by_id(evergreen_version_id) except HTTPError: diff --git a/buildscripts/tests/resmokelib/setup_multiversion/test_setup_multiversion.py b/buildscripts/tests/resmokelib/setup_multiversion/test_setup_multiversion.py index b3ee44970f3..30cea993d0e 100644 --- a/buildscripts/tests/resmokelib/setup_multiversion/test_setup_multiversion.py +++ b/buildscripts/tests/resmokelib/setup_multiversion/test_setup_multiversion.py @@ -91,7 +91,7 @@ class TestSetupMultiversionGetLatestUrls(TestSetupMultiversionBase): def test_no_compile_artifacts(self, mock_get_compile_artifact_urls, mock_versions_by_project, mock_version): mock_version.build_variants_map = {self.buildvariant_name: "build_id"} - mock_versions_by_project.return_value = iter([mock_version]) + mock_versions_by_project.return_value = [mock_version] mock_get_compile_artifact_urls.return_value = {} urls = self.setup_multiversion.get_latest_urls("4.4") @@ -108,7 +108,7 @@ class TestSetupMultiversionGetLatestUrls(TestSetupMultiversionBase): } mock_version.build_variants_map = {self.buildvariant_name: "build_id"} - mock_versions_by_project.return_value = iter([mock_version]) + mock_versions_by_project.return_value = [mock_version] mock_get_compile_artifact_urls.return_value = expected_urls urls = self.setup_multiversion.get_latest_urls("4.4") @@ -130,7 +130,7 @@ class TestSetupMultiversionGetLatestUrls(TestSetupMultiversionBase): mock_expected_version.build_variants_map = {self.buildvariant_name: "build_id"} evg_versions = [mock_version for _ in range(3)] evg_versions.append(mock_expected_version) - mock_versions_by_project.return_value = iter(evg_versions) + mock_versions_by_project.return_value = evg_versions mock_get_compile_artifact_urls.side_effect = lambda evg_api, evg_version, buildvariant_name, ignore_failed_push: { (self.setup_multiversion.evg_api, mock_version, self.buildvariant_name, False): {}, (self.setup_multiversion.evg_api, mock_expected_version, self.buildvariant_name, False): @@ -151,7 +151,7 @@ class TestSetupMultiversionGetLatestUrls(TestSetupMultiversionBase): } mock_version.build_variants_map = {self.generic_buildvariant_name: "build_id"} - mock_versions_by_project.return_value = iter([mock_version]) + mock_versions_by_project.return_value = [mock_version] mock_get_compile_artifact_urls.return_value = expected_urls urls = self.setup_multiversion.get_latest_urls("4.4") diff --git a/buildscripts/tests/resmokelib/utils/test_evergreen_conn.py b/buildscripts/tests/resmokelib/utils/test_evergreen_conn.py index 5caa1e16e29..e95841b0caa 100644 --- a/buildscripts/tests/resmokelib/utils/test_evergreen_conn.py +++ b/buildscripts/tests/resmokelib/utils/test_evergreen_conn.py @@ -103,6 +103,13 @@ class TestGetGenericBuildvariantName(unittest.TestCase): class TestGetEvergreenProjectAndVersion(unittest.TestCase): + def setUp(self): + raw_yaml = {"evergreen_projects": [ + "mongodb-mongo-master", + "mongodb-mongo-v4.4", + ]} + self.config = SetupMultiversionConfig(raw_yaml) + @patch("evergreen.version.Version") @patch("evergreen.api.EvergreenApi.version_by_id") @patch("evergreen.api.EvergreenApi") @@ -111,7 +118,7 @@ class TestGetEvergreenProjectAndVersion(unittest.TestCase): mock_version_by_id.return_value = mock_version evg_project, evg_version = evergreen_conn.get_evergreen_project_and_version( - mock_evg_api, "commit_hash") + self.config, mock_evg_api, "commit_hash") self.assertEqual(expected_evg_project, evg_project) self.assertEqual(mock_version, evg_version) @@ -120,8 +127,8 @@ class TestGetEvergreenProjectAndVersion(unittest.TestCase): def test_version_not_found(self, mock_evg_api, mock_version_by_id): mock_version_by_id.side_effect = HTTPError self.assertRaises(evergreen_conn.EvergreenConnError, - evergreen_conn.get_evergreen_project_and_version, mock_evg_api, - "commit_hash") + evergreen_conn.get_evergreen_project_and_version, self.config, + mock_evg_api, "commit_hash") class TestGetCompileArtifactUrls(unittest.TestCase): |