Skip to content

Commit 9663485

Browse files
authored
Merge branch 'master' into PYTHON-5814
2 parents a8a3b4e + ea074a3 commit 9663485

22 files changed

Lines changed: 917 additions & 82 deletions

File tree

.evergreen/config.yml

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,17 @@ post:
4545
- func: "cleanup"
4646

4747
tasks:
48+
- name: linkcheck
49+
commands:
50+
- command: subprocess.exec
51+
type: test
52+
params:
53+
binary: bash
54+
args:
55+
- .evergreen/just.sh
56+
- docs-linkcheck
57+
working_dir: src
58+
4859
- name: resync_specs
4960
commands:
5061
- command: subprocess.exec
@@ -56,6 +67,14 @@ tasks:
5667
working_dir: src
5768

5869
buildvariants:
70+
- name: linkcheck
71+
display_name: "Link Check"
72+
run_on: rhel80-small
73+
cron: '0 0 * * *'
74+
patchable: true
75+
tasks:
76+
- name: linkcheck
77+
5978
- name: resync_specs
6079
display_name: "Resync Specs"
6180
run_on: rhel80-small

.evergreen/generated_configs/tasks.yml

Lines changed: 25 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4802,22 +4802,20 @@ tasks:
48024802
- python-3.13
48034803
- standalone-noauth-nossl
48044804
- noauth
4805-
- name: test-non-standard-latest-python3.14t-noauth-ssl-replica-set-cov
4805+
- name: test-non-standard-latest-python3.14t-noauth-ssl-replica-set
48064806
commands:
48074807
- func: run server
48084808
vars:
48094809
AUTH: noauth
48104810
SSL: ssl
48114811
TOPOLOGY: replica_set
48124812
VERSION: latest
4813-
COVERAGE: "1"
48144813
- func: run tests
48154814
vars:
48164815
AUTH: noauth
48174816
SSL: ssl
48184817
TOPOLOGY: replica_set
48194818
VERSION: latest
4820-
COVERAGE: "1"
48214819
TOOLCHAIN_VERSION: 3.14t
48224820
tags:
48234821
- test-non-standard
@@ -4826,7 +4824,6 @@ tasks:
48264824
- replica_set-noauth-ssl
48274825
- noauth
48284826
- free-threaded
4829-
- pr
48304827
- name: test-non-standard-latest-pypy3.11-noauth-ssl-replica-set
48314828
commands:
48324829
- func: run server
@@ -4873,30 +4870,50 @@ tasks:
48734870
- sharded_cluster-auth-ssl
48744871
- auth
48754872
- pr
4876-
- name: test-non-standard-latest-python3.13-noauth-nossl-standalone-cov
4873+
- cov
4874+
- name: test-non-standard-latest-python3.14-auth-ssl-sharded-cluster
4875+
commands:
4876+
- func: run server
4877+
vars:
4878+
AUTH: auth
4879+
SSL: ssl
4880+
TOPOLOGY: sharded_cluster
4881+
VERSION: latest
4882+
- func: run tests
4883+
vars:
4884+
AUTH: auth
4885+
SSL: ssl
4886+
TOPOLOGY: sharded_cluster
4887+
VERSION: latest
4888+
TOOLCHAIN_VERSION: "3.14"
4889+
tags:
4890+
- test-non-standard-no-cov
4891+
- server-latest
4892+
- python-3.14
4893+
- sharded_cluster-auth-ssl
4894+
- auth
4895+
- pr
4896+
- name: test-non-standard-latest-python3.13-noauth-nossl-standalone
48774897
commands:
48784898
- func: run server
48794899
vars:
48804900
AUTH: noauth
48814901
SSL: nossl
48824902
TOPOLOGY: standalone
48834903
VERSION: latest
4884-
COVERAGE: "1"
48854904
- func: run tests
48864905
vars:
48874906
AUTH: noauth
48884907
SSL: nossl
48894908
TOPOLOGY: standalone
48904909
VERSION: latest
4891-
COVERAGE: "1"
48924910
TOOLCHAIN_VERSION: "3.13"
48934911
tags:
48944912
- test-non-standard
48954913
- server-latest
48964914
- python-3.13
48974915
- standalone-noauth-nossl
48984916
- noauth
4899-
- pr
49004917
- name: test-non-standard-rapid-python3.11-noauth-ssl-replica-set
49014918
commands:
49024919
- func: run server

