Skip to content

Commit 301db6a

Browse files
committed
cleanup
1 parent ebfe20a commit 301db6a

File tree

2 files changed

+116
-89
lines changed

2 files changed

+116
-89
lines changed

.evergreen/config.yml

Lines changed: 12 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -2827,19 +2827,6 @@ buildvariants:
28272827
- "test-5.0-standalone"
28282828

28292829
# OCSP test matrix.
2830-
- name: ocsp-test-rhel8-v4.4-py3.9
2831-
tasks:
2832-
- name: .ocsp
2833-
display_name: OCSP test RHEL8 v4.4 py3.9
2834-
run_on:
2835-
- rhel87-small
2836-
batchtime: 20160
2837-
expansions:
2838-
VERSION: "4.4"
2839-
AUTH: noauth
2840-
SSL: ssl
2841-
TOPOLOGY: server
2842-
PYTHON_BINARY: /opt/python/3.9/bin/python3
28432830
- name: ocsp-test-rhel8-v5.0-py3.10
28442831
tasks:
28452832
- name: .ocsp
@@ -2848,10 +2835,10 @@ buildvariants:
28482835
- rhel87-small
28492836
batchtime: 20160
28502837
expansions:
2851-
VERSION: "5.0"
28522838
AUTH: noauth
28532839
SSL: ssl
28542840
TOPOLOGY: server
2841+
VERSION: "5.0"
28552842
PYTHON_BINARY: /opt/python/3.10/bin/python3
28562843
- name: ocsp-test-rhel8-v6.0-py3.11
28572844
tasks:
@@ -2861,10 +2848,10 @@ buildvariants:
28612848
- rhel87-small
28622849
batchtime: 20160
28632850
expansions:
2864-
VERSION: "6.0"
28652851
AUTH: noauth
28662852
SSL: ssl
28672853
TOPOLOGY: server
2854+
VERSION: "6.0"
28682855
PYTHON_BINARY: /opt/python/3.11/bin/python3
28692856
- name: ocsp-test-rhel8-v7.0-py3.12
28702857
tasks:
@@ -2874,10 +2861,10 @@ buildvariants:
28742861
- rhel87-small
28752862
batchtime: 20160
28762863
expansions:
2877-
VERSION: "7.0"
28782864
AUTH: noauth
28792865
SSL: ssl
28802866
TOPOLOGY: server
2867+
VERSION: "7.0"
28812868
PYTHON_BINARY: /opt/python/3.12/bin/python3
28822869
- name: ocsp-test-rhel8-v8.0-py3.13
28832870
tasks:
@@ -2887,10 +2874,10 @@ buildvariants:
28872874
- rhel87-small
28882875
batchtime: 20160
28892876
expansions:
2890-
VERSION: "8.0"
28912877
AUTH: noauth
28922878
SSL: ssl
28932879
TOPOLOGY: server
2880+
VERSION: "8.0"
28942881
PYTHON_BINARY: /opt/python/3.13/bin/python3
28952882
- name: ocsp-test-rhel8-rapid-pypy3.9
28962883
tasks:
@@ -2900,10 +2887,10 @@ buildvariants:
29002887
- rhel87-small
29012888
batchtime: 20160
29022889
expansions:
2903-
VERSION: rapid
29042890
AUTH: noauth
29052891
SSL: ssl
29062892
TOPOLOGY: server
2893+
VERSION: rapid
29072894
PYTHON_BINARY: /opt/python/pypy3.9/bin/python3
29082895
- name: ocsp-test-rhel8-latest-pypy3.10
29092896
tasks:
@@ -2913,10 +2900,10 @@ buildvariants:
29132900
- rhel87-small
29142901
batchtime: 20160
29152902
expansions:
2916-
VERSION: latest
29172903
AUTH: noauth
29182904
SSL: ssl
29192905
TOPOLOGY: server
2906+
VERSION: latest
29202907
PYTHON_BINARY: /opt/python/pypy3.10/bin/python3
29212908
- name: ocsp-test-win64-v4.4-py3.9
29222909
tasks:
@@ -2926,10 +2913,10 @@ buildvariants:
29262913
- windows-64-vsMulti-small
29272914
batchtime: 20160
29282915
expansions:
2929-
VERSION: "4.4"
29302916
AUTH: noauth
29312917
SSL: ssl
29322918
TOPOLOGY: server
2919+
VERSION: "4.4"
29332920
PYTHON_BINARY: C:/python/Python39/python.exe
29342921
- name: ocsp-test-win64-v8.0-py3.13
29352922
tasks:
@@ -2939,36 +2926,36 @@ buildvariants:
29392926
- windows-64-vsMulti-small
29402927
batchtime: 20160
29412928
expansions:
2942-
VERSION: "8.0"
29432929
AUTH: noauth
29442930
SSL: ssl
29452931
TOPOLOGY: server
2932+
VERSION: "8.0"
29462933
PYTHON_BINARY: C:/python/Python313/python.exe
29472934
- name: ocsp-test-macos-v4.4-py3.9
29482935
tasks:
29492936
- name: .ocsp-rsa !.ocsp-staple
2950-
display_name: OCSP test macOS v4.4 py3.9
2937+
display_name: OCSP test MacOS v4.4 py3.9
29512938
run_on:
29522939
- macos-14
29532940
batchtime: 20160
29542941
expansions:
2955-
VERSION: "4.4"
29562942
AUTH: noauth
29572943
SSL: ssl
29582944
TOPOLOGY: server
2945+
VERSION: "4.4"
29592946
PYTHON_BINARY: /Library/Frameworks/Python.Framework/Versions/3.9/bin/python3
29602947
- name: ocsp-test-macos-v8.0-py3.13
29612948
tasks:
29622949
- name: .ocsp-rsa !.ocsp-staple
2963-
display_name: OCSP test macOS v8.0 py3.13
2950+
display_name: OCSP test MacOS v8.0 py3.13
29642951
run_on:
29652952
- macos-14
29662953
batchtime: 20160
29672954
expansions:
2968-
VERSION: "8.0"
29692955
AUTH: noauth
29702956
SSL: ssl
29712957
TOPOLOGY: server
2958+
VERSION: "8.0"
29722959
PYTHON_BINARY: /Library/Frameworks/Python.Framework/Versions/3.13/bin/python3
29732960

