Skip to content

Commit e039381

Browse files
committed
Merge branch 'master' of github.com:mongodb/mongo-python-driver
2 parents 1b83cf8 + 0f5349e commit e039381

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+703
-429
lines changed

.evergreen/config.yml

Lines changed: 18 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -432,9 +432,6 @@ functions:
432432
if [ -n "${test_serverless}" ]; then
433433
export TEST_SERVERLESS=1
434434
fi
435-
if [ -n "${IS_SERVERLESS_PROXY}" ]; then
436-
export IS_SERVERLESS_PROXY=1
437-
fi
438435
if [ -n "${TEST_INDEX_MANAGEMENT}" ]; then
439436
export TEST_INDEX_MANAGEMENT=1
440437
fi
@@ -1121,7 +1118,7 @@ tasks:
11211118
11221119
- name: "release-mac"
11231120
tags: ["release_tag"]
1124-
run_on: macos-1100
1121+
run_on: macos-11
11251122
commands:
11261123
- func: "build release"
11271124
vars:
@@ -2219,16 +2216,16 @@ axes:
22192216
- id: platform
22202217
display_name: OS
22212218
values:
2222-
- id: macos-1100
2223-
display_name: "macOS 11.00"
2224-
run_on: macos-1100
2219+
- id: macos
2220+
display_name: "macOS"
2221+
run_on: macos-14
22252222
variables:
22262223
skip_EC2_auth_test: true
22272224
skip_ECS_auth_test: true
22282225
skip_web_identity_auth_test: true
2229-
- id: macos-1100-arm64
2230-
display_name: "macOS 11.00 Arm64"
2231-
run_on: macos-1100-arm64
2226+
- id: macos-arm64
2227+
display_name: "macOS Arm64"
2228+
run_on: macos-14-arm64
22322229
variables:
22332230
skip_EC2_auth_test: true
22342231
skip_ECS_auth_test: true
@@ -2600,18 +2597,11 @@ axes:
26002597
- id: serverless
26012598
display_name: "Serverless"
26022599
values:
2603-
- id: "original"
2600+
- id: "enabled"
26042601
display_name: "Serverless"
26052602
variables:
26062603
test_serverless: true
26072604
batchtime: 10080 # 7 days
2608-
- id: "proxy"
2609-
display_name: "Serverless Proxy"
2610-
variables:
2611-
test_serverless: true
2612-
VAULT_NAME: "serverless_next"
2613-
IS_SERVERLESS_PROXY: true
2614-
batchtime: 10080 # 7 days
26152605

26162606
buildvariants:
26172607
- matrix_name: "tests-fips"
@@ -2629,12 +2619,12 @@ buildvariants:
26292619
platform:
26302620
# MacOS introduced SSL support with MongoDB >= 3.2.
26312621
# Older server versions (2.6, 3.0) are supported without SSL.
2632-
- macos-1100
2622+
- macos
26332623
auth: "*"
26342624
ssl: "*"
26352625
exclude_spec:
26362626
# No point testing with SSL without auth.
2637-
- platform: macos-1100
2627+
- platform: macos
26382628
auth: "noauth"
26392629
ssl: "ssl"
26402630
display_name: "${platform} ${auth} ${ssl}"
@@ -2652,7 +2642,7 @@ buildvariants:
26522642
- matrix_name: "test-macos-arm64"
26532643
matrix_spec:
26542644
platform:
2655-
- macos-1100-arm64
2645+
- macos-arm64
26562646
auth-ssl: "*"
26572647
display_name: "${platform} ${auth-ssl}"
26582648
tasks:
@@ -2666,7 +2656,7 @@ buildvariants:
26662656
- matrix_name: "test-macos-encryption"
26672657
matrix_spec:
26682658
platform:
2669-
- macos-1100
2659+
- macos
26702660
auth: "auth"
26712661
ssl: "nossl"
26722662
encryption: "*"
@@ -2675,7 +2665,7 @@ buildvariants:
26752665
rules:
26762666
- if:
26772667
encryption: ["encryption", "encryption_crypt_shared"]
2678-
platform: macos-1100
2668+
platform: macos
26792669
auth: "auth"
26802670
ssl: "nossl"
26812671
then:
@@ -2743,7 +2733,7 @@ buildvariants:
27432733

