Skip to content

Commit 4a64a28

Browse files
committed
Integrate Rust extension testing into existing test infrastructure
- Remove separate Rust-specific test workflows and scripts - Add Rust environment variables (PYMONGO_BUILD_RUST, PYMONGO_USE_RUST) to Evergreen test functions - Replace separate Rust variants with variants that run existing standard tests with Rust enabled - Add Rust extension testing to GitHub Actions build job via matrix dimension - Rust extensions now tested alongside C extensions using same test tasks
1 parent 1813409 commit 4a64a28

7 files changed

Lines changed: 40 additions & 420 deletions

File tree

.evergreen/generated_configs/functions.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,8 @@ functions:
111111
- LOAD_BALANCER
112112
- LOCAL_ATLAS
113113
- NO_EXT
114+
- PYMONGO_BUILD_RUST
115+
- PYMONGO_USE_RUST
114116
type: test
115117
- command: expansions.update
116118
params:
@@ -152,6 +154,8 @@ functions:
152154
- IS_WIN32
153155
- REQUIRE_FIPS
154156
- TEST_MIN_DEPS
157+
- PYMONGO_BUILD_RUST
158+
- PYMONGO_USE_RUST
155159
type: test
156160
- command: subprocess.exec
157161
params:

.evergreen/generated_configs/tasks.yml

Lines changed: 0 additions & 78 deletions
Original file line numberDiff line numberDiff line change
@@ -2611,84 +2611,6 @@ tasks:
26112611
- func: send dashboard data
26122612
tags: [perf]
26132613

2614-
# Rust extension tests
2615-
- name: test-rust-latest-python3.10-noauth-nossl-standalone
2616-
commands:
2617-
- func: run server
2618-
vars:
2619-
AUTH: noauth
2620-
SSL: nossl
2621-
TOPOLOGY: standalone
2622-
VERSION: latest
2623-
PYMONGO_BUILD_RUST: "1"
2624-
PYMONGO_USE_RUST: "1"
2625-
- func: run tests
2626-
vars:
2627-
AUTH: noauth
2628-
SSL: nossl
2629-
TOPOLOGY: standalone
2630-
VERSION: latest
2631-
PYMONGO_BUILD_RUST: "1"
2632-
PYMONGO_USE_RUST: "1"
2633-
TOOLCHAIN_VERSION: "3.10"
2634-
TEST_NAME: default_sync
2635-
tags:
2636-
- test-rust
2637-
- python-3.10
2638-
- standalone-noauth-nossl
2639-
- rust
2640-
- pr
2641-
- name: test-rust-latest-python3.12-noauth-ssl-replica-set
2642-
commands:
2643-
- func: run server
2644-
vars:
2645-
AUTH: noauth
2646-
SSL: ssl
2647-
TOPOLOGY: replica_set
2648-
VERSION: latest
2649-
PYMONGO_BUILD_RUST: "1"
2650-
PYMONGO_USE_RUST: "1"
2651-
- func: run tests
2652-
vars:
2653-
AUTH: noauth
2654-
SSL: ssl
2655-
TOPOLOGY: replica_set
2656-
VERSION: latest
2657-
PYMONGO_BUILD_RUST: "1"
2658-
PYMONGO_USE_RUST: "1"
2659-
TOOLCHAIN_VERSION: "3.12"
2660-
TEST_NAME: default_sync
2661-
tags:
2662-
- test-rust
2663-
- python-3.12
2664-
- replica_set-noauth-ssl
2665-
- rust
2666-
- name: test-rust-latest-python3.14-auth-ssl-sharded-cluster
2667-
commands:
2668-
- func: run server
2669-
vars:
2670-
AUTH: auth
2671-
SSL: ssl
2672-
TOPOLOGY: sharded_cluster
2673-
VERSION: latest
2674-
PYMONGO_BUILD_RUST: "1"
2675-
PYMONGO_USE_RUST: "1"
2676-
- func: run tests
2677-
vars:
2678-
AUTH: auth
2679-
SSL: ssl
2680-
TOPOLOGY: sharded_cluster
2681-
VERSION: latest
2682-
PYMONGO_BUILD_RUST: "1"
2683-
PYMONGO_USE_RUST: "1"
2684-
TOOLCHAIN_VERSION: "3.14"
2685-
TEST_NAME: default_sync
2686-
tags:
2687-
- test-rust
2688-
- python-3.14
2689-
- sharded_cluster-auth-ssl
2690-
- rust
2691-
26922614
# Search index tests
26932615
- name: test-search-index-helpers
26942616
commands:

