You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Feature: mongodb as replica set (single node) #640
mongomock can often be used in unit testing of mongodb-related functionality. It's faster and easier than using docker containers for such tests. But perhaps one of the most important scenarios in which mongomock is not applicable is testing the functionality using MongoDB transactions. At the moment, transaction mocking is not implemented in mongomock. But even if support for this was implemented there, such sensitive functionality (using transactions) would like to be checked "naturally". But as you know, transactions are possible only for replica sets, which the default MongoDB container is not. It is possible to configure mongodb as a replicaset (although with one node, but I think this is not critical for testing).
If you find this functionality useful here in the public, I can provide a PR (either as a separate Mongodb container, or extend the current MongoDbContainer with configuration options). What do you think about it?
Reacted by Naol Arega, krisnashaypp, Matt Menzenski, Amit Sadafule, Sachin Kumar Rawani, Gordiig, ilian and Jorge Gómez Zarzosa
mongodb replica set can be set with mongo_container.with_command("--replSet=rs"). but it makes it impossible to set since auth is forced internally and replica set with auth requires a key File. it would be great if the auth is optional.
@naolaregaqena can you comment with an example of using the streams for something? this way i can add a test to the pull request for this feature and add it to the library.
Activity
alexanderankin commentedon Jul 6, 2024
that would be great! also would be cool to have streaming, i think also only available with replica sets.
naolaregaqena commentedon Aug 17, 2024
mongodb replica set can be set with
mongo_container.with_command("--replSet=rs"). but it makes it impossible to set since auth is forced internally and replica set with auth requires a key File. it would be great if the auth is optional.naolaregaqena commentedon Aug 17, 2024
there is a work around to it
alexanderankin commentedon Aug 17, 2024
@naolaregaqena can you comment with an example of using the streams for something? this way i can add a test to the pull request for this feature and add it to the library.
naolaregaqena commentedon Aug 18, 2024
@alexanderankin stream also works too, you could use motor like so
gpkc commentedon Dec 6, 2024
Linking the .NET implementation of
WithReplicaSet():testcontainers/testcontainers-dotnet#1196
feat: support MongoDB replica set (#1092)