27442734
- matrix_name: "tests-pyopenssl-macOS"
27452735
matrix_spec:
2746-
platform: macos-1100
2736+
platform: macos
27472737
auth: "auth"
27482738
ssl: "ssl"
27492739
pyopenssl: "*"
@@ -3012,17 +3002,7 @@ buildvariants:
30123002
platform: rhel8
30133003
python-version: "*"
30143004
auth-ssl: auth-ssl
3015-
serverless: "original"
3016-
display_name: "${serverless} ${python-version} ${platform}"
3017-
tasks:
3018-
- "serverless_task_group"
3019-
3020-
- matrix_name: "serverless_proxy"
3021-
matrix_spec:
3022-
platform: rhel8
3023-
python-version: ["3.8", "3.10"]
3024-
auth-ssl: auth-ssl
3025-
serverless: "proxy"
3005+
serverless: "enabled"
30263006
display_name: "${serverless} ${python-version} ${platform}"
30273007
tasks:
30283008
- "serverless_task_group"
@@ -3077,7 +3057,7 @@ buildvariants:
30773057

30783058
- matrix_name: "ocsp-test-macos"
30793059
matrix_spec:
3080-
platform: macos-1100
3060+
platform: macos
30813061
mongodb-version: ["4.4", "5.0", "6.0", "7.0", "8.0", "latest"]
30823062
auth: "noauth"
30833063
ssl: "ssl"
@@ -3089,7 +3069,7 @@ buildvariants:
30893069

30903070
- matrix_name: "oidc-auth-test"
30913071
matrix_spec:
3092-
platform: [ rhel8, macos-1100, windows-64-vsMulti-small ]
3072+
platform: [ rhel8, macos, windows-64-vsMulti-small ]
30933073
display_name: "OIDC Auth ${platform}"
30943074
tasks:
30953075
- name: testoidc_task_group
@@ -3125,7 +3105,7 @@ buildvariants:
31253105

31263106
- matrix_name: "aws-auth-test-mac"
31273107
matrix_spec:
3128-
platform: [macos-1100]
3108+
platform: [macos]
31293109
display_name: "MONGODB-AWS Auth ${platform} ${python-version-mac}"
31303110
tasks:
31313111
- name: "aws-auth-test-4.4"

.evergreen/run-tests.sh

Lines changed: 16 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ set -o xtrace
3030

3131
AUTH=${AUTH:-noauth}
3232
SSL=${SSL:-nossl}
33-
TEST_SUITES="test/ test/asynchronous/"
33+
TEST_SUITES=""
3434
TEST_ARGS="${*:1}"
3535

3636
export PIP_QUIET=1 # Quiet by default
@@ -96,7 +96,7 @@ if [ -n "$TEST_LOADBALANCER" ]; then
9696
export LOAD_BALANCER=1
9797
export SINGLE_MONGOS_LB_URI="${SINGLE_MONGOS_LB_URI:-mongodb://127.0.0.1:8000/?loadBalanced=true}"
9898
export MULTI_MONGOS_LB_URI="${MULTI_MONGOS_LB_URI:-mongodb://127.0.0.1:8001/?loadBalanced=true}"
99-
export TEST_SUITES="test/test_load_balancer.py"
99+
export TEST_SUITES="load_balancer"
100100
fi
101101

102102
if [ "$SSL" != "nossl" ]; then
@@ -172,7 +172,7 @@ if [ -n "$TEST_ENCRYPTION" ]; then
172172
export PATH=$CRYPT_SHARED_DIR:$PATH
173173
fi
174174
# Only run the encryption tests.
175-
TEST_SUITES="test/test_encryption.py"
175+
TEST_SUITES="encryption"
176176
fi
177177

178178
if [ -n "$TEST_FLE_AZURE_AUTO" ] || [ -n "$TEST_FLE_GCP_AUTO" ]; then
@@ -185,8 +185,7 @@ if [ -n "$TEST_FLE_AZURE_AUTO" ] || [ -n "$TEST_FLE_GCP_AUTO" ]; then
185185
echo "MONGODB_URI unexpectedly contains user credentials in FLE test!";
186186
exit 1
187187
fi
188-
189-
TEST_SUITES="test/test_on_demand_csfle.py"
188+
TEST_SUITES="csfle"
190189
fi
191190

