Replies: 2 comments
-
To add an additional note on this, If I were to spin up a MongoDb replica set using Docker/Docker compose, I would do the following. Run a
Find out the container Id with a And then connect to the container's mongosh
and run the following
so that it is reachable at I would like the same with testcontainer. Has anyone succeeded? PS: I found this StackOverflow question and I added my findings https://stackoverflow.com/a/78277081/2948212 |
Beta Was this translation helpful? Give feedback.
-
Hi 👋 If a module does not support a feature, it is usually a good idea to look into Java's implementation. Some modules offer more features than their .NET counterparts and vice versa. In this case, AFAIK, Java supports replica sets. I think for proper support, it would be good to align the implementation and add the missing pieces from Java to .NET. |
Beta Was this translation helpful? Give feedback.
-
I have successfully used Ductus.FluentDocker to spin up a mongoDb container with a replica set. This is how I achieved it.
Notice it's in 2 steps, first I start the container with the
mongod
command, and later I initialize the replicaSet withmongosh
instruction.This will spin up a container, and I can access it with connection string
mongodb://mongo:27017/?replicaSet=rs0&ssl=false
Notice the hostname is
mongo
(it could be potato, it doesn't matter) and I have an entry on my /etc/hosts file so that I can use the alias mongo as if it was localhost. That's because initiating the replica set expects the host name.Now the problem is that I would like to achieve the same with TestContainers for MongoDb and I cannot make it work.
The following code gets stuck on starting the container
and if I uncomment the entrypoint part, it throws a timeout exception.
Has anyone managed to have a replica set working with testcontainers? Ideally a single node replica set, which is the minimum necessary for using change streams.
UPDATE:
I found out, if I pass empty username and empty password, it does not get stuck there. But, still, I am unable to have it working
This is the furthest I got, and it fails to initialize the replica set, although the mongoDb container spins up.
Beta Was this translation helpful? Give feedback.
All reactions