29742961
- matrix_name: "oidc-auth-test"

.evergreen/scripts/generate_config.py

Lines changed: 104 additions & 64 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,9 @@
99
# Note: Run this file with `hatch run`, `pipx run`, or `uv run`.
1010
from __future__ import annotations
1111

12-
from itertools import product
12+
from dataclasses import dataclass
13+
from itertools import product, zip_longest
14+
from typing import Any
1315

1416
from shrub.v3.evg_build_variant import BuildVariant
1517
from shrub.v3.evg_project import EvgProject
@@ -18,7 +20,7 @@
1820

1921
# Top level variables.
2022
ALL_VERSIONS = ["4.0", "4.4", "5.0", "6.0", "7.0", "8.0", "rapid", "latest"]
21-
CPYTHONS = ["py3.9", "py3.10", "py3.11", "py3.12", "py3.13"]
23+
CPYTHONS = ["3.9", "3.10", "3.11", "3.12", "3.13"]
2224
PYPYS = ["pypy3.9", "pypy3.10"]
2325
ALL_PYTHONS = CPYTHONS + PYPYS
2426
ALL_WIN_PYTHONS = CPYTHONS.copy()
@@ -29,16 +31,35 @@
2931
TOPOLOGIES = ["standalone", "replica_set", "sharded_cluster"]
3032
C_EXTS = ["without c extensions", "with c extensions"]
3133
BATCHTIME_WEEK = 10080
32-
HOSTS = dict(rhel8="rhel87-small", Win64="windows-64-vsMulti-small", macOS="macos-14")
34+
HOSTS = dict()
35+
36+
37+
@dataclass
38+
class Host:
39+
name: str
40+
run_on: str
41+
display_name: str
42+
43+
44+
HOSTS["rhel8"] = Host("rhel8", "rhel87-small", "RHEL8")
45+
HOSTS["win64"] = Host("win64", "windows-64-vsMulti-small", "Win64")
46+
HOSTS["macos"] = Host("macos", "macos-14", "MacOS")
3347

3448

3549
# Helper functions.
36-
def create_variant(task_names, display_name, *, python=None, host=None, **kwargs):
50+
def create_variant(
51+
task_names: list[str],
52+
display_name: str,
53+
*,
54+
python: str | None = None,
55+
host: str | None = None,
56+
**kwargs: Any,
57+
) -> BuildVariant:
3758
task_refs = [EvgTaskRef(name=n) for n in task_names]
3859
kwargs.setdefault("expansions", dict())
3960
expansions = kwargs.pop("expansions")
4061
host = host or "rhel8"
41-
run_on = [HOSTS[host]]
62+
run_on = [HOSTS[host].run_on]
4263
name = display_name.replace(" ", "-").lower()
4364
if python:
4465
expansions["PYTHON_BINARY"] = get_python_binary(python, host)
@@ -53,81 +74,100 @@ def create_variant(task_names, display_name, *, python=None, host=None, **kwargs
5374
)
5475

5576

56-
def get_python_binary(python, host):
57-
if host.lower() == "win64":
77+
def get_python_binary(python: str, host: str) -> str:
78+
if host == "win64":
5879
is_32 = python.startswith("32-bit")
5980
if is_32:
6081
_, python = python.split()
61-
base = "C:/python/32/"
82+
base = "C:/python/32"
6283
else:
63-
base = "C:/python/"
64-
middle = python.replace("py", "Python").replace(".", "")
65-
return base + middle + "/python.exe"
84+
base = "C:/python"
85+
python = python.replace(".", "")
86+
return f"{base}/Python{python}/python.exe"
87+
88+
if host == "rhel8":
89+
return f"/opt/python/{python}/bin/python3"
6690

67-
if host.lower() == "rhel8":
68-
if python.startswith("pypy"):
69-
return f"/opt/python/{python}/bin/python3"
70-
return f"/opt/python/{python[2:]}/bin/python3"
91+
if host == "macos":
92+
return f"/Library/Frameworks/Python.Framework/Versions/{python}/bin/python3"
7193