192191
if [ -n "$TEST_INDEX_MANAGEMENT" ]; then
@@ -195,36 +194,36 @@ if [ -n "$TEST_INDEX_MANAGEMENT" ]; then
195194
set +x
196195
export DB_PASSWORD="${DRIVERS_ATLAS_LAMBDA_PASSWORD}"
197196
set -x
198-
TEST_SUITES="test/test_index_management.py"
197+
TEST_SUITES="index_management"
199198
fi
200199

201200
if [ -n "$TEST_DATA_LAKE" ] && [ -z "$TEST_ARGS" ]; then
202-
TEST_SUITES="test/test_data_lake.py"
201+
TEST_SUITES="data_lake"
203202
fi
204203

205204
if [ -n "$TEST_ATLAS" ]; then
206-
TEST_SUITES="test/atlas/test_connection.py"
205+
TEST_SUITES="atlas"
207206
fi
208207

209208
if [ -n "$TEST_OCSP" ]; then
210209
python -m pip install ".[ocsp]"
211-
TEST_SUITES="test/ocsp/test_ocsp.py"
210+
TEST_SUITES="ocsp"
212211
fi
213212

214213
if [ -n "$TEST_AUTH_AWS" ]; then
215214
python -m pip install ".[aws]"
216-
TEST_SUITES="test/auth_aws/test_auth_aws.py"
215+
TEST_SUITES="auth_aws"
217216
fi
218217

219218
if [ -n "$TEST_AUTH_OIDC" ]; then
220219
python -m pip install ".[aws]"
221-
TEST_SUITES="test/auth_oidc/test_auth_oidc.py $TEST_ARGS"
220+
TEST_SUITES="auth_oidc"
222221
fi
223222

224223
if [ -n "$PERF_TEST" ]; then
225224
python -m pip install simplejson
226225
start_time=$(date +%s)
227-
TEST_SUITES="test/performance/perf_test.py"
226+
TEST_SUITES="perf"
228227
fi
229228

230229
echo "Running $AUTH tests over $SSL with python $(which python)"
@@ -254,7 +253,11 @@ PIP_QUIET=0 python -m pip list
254253
if [ -z "$GREEN_FRAMEWORK" ]; then
255254
# Use --capture=tee-sys so pytest prints test output inline:
256255
# https://docs.pytest.org/en/stable/how-to/capture-stdout-stderr.html
257-
python -m pytest -v --capture=tee-sys --durations=5 --maxfail=10 $TEST_SUITES $TEST_ARGS
256+
if [ -z "$TEST_SUITES" ]; then
257+
python -m pytest -v --capture=tee-sys --durations=5 --maxfail=10 $TEST_ARGS
258+
else
259+
python -m pytest -v --capture=tee-sys --durations=5 --maxfail=10 -m $TEST_SUITES $TEST_ARGS
260+
fi
258261
else
259262
python green_framework_test.py $GREEN_FRAMEWORK -v $TEST_ARGS
260263
fi

hatch.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ features = ["test"]
4242
test = "pytest -v --durations=5 --maxfail=10 {args}"
4343
test-eg = "bash ./.evergreen/run-tests.sh {args}"
4444
test-async = "test test/asynchronous/ {args}"
45-
test-mockupdb = ["pip install -U git+https://github.com/ajdavis/mongo-mockup-db@master", "test ./test/mockupdb"]
45+
test-mockupdb = ["pip install -U git+https://github.com/ajdavis/mongo-mockup-db@master", "test -m mockupdb"]
4646

4747
[envs.encryption]
4848
skip-install = true

