feat(modules.mongodb): add replica set support via opts#2469
Merged
mdelapenya merged 3 commits intotestcontainers:mainfrom May 8, 2024
Merged
feat(modules.mongodb): add replica set support via opts#2469mdelapenya merged 3 commits intotestcontainers:mainfrom
mdelapenya merged 3 commits intotestcontainers:mainfrom
Conversation
✅ Deploy Preview for testcontainers-go ready!
To edit notification comments on pull requests, go to your Netlify site configuration. |
Contributor
Author
|
Some differences between this PR and #2139 include:
|
mdelapenya
reviewed
May 7, 2024
504cd35 to
4e6248c
Compare
mdelapenya
reviewed
May 8, 2024
mdelapenya
reviewed
May 8, 2024
4e6248c to
fa37148
Compare
The `WithReplicaSet` option configures the MongoDB container to run a single-node replica set named "rs". The container will wait until the replica set is ready.
fa37148 to
e6bc11e
Compare
mdelapenya
approved these changes
May 8, 2024
|
|
||
| E.g. `testcontainers.WithPassword("mymongopwd")`. | ||
|
|
||
| #### WithReplicaSet |
Member
There was a problem hiding this comment.
@heiytor I went ahead and added the docs for the new option: https://deploy-preview-2469--testcontainers-go.netlify.app/modules/mongodb/#withreplicaset
Once the CI passes, I'll merge this one, thanks!
mdelapenya
added a commit
to bearrito/testcontainers-go
that referenced
this pull request
Jun 11, 2024
* main: (48 commits) Fix race condition when looking up reaper (ryuk) container (testcontainers#2508) chore: bring golangci-lint back (testcontainers#2571) docs(compose): Fix typo docker compose docs (testcontainers#2565) Handle error properly during port forwarding initialization. (testcontainers#2550) chore: pin vearch version (testcontainers#2568) feat: add vearch module (testcontainers#2560) chore: run tests against latest Docker engine, nightly (testcontainers#2566) chore(deps): bump mkdocs-include-markdown-plugin from 6.0.4 to 6.0.7 (testcontainers#2562) Fix network accessor for port-forwarding feature (testcontainers#2551) --- (testcontainers#2549) fix: update search bar eval in mkdocs (testcontainers#2547) docs: improve contributing docs for code snippets (testcontainers#2546) chore: use a virtualenv for working with the docs site (testcontainers#2545) docs: document test session semantics (testcontainers#2544) feat(ryuk): allow to configure ryuk timeouts using env variables (testcontainers#2541) docs: fix CircleCI docs (testcontainers#2539) fix: add import to module generation (testcontainers#2537) chore: prepare for next minor development cycle (0.32.0) chore: use new version (v0.31.0) in modules and examples feat(mongodb): add replica set support via opts (testcontainers#2469) ...
ttruongatl
pushed a commit
to ttruongatl/testcontainers-go
that referenced
this pull request
Feb 15, 2025
* feat(mongodb): add WithReplicaSet option The `WithReplicaSet` option configures the MongoDB container to run a single-node replica set named "rs". The container will wait until the replica set is ready. * docs: document the new option * fix: proper indent --------- Co-authored-by: Manuel de la Peña <[email protected]>
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.
What does this PR do?
Implementing a
WithReplicaSetfunction to configure the container to run with a default single-node replica set named "rs". This function appends "--replSet rs" toreq.Cmdto initialize MongoDB in preparation to receive a replica set. Additionally, after execution, it initializes the replica set using "rs.initiate()", configuring the current host as the PRIMARY.Why is it important?
I've been utilizing testcontainers to test my service environment, which necessitates a replica set to execute transactions. As I've developed this functionality for internal use, I believe it would be beneficial to others as well.
Related issues
This PR closes #2138. Additionally, I noticed that there is another PR, #2139, which also aims to implement this feature. However, it has not been updated for a while, and this branch has certain differences, such as utilizing both
mongoshandmongoto ensure version compatibility.How to test this PR
I've tested this in a production environment, so it should work fine. Additionally, I've added new test cases to
TestMongoDB.Follow-ups
Maybe adding a sharding option would be great.