PYTHON-4902 Use shrub.py to generate tasks (#1966)

This commit is contained in:
Steven Silvester 2024-10-24 10:30:30 -05:00 committed by GitHub
parent cb8cf03eb5
commit 215bca21ec
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 3209 additions and 1296 deletions

View File

@ -26,7 +26,8 @@ timeout:
ls -la
include:
- filename: .evergreen/generated_configs/variants.yml
- filename: .evergreen/generated_configs/tasks.yml
- filename: .evergreen/generated_configs/variants.yml
functions:
"fetch source":
@ -971,249 +972,6 @@ tasks:
TOPOLOGY: "server"
- func: "run doctests"
- name: "test-4.0-standalone"
tags: ["4.0", "standalone"]
commands:
- func: "bootstrap mongo-orchestration"
vars:
VERSION: "4.0"
TOPOLOGY: "server"
- func: "run tests"
- name: "test-4.0-replica_set"
tags: ["4.0", "replica_set"]
commands:
- func: "bootstrap mongo-orchestration"
vars:
VERSION: "4.0"
TOPOLOGY: "replica_set"
- func: "run tests"
- name: "test-4.0-sharded_cluster"
tags: ["4.0", "sharded_cluster"]
commands:
- func: "bootstrap mongo-orchestration"
vars:
VERSION: "4.0"
TOPOLOGY: "sharded_cluster"
- func: "run tests"
- name: "test-4.2-standalone"
tags: ["4.2", "standalone"]
commands:
- func: "bootstrap mongo-orchestration"
vars:
VERSION: "4.2"
TOPOLOGY: "server"
- func: "run tests"
- name: "test-4.2-replica_set"
tags: ["4.2", "replica_set"]
commands:
- func: "bootstrap mongo-orchestration"
vars:
VERSION: "4.2"
TOPOLOGY: "replica_set"
- func: "run tests"
- name: "test-4.2-sharded_cluster"
tags: ["4.2", "sharded_cluster"]
commands:
- func: "bootstrap mongo-orchestration"
vars:
VERSION: "4.2"
TOPOLOGY: "sharded_cluster"
- func: "run tests"
- name: "test-4.4-standalone"
tags: ["4.4", "standalone"]
commands:
- func: "bootstrap mongo-orchestration"
vars:
VERSION: "4.4"
TOPOLOGY: "server"
- func: "run tests"
- name: "test-4.4-replica_set"
tags: ["4.4", "replica_set"]
commands:
- func: "bootstrap mongo-orchestration"
vars:
VERSION: "4.4"
TOPOLOGY: "replica_set"
- func: "run tests"
- name: "test-4.4-sharded_cluster"
tags: ["4.4", "sharded_cluster"]
commands:
- func: "bootstrap mongo-orchestration"
vars:
VERSION: "4.4"
TOPOLOGY: "sharded_cluster"
- func: "run tests"
- name: "test-5.0-standalone"
tags: ["5.0", "standalone"]
commands:
- func: "bootstrap mongo-orchestration"
vars:
VERSION: "5.0"
TOPOLOGY: "server"
- func: "run tests"
- name: "test-5.0-replica_set"
tags: ["5.0", "replica_set"]
commands:
- func: "bootstrap mongo-orchestration"
vars:
VERSION: "5.0"
TOPOLOGY: "replica_set"
- func: "run tests"
- name: "test-5.0-sharded_cluster"
tags: ["5.0", "sharded_cluster"]
commands:
- func: "bootstrap mongo-orchestration"
vars:
VERSION: "5.0"
TOPOLOGY: "sharded_cluster"
- func: "run tests"
- name: "test-6.0-standalone"
tags: ["6.0", "standalone"]
commands:
- func: "bootstrap mongo-orchestration"
vars:
VERSION: "6.0"
TOPOLOGY: "server"
- func: "run tests"
- name: "test-6.0-replica_set"
tags: ["6.0", "replica_set"]
commands:
- func: "bootstrap mongo-orchestration"
vars:
VERSION: "6.0"
TOPOLOGY: "replica_set"
- func: "run tests"
- name: "test-6.0-sharded_cluster"
tags: ["6.0", "sharded_cluster"]
commands:
- func: "bootstrap mongo-orchestration"
vars:
VERSION: "6.0"
TOPOLOGY: "sharded_cluster"
- func: "run tests"
- name: "test-8.0-standalone"
tags: ["8.0", "standalone"]
commands:
- func: "bootstrap mongo-orchestration"
vars:
VERSION: "8.0"
TOPOLOGY: "server"
- func: "run tests"
- name: "test-8.0-replica_set"
tags: ["8.0", "replica_set"]
commands:
- func: "bootstrap mongo-orchestration"
vars:
VERSION: "8.0"
TOPOLOGY: "replica_set"
- func: "run tests"
- name: "test-8.0-sharded_cluster"
tags: ["8.0", "sharded_cluster"]
commands:
- func: "bootstrap mongo-orchestration"
vars:
VERSION: "8.0"
TOPOLOGY: "sharded_cluster"
- func: "run tests"
- name: "test-7.0-standalone"
tags: ["7.0", "standalone"]
commands:
- func: "bootstrap mongo-orchestration"
vars:
VERSION: "7.0"
TOPOLOGY: "server"
- func: "run tests"
- name: "test-7.0-replica_set"
tags: ["7.0", "replica_set"]
commands:
- func: "bootstrap mongo-orchestration"
vars:
VERSION: "7.0"
TOPOLOGY: "replica_set"
- func: "run tests"
- name: "test-7.0-sharded_cluster"
tags: ["7.0", "sharded_cluster"]
commands:
- func: "bootstrap mongo-orchestration"
vars:
VERSION: "7.0"
TOPOLOGY: "sharded_cluster"
- func: "run tests"
- name: "test-latest-standalone"
tags: ["latest", "standalone"]
commands:
- func: "bootstrap mongo-orchestration"
vars:
VERSION: "latest"
TOPOLOGY: "server"
- func: "run tests"
- name: "test-latest-replica_set"
tags: ["latest", "replica_set"]
commands:
- func: "bootstrap mongo-orchestration"
vars:
VERSION: "latest"
TOPOLOGY: "replica_set"
- func: "run tests"
- name: "test-latest-sharded_cluster"
tags: ["latest", "sharded_cluster"]
commands:
- func: "bootstrap mongo-orchestration"
vars:
VERSION: "latest"
TOPOLOGY: "sharded_cluster"
- func: "run tests"
- name: "test-rapid-standalone"
tags: ["rapid", "standalone"]
commands:
- func: "bootstrap mongo-orchestration"
vars:
VERSION: "rapid"
TOPOLOGY: "server"
- func: "run tests"
- name: "test-rapid-replica_set"
tags: ["rapid", "replica_set"]
commands:
- func: "bootstrap mongo-orchestration"
vars:
VERSION: "rapid"
TOPOLOGY: "replica_set"
- func: "run tests"
- name: "test-rapid-sharded_cluster"
tags: ["rapid", "sharded_cluster"]
commands:
- func: "bootstrap mongo-orchestration"
vars:
VERSION: "rapid"
TOPOLOGY: "sharded_cluster"
- func: "run tests"
- name: "test-serverless"
tags: ["serverless"]
commands:

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -17,8 +17,9 @@ from pathlib import Path
from typing import Any
from shrub.v3.evg_build_variant import BuildVariant
from shrub.v3.evg_command import FunctionCall
from shrub.v3.evg_project import EvgProject
from shrub.v3.evg_task import EvgTaskRef
from shrub.v3.evg_task import EvgTask, EvgTaskRef
from shrub.v3.shrub_service import ShrubService
##############
@ -34,6 +35,12 @@ BATCHTIME_WEEK = 10080
AUTH_SSLS = [("auth", "ssl"), ("noauth", "ssl"), ("noauth", "nossl")]
TOPOLOGIES = ["standalone", "replica_set", "sharded_cluster"]
C_EXTS = ["with_ext", "without_ext"]
# By default test each of the topologies with a subset of auth/ssl.
SUB_TASKS = [
".sharded_cluster .auth .ssl",
".replica_set .noauth .ssl",
".standalone .noauth .nossl",
]
SYNCS = ["sync", "async"]
DISPLAY_LOOKUP = dict(
ssl=dict(ssl="SSL", nossl="NoSSL"),
@ -175,10 +182,10 @@ def handle_c_ext(c_ext, expansions):
expansions["NO_EXT"] = "1"
def create_yaml(tasks=None, variants=None):
def generate_yaml(tasks=None, variants=None):
"""Generate the yaml for a given set of tasks and variants."""
project = EvgProject(tasks=tasks, buildvariants=variants)
out = ShrubService.create_yaml(project)
out = ShrubService.generate_yaml(project)
# Dedent by two spaces to match what we use in config.yml
lines = [line[2:] for line in out.splitlines()]
print("\n".join(lines)) # noqa: T201
@ -233,9 +240,9 @@ def create_server_variants() -> list[BuildVariant]:
# Run the full matrix on linux with min and max CPython, and latest pypy.
host = "rhel8"
for python, (auth, ssl) in product([*MIN_MAX_PYTHON, PYPYS[-1]], AUTH_SSLS):
for python in [*MIN_MAX_PYTHON, PYPYS[-1]]:
display_name = f"Test {host}"
expansions = dict(AUTH=auth, SSL=ssl, COVERAGE="coverage")
expansions = dict(COVERAGE="coverage")
display_name = get_display_name("Test", host, python=python, **expansions)
variant = create_variant(
[f".{t}" for t in TOPOLOGIES],
@ -247,15 +254,12 @@ def create_server_variants() -> list[BuildVariant]:
)
variants.append(variant)
# Test the rest of the pythons on linux.
for python, (auth, ssl), topology in zip_cycle(
CPYTHONS[1:-1] + PYPYS[:-1], AUTH_SSLS, TOPOLOGIES
):
# Test the rest of the pythons.
for python in CPYTHONS[1:-1] + PYPYS[:-1]:
display_name = f"Test {host}"
expansions = dict(AUTH=auth, SSL=ssl)
display_name = get_display_name("Test", host, python=python, **expansions)
display_name = get_display_name("Test", host, python=python)
variant = create_variant(
[f".{topology}"],
SUB_TASKS,
display_name,
python=python,
host=host,
@ -265,18 +269,14 @@ def create_server_variants() -> list[BuildVariant]:
# Test a subset on each of the other platforms.
for host in ("macos", "macos-arm64", "win64", "win32"):
for (
python,
sync,
(auth, ssl),
) in product(MIN_MAX_PYTHON, SYNCS, AUTH_SSLS):
test_suite = "default" if sync == "sync" else "default_async"
topology = TOPOLOGIES[0] if python == CPYTHONS[0] else TOPOLOGIES[-1]
tasks = [f".{topology}"]
for python in MIN_MAX_PYTHON:
tasks = SUB_TASKS
# MacOS arm64 only works on server versions 6.0+
if host == "macos-arm64":
tasks = [f".{topology} .{version}" for version in get_versions_from("6.0")]
expansions = dict(AUTH=auth, SSL=ssl, TEST_SUITES=test_suite, SKIP_CSOT_TESTS="true")
tasks = []
for version in get_versions_from("6.0"):
tasks.extend(f"{t} .{version}" for t in SUB_TASKS)
expansions = dict(SKIP_CSOT_TESTS="true")
display_name = get_display_name("Test", host, python=python, **expansions)
variant = create_variant(
tasks,
@ -295,8 +295,8 @@ def create_encryption_variants() -> list[BuildVariant]:
tags = ["encryption_tag"]
batchtime = BATCHTIME_WEEK
def get_encryption_expansions(encryption, ssl="ssl"):
expansions = dict(AUTH="auth", SSL=ssl, test_encryption="true")
def get_encryption_expansions(encryption):
expansions = dict(test_encryption="true")
if "crypt_shared" in encryption:
expansions["test_crypt_shared"] = "true"
if "PyOpenSSL" in encryption:
@ -305,13 +305,13 @@ def create_encryption_variants() -> list[BuildVariant]:
host = "rhel8"
# Test against all server versions and topolgies for the three main python versions.
# Test against all server versions for the three main python versions.
encryptions = ["Encryption", "Encryption crypt_shared", "Encryption PyOpenSSL"]
for encryption, python in product(encryptions, [*MIN_MAX_PYTHON, PYPYS[-1]]):
expansions = get_encryption_expansions(encryption)
display_name = get_display_name(encryption, host, python=python, **expansions)
variant = create_variant(
[f".{t}" for t in TOPOLOGIES],
SUB_TASKS,
display_name,
python=python,
host=host,
@ -322,13 +322,11 @@ def create_encryption_variants() -> list[BuildVariant]:
variants.append(variant)
# Test the rest of the pythons on linux for all server versions.
for encryption, python, ssl in zip_cycle(
encryptions, CPYTHONS[1:-1] + PYPYS[:-1], ["ssl", "nossl"]
):
expansions = get_encryption_expansions(encryption, ssl)
for encryption, python, task in zip_cycle(encryptions, CPYTHONS[1:-1] + PYPYS[:-1], SUB_TASKS):
expansions = get_encryption_expansions(encryption)
display_name = get_display_name(encryption, host, python=python, **expansions)
variant = create_variant(
[".replica_set"],
[task],
display_name,
python=python,
host=host,
@ -340,8 +338,7 @@ def create_encryption_variants() -> list[BuildVariant]:
encryptions = ["Encryption", "Encryption crypt_shared"]
task_names = [".latest .replica_set"]
for host, encryption, python in product(["macos", "win64"], encryptions, MIN_MAX_PYTHON):
ssl = "ssl" if python == CPYTHONS[0] else "nossl"
expansions = get_encryption_expansions(encryption, ssl)
expansions = get_encryption_expansions(encryption)
display_name = get_display_name(encryption, host, python=python, **expansions)
variant = create_variant(
task_names,
@ -386,7 +383,8 @@ def create_compression_variants():
# Compression tests - standalone versions of each server, across python versions, with and without c extensions.
# PyPy interpreters are always tested without extensions.
host = "rhel8"
task_names = dict(snappy=[".standalone"], zlib=[".standalone"], zstd=[".standalone !.4.0"])
base_task = ".standalone .noauth .nossl"
task_names = dict(snappy=[base_task], zlib=[base_task], zstd=[f"{base_task} !.4.0"])
variants = []
for ind, (compressor, c_ext) in enumerate(product(["snappy", "zlib", "zstd"], C_EXTS)):
expansions = dict(COMPRESSORS=compressor)
@ -445,24 +443,23 @@ def create_enterprise_auth_variants():
def create_pyopenssl_variants():
base_name = "PyOpenSSL"
batchtime = BATCHTIME_WEEK
base_expansions = dict(test_pyopenssl="true", SSL="ssl")
expansions = dict(test_pyopenssl="true")
variants = []
for python in ALL_PYTHONS:
# Only test "noauth" with min python.
auth = "noauth" if python == CPYTHONS[0] else "auth"
ssl = "nossl" if auth == "noauth" else "ssl"
if python == CPYTHONS[0]:
host = "macos"
elif python == CPYTHONS[-1]:
host = "win64"
else:
host = "rhel8"
expansions = dict(AUTH=auth)
expansions.update(base_expansions)
display_name = get_display_name(base_name, host, python=python)
variant = create_variant(
[".replica_set", ".7.0"],
[f".replica_set .{auth} .{ssl}", f".7.0 .{auth} .{ssl}"],
display_name,
python=python,
host=host,
@ -482,12 +479,12 @@ def create_storage_engine_tests():
python = CPYTHONS[0]
expansions = dict(STORAGE_ENGINE=engine.lower())
if engine == engines[0]:
tasks = [f".standalone .{v}" for v in ALL_VERSIONS]
tasks = [f".standalone .noauth .nossl .{v}" for v in ALL_VERSIONS]
else:
# MongoDB 4.2 drops support for MMAPv1
versions = get_versions_until("4.0")
tasks = [f".standalone .{v}" for v in versions] + [
f".replica_set .{v}" for v in versions
tasks = [f".standalone .{v} .noauth .nossl" for v in versions] + [
f".replica_set .{v} .noauth .nossl" for v in versions
]
display_name = get_display_name(f"Storage {engine}", host, python=python)
variant = create_variant(
@ -500,7 +497,7 @@ def create_storage_engine_tests():
def create_versioned_api_tests():
host = "rhel8"
tags = ["versionedApi_tag"]
tasks = [f".standalone .{v}" for v in get_versions_from("5.0")]
tasks = [f".standalone .{v} .noauth .nossl" for v in get_versions_from("5.0")]
variants = []
types = ["require v1", "accept v2"]
@ -531,7 +528,7 @@ def create_versioned_api_tests():
def create_green_framework_variants():
variants = []
tasks = [".standalone"]
tasks = [".standalone .noauth .nossl"]
host = "rhel8"
for python, framework in product([CPYTHONS[0], CPYTHONS[-2]], ["eventlet", "gevent"]):
expansions = dict(GREEN_FRAMEWORK=framework, AUTH="auth", SSL="ssl")
@ -547,7 +544,7 @@ def create_no_c_ext_variants():
variants = []
host = "rhel8"
for python, topology in zip_cycle(CPYTHONS, TOPOLOGIES):
tasks = [f".{topology}"]
tasks = [f".{topology} .noauth .nossl"]
expansions = dict()
handle_c_ext(C_EXTS[0], expansions)
display_name = get_display_name("No C Ext", host, python=python)
@ -717,32 +714,25 @@ def create_aws_auth_variants():
def create_alternative_hosts_variants():
base_expansions = dict(SKIP_HATCH="true")
expansions = dict(SKIP_HATCH="true")
batchtime = BATCHTIME_WEEK
variants = []
host = "rhel7"
for auth, ssl in AUTH_SSLS:
expansions = base_expansions.copy()
expansions["AUTH"] = auth
expansions["SSL"] = ssl
variants.append(
create_variant(
[".5.0 .standalone"],
get_display_name("OpenSSL 1.0.2", "rhel7", python=CPYTHONS[0], **expansions),
host=host,
python=CPYTHONS[0],
batchtime=batchtime,
expansions=expansions,
)
variants.append(
create_variant(
[".5.0 .standalone"],
get_display_name("OpenSSL 1.0.2", "rhel7", python=CPYTHONS[0], **expansions),
host=host,
python=CPYTHONS[0],
batchtime=batchtime,
expansions=expansions,
)
)
hosts = ["rhel92-fips", "rhel8-zseries-small", "rhel8-power-small", "rhel82-arm64-small"]
host_names = ["RHEL9-FIPS", "RHEL8-zseries", "RHEL8-POWER8", "RHEL8-arm64"]
for (host, host_name), (auth, ssl) in product(zip(hosts, host_names), AUTH_SSLS):
expansions = base_expansions.copy()
expansions["AUTH"] = auth
expansions["SSL"] = ssl
for host, host_name in zip(hosts, host_names):
variants.append(
create_variant(
[".6.0 .standalone"],
@ -755,6 +745,34 @@ def create_alternative_hosts_variants():
return variants
##############
# Tasks
##############
def create_server_tasks():
tasks = []
for topo, version, (auth, ssl), sync in product(TOPOLOGIES, ALL_VERSIONS, AUTH_SSLS, SYNCS):
name = f"test-{version}-{topo}-{auth}-{ssl}-{sync}".lower()
tags = [version, topo, auth, ssl, sync]
bootstrap_vars = dict(
VERSION=version,
TOPOLOGY=topo if topo != "standalone" else "server",
AUTH=auth,
SSL=ssl,
)
bootstrap_func = FunctionCall(func="bootstrap mongo-orchestration", vars=bootstrap_vars)
test_vars = dict(
AUTH=auth,
SSL=ssl,
SYNC=sync,
TEST_SUITES="default" if sync == "sync" else "default_async",
)
test_func = FunctionCall(func="run tests", vars=test_vars)
tasks.append(EvgTask(name=name, tags=tags, commands=[bootstrap_func, test_func]))
return tasks
##################
# Generate Config
##################
@ -790,4 +808,35 @@ def write_variants_to_file():
fid.write(f"{line}\n")
def write_tasks_to_file():
mod = sys.modules[__name__]
here = Path(__file__).absolute().parent
target = here.parent / "generated_configs" / "tasks.yml"
if target.exists():
target.unlink()
with target.open("w") as fid:
fid.write("tasks:\n")
for name, func in getmembers(mod, isfunction):
if not name.endswith("_tasks"):
continue
if not name.startswith("create_"):
raise ValueError("Task creators must start with create_")
title = name.replace("create_", "").replace("_tasks", "").replace("_", " ").capitalize()
project = EvgProject(tasks=func(), buildvariants=None)
out = ShrubService.generate_yaml(project).splitlines()
with target.open("a") as fid:
fid.write(f" # {title} tests\n")
for line in out[1:]:
fid.write(f"{line}\n")
fid.write("\n")
# Remove extra trailing newline:
data = target.read_text().splitlines()
with target.open("w") as fid:
for line in data[:-1]:
fid.write(f"{line}\n")
write_variants_to_file()
write_tasks_to_file()