Skip to content

Commit c930c69

Browse files
authored
PYTHON-5566 & PYTHON-3132 Add minimum version checks for remaining test variants (#2650)
1 parent b1ea391 commit c930c69

File tree

11 files changed

+1707
-1173
lines changed

11 files changed

+1707
-1173
lines changed

.evergreen/generated_configs/tasks.yml

Lines changed: 346 additions & 208 deletions
Large diffs are not rendered by default.

.evergreen/generated_configs/variants.yml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,6 @@ buildvariants:
177177
- name: encryption-rhel8
178178
tasks:
179179
- name: .test-non-standard
180-
- name: .test-min-deps
181180
display_name: Encryption RHEL8
182181
run_on:
183182
- rhel87-small
@@ -208,7 +207,6 @@ buildvariants:
208207
- name: encryption-crypt_shared-rhel8
209208
tasks:
210209
- name: .test-non-standard
211-
- name: .test-min-deps
212210
display_name: Encryption crypt_shared RHEL8
213211
run_on:
214212
- rhel87-small

.evergreen/scripts/generate_config.py

Lines changed: 18 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ def get_encryption_expansions(encryption):
128128
):
129129
expansions = get_encryption_expansions(encryption)
130130
display_name = get_variant_name(encryption, host, **expansions)
131-
tasks = [".test-non-standard", ".test-min-deps"]
131+
tasks = [".test-non-standard"]
132132
if host != "rhel8":
133133
tasks = [".test-non-standard !.pypy"]
134134
variant = create_variant(
@@ -581,6 +581,8 @@ def create_server_version_tasks():
581581
seen.add(combo)
582582
tags.append("pr")
583583
expansions = dict(AUTH=auth, SSL=ssl, TOPOLOGY=topology)
584+
if python == ALL_PYTHONS[0]:
585+
expansions["TEST_MIN_DEPS"] = "1"
584586
if "t" in python:
585587
tags.append("free-threaded")
586588
if python not in PYPYS and "t" not in python:
@@ -646,6 +648,8 @@ def create_test_non_standard_tasks():
646648
if pr:
647649
tags.append("pr")
648650
expansions = dict(AUTH=auth, SSL=ssl, TOPOLOGY=topology, VERSION=version)
651+
if python == ALL_PYTHONS[0]:
652+
expansions["TEST_MIN_DEPS"] = "1"
649653
name = get_task_name("test-non-standard", python=python, **expansions)
650654
server_func = FunctionCall(func="run server", vars=expansions)
651655
test_vars = expansions.copy()
@@ -686,6 +690,8 @@ def create_test_standard_auth_tasks():
686690
if pr:
687691
tags.append("pr")
688692
expansions = dict(AUTH=auth, SSL=ssl, TOPOLOGY=topology, VERSION=version)
693+
if python == ALL_PYTHONS[0]:
694+
expansions["TEST_MIN_DEPS"] = "1"
689695
name = get_task_name("test-standard-auth", python=python, **expansions)
690696
server_func = FunctionCall(func="run server", vars=expansions)
691697
test_vars = expansions.copy()
@@ -695,22 +701,6 @@ def create_test_standard_auth_tasks():
695701
return tasks
696702

697703

698-
def create_min_deps_tasks():
699-
"""For variants that support testing with minimum dependencies."""
700-
tasks = []
701-
for topology in TOPOLOGIES:
702-
auth, ssl = get_standard_auth_ssl(topology)
703-
tags = ["test-min-deps", f"{topology}-{auth}-{ssl}"]
704-
expansions = dict(AUTH=auth, SSL=ssl, TOPOLOGY=topology)
705-
server_func = FunctionCall(func="run server", vars=expansions)
706-
test_vars = expansions.copy()
707-
test_vars["TEST_MIN_DEPS"] = "1"
708-
name = get_task_name("test-min-deps", python=CPYTHONS[0], sync="sync", **test_vars)
709-
test_func = FunctionCall(func="run tests", vars=test_vars)
710-
tasks.append(EvgTask(name=name, tags=tags, commands=[server_func, test_func]))
711-
return tasks
712-
713-
714704
def create_standard_tasks():
715705
"""For variants that do not set a TEST_NAME."""
716706
tasks = []
@@ -738,6 +728,8 @@ def create_standard_tasks():
738728
if pr:
739729
tags.append("pr")
740730
expansions = dict(AUTH=auth, SSL=ssl, TOPOLOGY=topology, VERSION=version)
731+
if python == ALL_PYTHONS[0]:
732+
expansions["TEST_MIN_DEPS"] = "1"
741733
name = get_task_name("test-standard", python=python, sync=sync, **expansions)
742734
server_func = FunctionCall(func="run server", vars=expansions)
743735
test_vars = expansions.copy()
@@ -755,9 +747,11 @@ def create_no_orchestration_tasks():
755747
"test-no-orchestration",
756748
f"python-{python}",
757749
]
758-
name = get_task_name("test-no-orchestration", python=python)
759750
assume_func = FunctionCall(func="assume ec2 role")
760751
test_vars = dict(TOOLCHAIN_VERSION=python)
752+
if python == ALL_PYTHONS[0]:
753+
test_vars["TEST_MIN_DEPS"] = "1"
754+
name = get_task_name("test-no-orchestration", **test_vars)
761755
test_func = FunctionCall(func="run tests", vars=test_vars)
762756
commands = [assume_func, test_func]
763757
tasks.append(EvgTask(name=name, tags=tags, commands=commands))
@@ -805,8 +799,10 @@ def create_aws_tasks():
805799
tags = [*base_tags, f"auth-aws-{test_type}"]
806800
if "t" in python:
807801
tags.append("free-threaded")
808-
name = get_task_name(f"{base_name}-{test_type}", python=python)
809802
test_vars = dict(TEST_NAME="auth_aws", SUB_TEST_NAME=test_type, TOOLCHAIN_VERSION=python)
803+
if python == ALL_PYTHONS[0] and test_type != "ecs":
804+
test_vars["TEST_MIN_DEPS"] = "1"
805+
name = get_task_name(f"{base_name}-{test_type}", **test_vars)
810806
test_func = FunctionCall(func="run tests", vars=test_vars)
811807
funcs = [server_func, assume_func, test_func]
812808
tasks.append(EvgTask(name=name, tags=tags, commands=funcs))
@@ -885,6 +881,8 @@ def _create_ocsp_tasks(algo, variant, server_type, base_task_name):
885881
TOOLCHAIN_VERSION=python,
886882
VERSION=version,
887883
)
884+
if python == ALL_PYTHONS[0]:
885+
vars["TEST_MIN_DEPS"] = "1"
888886
test_func = FunctionCall(func="run tests", vars=vars)
889887