72-
if host.lower() == "macos":
73-
ver = python.replace("py", "")
74-
return f"/Library/Frameworks/Python.Framework/Versions/{ver}/bin/python3"
94+
raise ValueError(f"no match found for python {python} on {host}")
7595

76-
raise ValueError(f"no match found for {python} on {host}")
96+
97+
def get_display(base: str, host: str, version: str, python: str) -> str:
98+
if version not in ["rapid", "latest"]:
99+
version = f"v{version}"
100+
if not python.startswith("pypy"):
101+
python = f"py{python}"
102+
return f"{base} {HOSTS[host].display_name} {version} {python}"
103+
104+
105+
def get_pairs(versions: list[str], pythons: list[str]) -> str:
106+
values = []
107+
for version, python in zip_longest(versions, pythons):
108+
if version is None:
109+
values.append((versions[0], python))
110+
elif python is None:
111+
values.append((version, pythons[0]))
112+
else:
113+
values.append((version, python))
114+
return values
77115

78116

79117
##############
80118
# OCSP
81119
##############
82120

121+
83122
# Create OCSP build variants.
84-
variants = []
85-
86-
# OCSP tests on rhel8 with rotating CPython versions.
87-
for version in ALL_VERSIONS:
88-
# OCSP is not supported until v4.4.
89-
if version == "4.0":
90-
continue
91-
task_refs = [EvgTaskRef(name=".ocsp")]
92-
expansions = dict(VERSION=version, AUTH="noauth", SSL="ssl", TOPOLOGY="server")
123+
def create_ocsp_variants() -> list[BuildVariant]:
124+
variants = []
93125
batchtime = BATCHTIME_WEEK * 2
94-
python = ALL_PYTHONS[len(variants) % len(ALL_PYTHONS)]
95-
host = "rhel8"
96-
if version in ["rapid", "latest"]:
97-
display_name = f"OCSP test RHEL8 {version} {python}"
98-
else:
99-
display_name = f"OCSP test RHEL8 v{version} {python}"
100-
variant = create_variant(
101-
[".ocsp"],
102-
display_name,
103-
python=python,
104-
batchtime=batchtime,
105-
host=host,
106-
expansions=expansions,
107-
)
108-
variants.append(variant)
126+
base_expansions = dict(AUTH="noauth", SSL="ssl", TOPOLOGY="server")
127+
base_display = "OCSP test"
128+
129+
# OCSP tests on rhel8 with all server and python versions.
130+
versions = [v for v in ALL_VERSIONS if v != "4.4"]
131+
for version, python in get_pairs(versions, ALL_PYTHONS):
132+
# OCSP is not supported until v4.4.
133+
if version == "4.0":
134+
continue
135+
expansions = base_expansions.copy()
136+
expansions["VERSION"] = version
137+
host = "rhel8"
138+
variant = create_variant(
139+
[".ocsp"],
140+
get_display(base_display, host, version, python),
141+
python=python,
142+
batchtime=batchtime,
143+
host=host,
144+
expansions=expansions,
145+
)
146+
variants.append(variant)
147+
148+
# OCSP tests on Windows and MacOS.
149+
for host, version in product(["win64", "macos"], ["4.4", "8.0"]):
150+
# MongoDB servers do not staple OCSP responses and only support RSA.
151+
task_names = [".ocsp-rsa !.ocsp-staple"]
152+
expansions = base_expansions.copy()
153+
expansions["VERSION"] = version
154+
if version == "4.4":
155+
python = CPYTHONS[0]
156+
else:
157+
python = CPYTHONS[-1]
158+
variant = create_variant(
159+
task_names,
160+
get_display(base_display, host, version, python),
161+
python=python,
162+
host=host,
163+
expansions=expansions,
164+
batchtime=batchtime,
165+
)
166+
variants.append(variant)
167+
168+
return variants
109169

110-
# OCSP tests on Windows and MacOS.
111-
for host, version in product(["Win64", "macOS"], ["4.4", "8.0"]):
112-
# MongoDB servers do not staple OCSP responses and only support RSA.
113-
task_names = [".ocsp-rsa !.ocsp-staple"]
114-
expansions = dict(VERSION=version, AUTH="noauth", SSL="ssl", TOPOLOGY="server")
115-
batchtime = BATCHTIME_WEEK * 2
116-
if version == "4.4":
117-
python = CPYTHONS[0]
118-
else:
119-
python = CPYTHONS[-1]
120-
display_name = f"OCSP test {host} v{version} {python}"
121-
variant = create_variant(
122-
task_names,
123-
display_name,
124-
python=python,
125-
host=host,
126-
expansions=expansions,
127-
batchtime=batchtime,
128-
)
129-
variants.append(variant)
130170

131171
# Generate OCSP config.
132-
project = EvgProject(tasks=None, buildvariants=variants)
172+
project = EvgProject(tasks=None, buildvariants=create_ocsp_variants())
133173
print(ShrubService.generate_yaml(project)) # noqa: T201

0 commit comments

Comments
 (0)