Skip to content

Commit 217a0b7

Browse files
committed
Move Rust testing documentation to main README
All Evergreen CI testing documentation for the Rust extension has been consolidated into the main README.md in the Rust Extension section. - Removed .evergreen/RUST_TESTING.md - Added comprehensive Evergreen CI testing section to README.md - Includes test configuration, environment variables, execution flow - Includes troubleshooting guide and instructions for adding new tests
1 parent 3ef42b9 commit 217a0b7

2 files changed

Lines changed: 86 additions & 145 deletions

File tree

.evergreen/RUST_TESTING.md

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

README.md

Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -627,4 +627,90 @@ For implementation details, see the source code at `bson/_rbson/src/lib.rs`. Key
627627

628628
**Investigation Complete:** The Rust extension successfully demonstrates that Rust is a viable alternative to C for Python extensions, with the trade-off being development complexity vs. performance. The investigation has identified the exact architectural differences that cause the performance gap and the effort required to close it.
629629

630+
### Evergreen CI Testing
631+
632+
The Rust BSON extension is automatically tested in Evergreen CI to ensure 100% compatibility with the C extension across all supported platforms and Python versions.
633+
634+
#### Test Configuration
635+
636+
**Automated Tests run on:**
637+
638+
1. **Linux (RHEL 8)** - Primary platform, runs on every PR
639+
- Python 3.10 on standalone (noauth-nossl) - **PR task**
640+
- Python 3.12 on replica_set (noauth-ssl)
641+
- Python 3.14 on sharded_cluster (auth-ssl)
642+
643+
2. **macOS ARM64** - Weekly batch
644+
- Same Python versions and topologies as Linux
645+
- Important for M1/M2 Mac compatibility
646+
647+
3. **Windows** - Weekly batch
648+
- Same Python versions and topologies as Linux
649+
- Important for cross-platform compatibility
650+
651+
#### Environment Variables
652+
653+
The following environment variables control Rust extension building and testing:
654+
655+
- `PYMONGO_BUILD_RUST=1` - Build the Rust extension during installation
656+
- `PYMONGO_USE_RUST=1` - Use the Rust extension for BSON operations
657+
658+
These are automatically set by the Evergreen configuration for Rust test tasks.
659+
660+
#### Test Execution Flow
661+
662+
1. **Setup Phase** (`.evergreen/scripts/setup-tests.sh`)
663+
- Detects `PYMONGO_BUILD_RUST` environment variable
664+
- Installs Rust toolchain via `.evergreen/scripts/install-rust.sh`
665+
- Installs maturin (Rust-Python build tool)
666+
667+
2. **Build Phase**
668+
- PyMongo is installed with `PYMONGO_BUILD_RUST=1`
669+
- This triggers the Rust extension build via `build.py`
670+
- The Rust extension is compiled and installed alongside the C extension
671+
672+
3. **Test Phase** (`.evergreen/scripts/run-tests.sh`)
673+
- Tests run with `PYMONGO_USE_RUST=1`
674+
- This causes PyMongo to use the Rust extension instead of C
675+
- Full BSON test suite runs to ensure 100% compatibility
676+
677+
#### Test Coverage
678+
679+
The Rust extension tests run the full BSON test suite (`test/test_bson.py`) which includes:
680+
681+
- All BSON types (int, string, document, array, binary, ObjectId, datetime, etc.)
682+
- Edge cases and error handling
683+
- Encoding/decoding round-trips
684+
- Codec options and type preservation
685+
- Performance characteristics
686+
687+
#### Adding New Rust Tests
688+
689+
To add new test configurations:
690+
691+
1. Edit `.evergreen/scripts/generate_config.py`
692+
2. Modify `create_rust_extension_tasks()` to add new Python versions or topologies
693+
3. Modify `create_rust_extension_variants()` to add new platforms
694+
4. Run `python .evergreen/scripts/generate_config.py` to regenerate configs
695+
5. Commit the changes to `.evergreen/generated_configs/`
696+
697+
#### Troubleshooting CI Tests
698+
699+
**Rust Not Found:**
700+
- Check that `.evergreen/scripts/install-rust.sh` is executable
701+
- Verify the script runs successfully in the setup phase
702+
- Check Evergreen logs for Rust installation errors
703+
704+
**Build Failures:**
705+
- Check that maturin is installed (`maturin --version`)
706+
- Verify Rust toolchain is up to date (`rustc --version`)
707+
- Check for compilation errors in the build logs
708+
- Ensure PyO3 dependencies are compatible
709+
710+
**Test Failures:**
711+
- Verify `PYMONGO_USE_RUST=1` is set
712+
- Check that the Rust extension is actually loaded (run `just rust-check`)
713+
- Compare behavior with C extension (run tests without `PYMONGO_USE_RUST`)
714+
- Check for platform-specific issues (endianness, pointer size, etc.)
715+
630716
---

0 commit comments

Comments
 (0)