890888
tags = ["ocsp", f"ocsp-{algo}", version]
@@ -893,11 +891,7 @@ def _create_ocsp_tasks(algo, variant, server_type, base_task_name):
893891
if algo == "valid-cert-server-staples" and version == "latest":
894892
tags.append("pr")
895893

896-
task_name = get_task_name(
897-
f"test-ocsp-{algo}-{base_task_name}",
898-
python=python,
899-
version=version,
900-
)
894+
task_name = get_task_name(f"test-ocsp-{algo}-{base_task_name}", **vars)
901895
tasks.append(EvgTask(name=task_name, tags=tags, commands=[test_func]))
902896

903897
return tasks

.evergreen/scripts/generate_config_utils.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@
4343
sync={"sync": "Sync", "async": "Async"},
4444
coverage={"1": "cov"},
4545
no_ext={"1": "No C"},
46-
test_min_deps={True: "Min Deps"},
46+
test_min_deps={"1": "Min Deps"},
4747
)
4848
HOSTS = dict()
4949

@@ -172,7 +172,7 @@ def get_common_name(base: str, sep: str, **kwargs) -> str:
172172
display_name = f"{display_name}{sep}{version}"
173173
for key, value in kwargs.items():
174174
name = value
175-
if key.lower() == "python":
175+
if key.lower() in ["python", "toolchain_version"]:
176176
if not value.startswith("pypy"):
177177
name = f"Python{value}"
178178
else:

pymongo/ocsp_support.py

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,6 @@
4545
from cryptography.x509 import ExtensionNotFound as _ExtensionNotFound
4646
from cryptography.x509 import TLSFeature as _TLSFeature
4747
from cryptography.x509 import TLSFeatureType as _TLSFeatureType
48-
from cryptography.x509 import load_pem_x509_certificate as _load_pem_x509_certificate
4948
from cryptography.x509.ocsp import OCSPCertStatus as _OCSPCertStatus
5049
from cryptography.x509.ocsp import OCSPRequestBuilder as _OCSPRequestBuilder
5150
from cryptography.x509.ocsp import OCSPResponseStatus as _OCSPResponseStatus
@@ -102,19 +101,6 @@
102101
)
103102