.evergreen/generated_configs/variants.yml

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -477,32 +477,32 @@ buildvariants:
477477
expansions:
478478
SUB_TEST_NAME: pyopenssl
479479

480-
# Rust extension tests
481-
- name: test-rust-extension
480+
# Rust tests
481+
- name: test-with-rust-extension
482482
tasks:
483-
- name: .test-rust
484-
display_name: Test Rust Extension
483+
- name: .test-standard .server-latest .pr
484+
display_name: Test with Rust Extension
485485
run_on:
486486
- rhel87-small
487487
expansions:
488488
PYMONGO_BUILD_RUST: "1"
489489
PYMONGO_USE_RUST: "1"
490490
tags: [rust, pr]
491-
- name: test-rust-extension---macos-arm64
491+
- name: test-with-rust-extension---macos-arm64
492492
tasks:
493-
- name: .test-rust !.pr
494-
display_name: Test Rust Extension - macOS ARM64
493+
- name: .test-standard .server-latest !.pr
494+
display_name: Test with Rust Extension - macOS ARM64
495495
run_on:
496496
- macos-14-arm64
497497
batchtime: 10080
498498
expansions:
499499
PYMONGO_BUILD_RUST: "1"
500500
PYMONGO_USE_RUST: "1"
501501
tags: [rust]
502-
- name: test-rust-extension---windows
502+
- name: test-with-rust-extension---windows
503503
tasks:
504-
- name: .test-rust !.pr
505-
display_name: Test Rust Extension - Windows
504+
- name: .test-standard .server-latest !.pr
505+
display_name: Test with Rust Extension - Windows
506506
run_on:
507507
- windows-64-vsMulti-small
508508
batchtime: 10080

.evergreen/run-rust-tests.sh

Lines changed: 0 additions & 109 deletions
This file was deleted.

.evergreen/scripts/generate_config.py

Lines changed: 14 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -1195,6 +1195,8 @@ def create_run_server_func():
11951195
"LOAD_BALANCER",
11961196
"LOCAL_ATLAS",
11971197
"NO_EXT",
1198+
"PYMONGO_BUILD_RUST",
1199+
"PYMONGO_USE_RUST",
11981200
]
11991201
args = [".evergreen/just.sh", "run-server", "${TEST_NAME}"]
12001202
sub_cmd = get_subprocess_exec(include_expansions_in_env=includes, args=args)
@@ -1228,6 +1230,8 @@ def create_run_tests_func():
12281230
"IS_WIN32",
12291231
"REQUIRE_FIPS",
12301232
"TEST_MIN_DEPS",
1233+
"PYMONGO_BUILD_RUST",
1234+
"PYMONGO_USE_RUST",
12311235
]
12321236
args = [".evergreen/just.sh", "setup-tests", "${TEST_NAME}", "${SUB_TEST_NAME}"]
12331237
setup_cmd = get_subprocess_exec(include_expansions_in_env=includes, args=args)
@@ -1289,60 +1293,15 @@ def create_send_dashboard_data_func():
12891293
return "send dashboard data", cmds
12901294

12911295