.evergreen/generated_configs/variants.yml

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,8 @@ buildvariants:
193193
tags: [encryption_tag]
194194
- name: encryption-macos
195195
tasks:
196-
- name: .test-non-standard !.pypy
196+
- name: .test-non-standard !.pypy !.cov
197+
- name: .test-non-standard-no-cov !.pypy
197198
display_name: Encryption macOS
198199
run_on:
199200
- macos-14
@@ -203,7 +204,8 @@ buildvariants:
203204
tags: [encryption_tag]
204205
- name: encryption-win64
205206
tasks:
206-
- name: .test-non-standard !.pypy
207+
- name: .test-non-standard !.pypy !.cov
208+
- name: .test-non-standard-no-cov !.pypy
207209
display_name: Encryption Win64
208210
run_on:
209211
- windows-2022-latest-small
@@ -224,7 +226,8 @@ buildvariants:
224226
tags: [encryption_tag]
225227
- name: encryption-crypt_shared-macos
226228
tasks:
227-
- name: .test-non-standard !.pypy
229+
- name: .test-non-standard !.pypy !.cov
230+
- name: .test-non-standard-no-cov !.pypy
228231
display_name: Encryption crypt_shared macOS
229232
run_on:
230233
- macos-14
@@ -235,7 +238,8 @@ buildvariants:
235238
tags: [encryption_tag]
236239
- name: encryption-crypt_shared-win64
237240
tasks:
238-
- name: .test-non-standard !.pypy
241+
- name: .test-non-standard !.pypy !.cov
242+
- name: .test-non-standard-no-cov !.pypy
239243
display_name: Encryption crypt_shared Win64
240244
run_on:
241245
- windows-2022-latest-small

.evergreen/scripts/generate_config.py