104103

105-
def _load_trusted_ca_certs(cafile: str) -> list[Certificate]:
106-
"""Parse the tlsCAFile into a list of certificates."""
107-
with open(cafile, "rb") as f:
108-
data = f.read()
109-
110-
# Load all the certs in the file.
111-
trusted_ca_certs = []
112-
backend = _default_backend()
113-
for cert_data in _re.findall(_CERT_REGEX, data):
114-
trusted_ca_certs.append(_load_pem_x509_certificate(cert_data, backend))
115-
return trusted_ca_certs
116-
117-
118104
def _get_issuer_cert(
119105
cert: Certificate, chain: Iterable[Certificate], trusted_ca_certs: Optional[list[Certificate]]
120106
) -> Optional[Certificate]:

pymongo/pyopenssl_context.py

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535
from pymongo.errors import ConfigurationError as _ConfigurationError
3636
from pymongo.errors import _CertificateError # type:ignore[attr-defined]
3737
from pymongo.ocsp_cache import _OCSPCache
38-
from pymongo.ocsp_support import _load_trusted_ca_certs, _ocsp_callback
38+
from pymongo.ocsp_support import _ocsp_callback
3939
from pymongo.socket_checker import SocketChecker as _SocketChecker
4040
from pymongo.socket_checker import _errno_from_exception
4141
from pymongo.write_concern import validate_boolean
@@ -322,10 +322,6 @@ def load_verify_locations(
322322
ssl.CERT_NONE.
323323
"""
324324
self._ctx.load_verify_locations(cafile, capath)
325-
# Manually load the CA certs when get_verified_chain is not available (pyopenssl<20).
326-
if not hasattr(_SSL.Connection, "get_verified_chain"):
327-
assert cafile is not None
328-
self._callback_data.trusted_ca_certs = _load_trusted_ca_certs(cafile)
329325

330326
def _load_certifi(self) -> None:
331327
"""Attempt to load CA certs from certifi."""

pyproject.toml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -48,11 +48,11 @@ Tracker = "https://jira.mongodb.org/projects/PYTHON/issues"
4848

4949
[dependency-groups]
5050
dev = []
51-
pip = ["pip"]
52-
gevent = ["gevent>=20.6.0"]
51+
pip = ["pip>=20.2"]
52+
gevent = ["gevent>=21.12"]
5353
coverage = [
54-
"pytest-cov",
55-
"coverage>=5,<=7.10.6"
54+
"pytest-cov>=4.0.0",
55+
"coverage[toml]>=5,<=7.10.6"
5656
]
5757
mockupdb = [
5858
"mockupdb@git+https://github.com/mongodb-labs/mongo-mockup-db@master"
@@ -61,8 +61,8 @@ perf = ["simplejson>=3.17.0"]
6161
typing = [
6262
"mypy==1.19.1",
6363
"pyright==1.1.407",
64-
"typing_extensions",
65-
"pip"
64+
"typing_extensions>=3.7.4.2",
65+
"pip>=20.2"
6666
]
6767

6868
# Used to call hatch_build.py

requirements/gssapi.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
pykerberos;os.name!='nt'
1+
pykerberos>=1.2.4;os.name!='nt'
22
winkerberos>=0.5.0;os.name=='nt'

requirements/ocsp.txt

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,10 @@
44
# service_identity 18.1.0 introduced support for IP addr matching.
55
# Fallback to certifi on Windows if we can't load CA certs from the system
66
# store and just use certifi on macOS.
7+
# pyopenssl, cryptography, and service_identity must be set in tandem.
78
# https://www.pyopenssl.org/en/stable/api/ssl.html#OpenSSL.SSL.Context.set_default_verify_paths
89
certifi>=2023.7.22;os.name=='nt' or sys_platform=='darwin'
9-
pyopenssl>=17.2.0
10-
requests<3.0.0
11-
cryptography>=2.5
12-
service_identity>=18.1.0
10+
pyopenssl>=23.2.0
11+
requests>=2.23.0,<3.0
12+
cryptography>=42.0.0
13+
service_identity>=23.1.0

requirements/snappy.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
python-snappy
1+
python-snappy>=0.6.0

0 commit comments

Comments
 (0)