pymongo/pyopenssl_context.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -292,7 +292,7 @@ def load_cert_chain(
292292
# Password callback MUST be set first or it will be ignored.
293293
if password:
294294

295-
def _pwcb(_max_length: int, _prompt_twice: bool, _user_data: bytes) -> bytes:
295+
def _pwcb(_max_length: int, _prompt_twice: bool, _user_data: Optional[bytes]) -> bytes:
296296
# XXX:We could check the password length against what OpenSSL
297297
# tells us is the max, but we can't raise an exception, so...
298298
# warn?
@@ -332,6 +332,7 @@ def _load_certifi(self) -> None:
332332
def _load_wincerts(self, store: str) -> None:
333333
"""Attempt to load CA certs from Windows trust store."""
334334
cert_store = self._ctx.get_cert_store()
335+
assert cert_store is not None
335336
oid = _stdlibssl.Purpose.SERVER_AUTH.oid
336337

337338
for cert, encoding, trust in _stdlibssl.enum_certificates(store): # type: ignore

pyproject.toml

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,10 +70,9 @@ zstd = ["requirements/zstd.txt"]
7070

7171
[tool.pytest.ini_options]
7272
minversion = "7"
73-
addopts = ["-ra", "--strict-config", "--strict-markers", "--junitxml=xunit-results/TEST-results.xml"]
73+
addopts = ["-ra", "--strict-config", "--strict-markers", "--junitxml=xunit-results/TEST-results.xml", "-m default"]
7474
testpaths = ["test"]
7575
log_cli_level = "INFO"
76-
norecursedirs = ["test/*"]
7776
faulthandler_timeout = 1500
7877
xfail_strict = true
7978
filterwarnings = [
@@ -96,6 +95,20 @@ filterwarnings = [
9695
# https://github.com/dateutil/dateutil/issues/1314
9796
"module:datetime.datetime.utc:DeprecationWarning:dateutil",
9897
]
98+
markers = [
99+
"auth_aws: tests that rely on pymongo-auth-aws",
100+
"auth_oidc: tests that rely on oidc auth",
101+
"ocsp: tests that rely on ocsp",
102+
"atlas: tests that rely on atlas",
103+
"data_lake: tests that rely on atlas data lake",
104+
"perf: benchmark tests",
105+
"index_management: index management tests",
106+
"csfle: client-side field-level encryption tests",
107+
"encryption: encryption tests",
108+
"load_balancer: load balancer tests",
109+
"mockupdb: tests that rely on mockupdb",
110+
"default: default test suite",
111+
]
99112

100113
[tool.mypy]
101114
strict = true

test/asynchronous/conftest.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,3 +12,9 @@ async def test_setup_and_teardown():
1212
await async_setup()
1313
yield
1414
await async_teardown()
15+
16+
17+
def pytest_collection_modifyitems(items, config):
18+
for item in items:
19+
if not any(item.iter_markers()):
20+
item.add_marker("default")

test/atlas/test_connection.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,16 @@
2020
import unittest
2121
from collections import defaultdict
2222

23+
import pytest
24+
2325
sys.path[0:0] = [""]
2426

2527
import pymongo
2628
from pymongo.ssl_support import HAS_SNI
2729

30+
pytestmark = pytest.mark.atlas
31+
32+
2833
URIS = {
2934
"ATLAS_REPL": os.environ.get("ATLAS_REPL"),
3035
"ATLAS_SHRD": os.environ.get("ATLAS_SHRD"),

test/auth_aws/test_auth_aws.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,14 +20,21 @@
2020
import unittest
2121
from unittest.mock import patch
2222

23+
import pytest
24+
2325
sys.path[0:0] = [""]
2426

25-
from pymongo_auth_aws import AwsCredential, auth
27+
try:
28+
from pymongo_auth_aws import AwsCredential, auth
29+
except ImportError:
30+
pass
2631

2732
from pymongo import MongoClient
2833
from pymongo.errors import OperationFailure
2934
from pymongo.uri_parser import parse_uri
3035

36+
pytestmark = pytest.mark.auth_aws
37+
3138

3239
class TestAuthAWS(unittest.TestCase):
3340
uri: str

test/auth_oidc/test_auth_oidc.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@
2525
from pathlib import Path
2626
from typing import Dict
2727

28+
import pytest
29+
2830
sys.path[0:0] = [""]
2931

3032
from test.unified_format import generate_test_classes
@@ -55,6 +57,8 @@
5557
# Generate unified tests.
5658
globals().update(generate_test_classes(str(TEST_PATH), module=__name__))
5759

60+
pytestmark = pytest.mark.auth_oidc
61+
5862

5963
class OIDCTestBase(unittest.TestCase):
6064
@classmethod
@@ -96,6 +100,7 @@ def fail_point(self, command_args):
96100
client.admin.command("configureFailPoint", cmd_on["configureFailPoint"], mode="off")
97101

98102

103+
@pytest.mark.auth_oidc
99104
class TestAuthOIDCHuman(OIDCTestBase):
100105
uri: str
101106

test/conftest.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,3 +12,9 @@ def test_setup_and_teardown():
1212
setup()
1313
yield
1414
teardown()
15+
16+
17+
def pytest_collection_modifyitems(items, config):
18+
for item in items:
19+
if not any(item.iter_markers()):
20+
item.add_marker("default")

0 commit comments

Comments
 (0)