1292-
def create_rust_extension_tasks():
1293-
"""Create tasks for testing the Rust BSON extension."""
1294-
tasks = []
1295-
# Test Rust extension on a subset of Python versions and topologies
1296-
# Focus on min, max, and latest stable Python versions
1297-
test_pythons = [MIN_MAX_PYTHON[0], "3.12", MIN_MAX_PYTHON[-1]]
1298-
1299-
for python, topology in zip_cycle(
1300-
test_pythons, ["standalone", "replica_set", "sharded_cluster"]
1301-
):
1302-
if "t" in python:
1303-
# Skip free-threaded Python for now (Rust extension may need updates)
1304-
continue
1305-
1306-
auth, ssl = get_standard_auth_ssl(topology)
1307-
tags = [
1308-
"test-rust",
1309-
f"python-{python}",
1310-
f"{topology}-{auth}-{ssl}",
1311-
"rust",
1312-
]
1313-
1314-
# Add PR tag for one configuration to run on every PR (Python 3.10 on standalone)
1315-
if python == MIN_MAX_PYTHON[0] and topology == "standalone":
1316-
tags.append("pr")
1317-
1318-
expansions = dict(
1319-
AUTH=auth,
1320-
SSL=ssl,
1321-
TOPOLOGY=topology,
1322-
VERSION="latest",
1323-
PYMONGO_BUILD_RUST="1",
1324-
PYMONGO_USE_RUST="1",
1325-
)
1326-
1327-
name = get_task_name("test-rust", python=python, **expansions)
1328-
server_func = FunctionCall(func="run server", vars=expansions)
1329-
test_vars = expansions.copy()
1330-
test_vars["TOOLCHAIN_VERSION"] = python
1331-
test_vars["TEST_NAME"] = "default_sync"
1332-
test_func = FunctionCall(func="run tests", vars=test_vars)
1333-
tasks.append(EvgTask(name=name, tags=tags, commands=[server_func, test_func]))
1334-
1335-
return tasks
1336-
1337-
1338-
def create_rust_extension_variants():
1339-
"""Create build variants for testing the Rust BSON extension."""
1296+
def create_rust_variants():
1297+
"""Create build variants that test with Rust extension alongside C extension."""
13401298
variants = []
13411299

1342-
# Test on Linux (primary platform) - runs on PRs
1300+
# Test Rust on Linux (primary platform) - runs on PRs
1301+
# Run standard tests with Rust enabled (both sync and async)
13431302
variant = create_variant(
1344-
[".test-rust"],
1345-
"Test Rust Extension",
1303+
[".test-standard .server-latest .pr"],
1304+
"Test with Rust Extension",
13461305
host=DEFAULT_HOST,
13471306
tags=["rust", "pr"],
13481307
expansions=dict(
@@ -1354,8 +1313,8 @@ def create_rust_extension_variants():
13541313

13551314
# Test on macOS ARM64 (important for M1/M2 Macs)
13561315
variant = create_variant(
1357-
[".test-rust !.pr"],
1358-
"Test Rust Extension - macOS ARM64",
1316+
[".test-standard .server-latest !.pr"],
1317+
"Test with Rust Extension - macOS ARM64",
13591318
host=HOSTS["macos-arm64"],
13601319
tags=["rust"],
13611320
batchtime=BATCHTIME_WEEK,
@@ -1368,8 +1327,8 @@ def create_rust_extension_variants():
13681327

13691328
# Test on Windows (important for cross-platform compatibility)
13701329
variant = create_variant(
1371-
[".test-rust !.pr"],
1372-
"Test Rust Extension - Windows",
1330+
[".test-standard .server-latest !.pr"],
1331+
"Test with Rust Extension - Windows",
13731332
host=HOSTS["win64"],
13741333
tags=["rust"],
13751334
batchtime=BATCHTIME_WEEK,

.github/workflows/test-python.yml

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,8 +61,13 @@ jobs:
6161
os: [ubuntu-latest]
6262
python-version: ["3.10", "pypy-3.11", "3.13t"]
6363
mongodb-version: ["8.0"]
64+
extension: ["c", "rust"]
65+
exclude:
66+
# Don't test Rust with pypy
67+
- python-version: "pypy-3.11"
68+
extension: "rust"
6469

65-
name: CPython ${{ matrix.python-version }}-${{ matrix.os }}
70+
name: CPython ${{ matrix.python-version }}-${{ matrix.os }}-${{ matrix.extension }}
6671
steps:
6772
- uses: actions/checkout@v6
6873
with:
@@ -72,12 +77,18 @@ jobs:
7277
with:
7378
enable-cache: true
7479
python-version: ${{ matrix.python-version }}
80+
- name: Install Rust toolchain
81+
if: matrix.extension == 'rust'
82+
uses: dtolnay/rust-toolchain@stable
7583
- id: setup-mongodb
7684
uses: mongodb-labs/drivers-evergreen-tools@master
7785
with:
7886
version: "${{ matrix.mongodb-version }}"
7987
- name: Run tests
8088
run: uv run --extra test pytest -v
89+
env:
90+
PYMONGO_BUILD_RUST: ${{ matrix.extension == 'rust' && '1' || '' }}
91+
PYMONGO_USE_RUST: ${{ matrix.extension == 'rust' && '1' || '' }}
8192

8293
coverage:
8394
# This enables a coverage report for a given PR, which will be augmented by

0 commit comments

Comments
 (0)