Lines changed: 28 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,11 @@ def get_encryption_expansions(encryption):
132132
display_name = get_variant_name(encryption, host, **expansions)
133133
tasks = [".test-non-standard"]
134134
if host != "rhel8":
135-
tasks = [".test-non-standard !.pypy"]
135+
# Exclude PyPy (not tested with encryption on macOS/win64) and coverage tasks
136+
# (encryption suites exceed the 60-min timeout with coverage overhead on macOS/win64).
137+
# Also include the non-coverage companion tasks (test-non-standard-no-cov) which
138+
# carry the "latest" server tasks without COVERAGE=1.
139+
tasks = [".test-non-standard !.pypy !.cov", ".test-non-standard-no-cov !.pypy"]
136140
variant = create_variant(
137141
tasks,
138142
display_name,
@@ -644,8 +648,9 @@ def create_test_non_standard_tasks():
644648
tasks = []
645649
task_combos = set()
646650
# For each version and topology, rotate through the CPythons.
651+
# Only the sharded_cluster topology runs on PRs to keep patch build size manageable.
647652
for (version, topology), python in zip_cycle(list(product(ALL_VERSIONS, TOPOLOGIES)), CPYTHONS):
648-
pr = version == "latest"
653+
pr = version == "latest" and topology == "sharded_cluster"
649654
task_combos.add((version, topology, python, pr))
650655
# For each PyPy and topology, rotate through the MongoDB versions.
651656
for (python, topology), version in zip_cycle(list(product(PYPYS, TOPOLOGIES)), ALL_VERSIONS):
@@ -670,12 +675,33 @@ def create_test_non_standard_tasks():
670675
expansions["TEST_MIN_DEPS"] = "1"
671676
elif pr:
672677
expansions["COVERAGE"] = "1"
678+
tags.append("cov")
673679
name = get_task_name("test-non-standard", python=python, **expansions)
674680
server_func = FunctionCall(func="run server", vars=expansions)
675681
test_vars = expansions.copy()
676682
test_vars["TOOLCHAIN_VERSION"] = python
677683
test_func = FunctionCall(func="run tests", vars=test_vars)
678684
tasks.append(EvgTask(name=name, tags=tags, commands=[server_func, test_func]))
685+
# For each coverage task, also emit a non-coverage companion so that
686+
# macOS/Win64 encryption variants (which filter out .cov due to timeout
687+
# constraints) still have a "latest" task to activate in patch builds.
688+
if pr and "cov" in tags:
689+
nc_expansions = {k: v for k, v in expansions.items() if k != "COVERAGE"}
690+
# Use a distinct primary tag so companions are not selected by existing
691+
# ".test-non-standard" selectors (e.g. load-balancer, PyOpenSSL variants).
692+
nc_tags = [
693+
"test-non-standard-no-cov" if t == "test-non-standard" else t
694+
for t in tags
695+
if t != "cov"
696+
]
697+
nc_name = get_task_name("test-non-standard", python=python, **nc_expansions)
698+
nc_server_func = FunctionCall(func="run server", vars=nc_expansions)
699+
nc_test_vars = nc_expansions.copy()
700+
nc_test_vars["TOOLCHAIN_VERSION"] = python
701+
nc_test_func = FunctionCall(func="run tests", vars=nc_test_vars)
702+
tasks.append(
703+
EvgTask(name=nc_name, tags=nc_tags, commands=[nc_server_func, nc_test_func])
704+
)
679705
return tasks
680706

681707

.github/workflows/test-python.yml

Lines changed: 3 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,9 @@ jobs:
4646
- name: Run typecheck
4747
run: |
4848
just typing
49+
- name: Run synchro smoke test
50+
run: |
51+
uv run --extra test --with unasync pytest tools/test_synchro.py -v --override-ini="addopts="
4952
- run: |
5053
sudo apt-get install -y cppcheck
5154
- run: |
@@ -154,27 +157,6 @@ jobs:
154157
- name: Build docs
155158
run: just docs
156159

157-
linkcheck:
158-
name: Link Check
159-
runs-on: ubuntu-latest
160-
steps:
161-
- uses: actions/checkout@v6.0.3
162-
with:
163-
persist-credentials: false
164-
- name: Install uv
165-
uses: astral-sh/setup-uv@fac544c07dec837d0ccb6301d7b5580bf5edae39 # v8.2.0
166-
with:
167-
enable-cache: true
168-
python-version: "3.10"
169-
- name: Install just
170-
run: uv tool install rust-just
171-
- name: Install dependencies
172-
run: just install
173-
- name: Build docs
174-
run: just docs-linkcheck
175-
env:
176-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
177-
178160
typing:
179161
name: Typing Tests
180162
runs-on: ubuntu-latest

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ expansion.yml
3030
.evergreen/scripts/test-env.sh
3131
specifications/
3232
results.json
33+
.synchro-modified
3334
.evergreen/atlas_x509_dev_client_certificate.pem
3435

3536
# Lambda temp files

.pre-commit-config.yaml

Lines changed: 21 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -18,25 +18,36 @@ repos:
1818
exclude: .patch
1919
exclude_types: [json]
2020

21-
- repo: https://github.com/astral-sh/ruff-pre-commit
22-
# Ruff version.
23-
rev: v0.15.16
21+
- repo: local
2422
hooks:
2523
- id: ruff
26-
args: ["--fix", "--show-fixes"]
24+
name: ruff
25+
entry: uv run --group lint ruff check --fix --show-fixes
26+
language: system
27+
types_or: [python, pyi]
28+
require_serial: true
2729
- id: ruff-format
30+
name: ruff-format
31+
entry: uv run --group lint ruff format
32+
language: system
33+
types_or: [python, pyi]
34+
require_serial: true
2835

2936
- repo: local
3037
hooks:
3138
- id: synchro
3239
name: synchro
33-
entry: bash ./tools/synchro.sh
34-
language: python
40+
entry: uv run --group unasync ./tools/synchro.py
41+
language: system
42+
require_serial: true
43+
always_run: true
44+
- id: synchro-stage-files
45+
name: synchro-stage-files
46+
entry: bash -c 'if [ -s .synchro-modified ]; then xargs git add < .synchro-modified || true; fi'
47+
language: system
3548
require_serial: true
36-
fail_fast: true
37-
additional_dependencies:
38-
- ruff==0.15.16
39-
- unasync
49+
always_run: true
50+
pass_filenames: false
4051

4152
- repo: https://github.com/adamchainz/blacken-docs
4253
rev: "1.16.0"

doc/changelog.rst

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,14 @@
11
Changelog
22
=========
33

4+
Changes in Version 4.18.0
5+
-------------------------
6+
7+
- Improved TLS connection performance by reusing TLS sessions across connections
8+
to the same server, avoiding a full handshake on each new connection.
9+
Session resumption is supported on all Python versions for synchronous clients
10+
and on Python 3.11+ for async clients.
11+
412
Changes in Version 4.17.0 (2026/04/20)
513
--------------------------------------
614

doc/conf.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -98,9 +98,8 @@
9898
linkcheck_workers = 1
9999
# Give slow redirects more time before retrying.
100100
linkcheck_timeout = 60
101-
102-
# Ignore anchors in links since they may not be added to the page right away.
103-
linkcheck_anchors_ignore_for_url = [r"https://github.com/.*"]
101+
# Ignore anchors in links
102+
linkcheck_anchors = False
104103

105104
# Pass GitHub token to avoid rate-limiting on GitHub links.
106105
if github_token := os.environ.get("GITHUB_TOKEN"):

justfile

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,10 @@ default:
1616
resync:
1717
@uv sync --quiet
1818

19+
[private]
20+
run-synchro:
21+
uv run --group unasync ./tools/synchro.py
22+
1923
# Set up the development environment
2024
install:
2125
bash .evergreen/scripts/setup-dev-env.sh
@@ -66,7 +70,7 @@ lint-manual *args="": && resync
6670

6771
# Run pytest (e.g. just test test/test_uri_parser.py)
6872
[group('test')]
69-
test *args="-v --durations=5 --maxfail=10": && resync
73+
test *args="-v --durations=5 --maxfail=10": run-synchro && resync
7074
#!/usr/bin/env bash
7175
set -euo pipefail
7276
uv run ${USE_ACTIVE_VENV:+--active} --extra test python -m pytest {{args}}
@@ -79,7 +83,7 @@ test-numpy *args="": && resync
7983

8084
# Run tests via the Evergreen test runner script
8185
[group('test')]
82-
run-tests *args: && resync
86+
run-tests *args: run-synchro && resync
8387
bash ./.evergreen/run-tests.sh {{args}}
8488

8589
# Set up the test environment (auth, TLS, etc.)

0 commit comments

Comments
 (0)