fix(mongodb): add MongoDBAtlasLocalContainer for Atlas Search and Vector Search testing#1010
Open
caseyclements wants to merge 3 commits intotestcontainers:mainfrom
Open
fix(mongodb): add MongoDBAtlasLocalContainer for Atlas Search and Vector Search testing#1010caseyclements wants to merge 3 commits intotestcontainers:mainfrom
caseyclements wants to merge 3 commits intotestcontainers:mainfrom
Conversation
Add a testcontainer for MongoDB Atlas Local (mongodb/mongodb-atlas-local), which provides a local Atlas environment with Atlas Search and Vector Search. - Extends DockerContainer directly (no auth required) - Uses ExecWaitStrategy with 'runner healthcheck' for readiness - Connection string includes directConnection=true - Includes integration tests for insert/query and connection string format
…alContainer - Add test_vector_search using deterministic hash-based mock embeddings - indexed_collection fixture: inserts docs, creates vector index, polls until all documents are indexed (handles OperationFailure during init) - Asserts top_k limiting, exact-match ranking, and score range Signed-off-by: Casey Clements <casey.clements@mongodb.com>
- Add autoclass directive in modules/mongodb/README.rst - Update docs/modules/mongodb.md to describe both container classes Signed-off-by: Casey Clements <casey.clements@mongodb.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
New Container
Fixes MongoDB JIRA ticket INTPYTHON-922
Summary
Adds
MongoDBAtlasLocalContainerto the existingmongodbmodule, enabling local testing of MongoDB Atlas-specific features such as Atlas Search and Atlas Vector Search.The container uses the
mongodb/mongodb-atlas-localDocker image, which provides a fully functional local MongoDB Atlas deployment including a single-node replica set and the MongoT search indexing service.What's included
MongoDBAtlasLocalContainerclass inmodules/mongodb/testcontainers/mongodb/__init__.pyExecWaitStrategy(["runner", "healthcheck"])for reliable startup detectionget_connection_string()returns amongodb://host:port/?directConnection=trueURIget_connection_client()returns a connectedpymongo.MongoClientmodules/mongodb/tests/test_mongodb.pytest_docker_run_mongodb_atlas_local)test_mongodb_atlas_local_connection_string)test_vector_search) — creates a vector index, waits for indexing, and queries with$vectorSearchMongoDBAtlasLocalContainerautoclass directivePR Checklist
fix(mongodb): add MongoDBAtlasLocalContainer for Atlas Search and Vector Search testingmodules/*modules/mongodbmodule (not a new module)testcontainers.mongodb.*__init__.pyabove module levelmodules/mongodb/testspyproject.tomlmongodbmodulepymongo>=4optional dependencyPreferred implementation
This implementation follows the maintainer preference of minimal dependencies:
pymongowhich is already an optional dependency of themongodbmoduleExecWaitStrategy(["runner", "healthcheck"])(matching the health check approach used by testcontainers-java's Atlas module) rather than log-based detectionhashlib-based mock embedding function — no numpy or ML library dependencies