-
Notifications
You must be signed in to change notification settings - Fork 30
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add ability to start mongo single replica set #31
Conversation
src/TestEnvironment.Docker.Containers.Mongo/MongoSingleReplicaSetContainer.cs
Outdated
Show resolved
Hide resolved
src/TestEnvironment.Docker.Containers.Mongo/MongoSingleReplicaSetContainer.cs
Outdated
Show resolved
Hide resolved
src/TestEnvironment.Docker.Containers.Mongo/MongoSingleReplicaSetContainerInitializer.cs
Outdated
Show resolved
Hide resolved
@Deffiss, @Hellevar, thanks for your review and comments. Everything is valid and this is exact reason why the PR is in draft state. My initial intention was to introduce a concept for you with a detailed description. Unfortunately, I didn't have time to fill in the description before your review. I'll update the description in few hours and will ping you |
Nobody likes to provide descriptions :) the code looks self-explained and the intend was clear anyway. |
fix usage of default cleaner for both containers: simple and replica set fix replica set reinitialization
Failure message from
Looks like smth is run on 27017 port. From documentation, AppVeyor agents have preinstalled MongoDB. But it shouldn't be run by default. according to the same documentation. Link to documentation: https://www.appveyor.com/docs/services-databases/. |
src/TestEnvironment.Docker.Containers.Mongo/MongoSingleReplicaSetContainerInitializer.cs
Outdated
Show resolved
Hide resolved
You can try to use port binding to avoid the issue. |
As I mentioned, private docker container port should be equal to public docker container port due to the logic of how server selection works.
|
If it works locally, we probably could skip this test until we migrate to GitHub actions if it is not possible to solve the issue. |
It would be nice to fix it due to some other devs can face it in their own CIs. BTW, I've fixed it with custom Mongo DB port. Let's see the output from AppVeyor. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In order to publish new version of Mongo lib we need to increase the version in .csproj
. Could you please do that?
I'll do that. |
@Deffiss, it's also required to increase version of |
All published |
@Deffiss , despite of fact that additional parameter in constructor is backward compatible on source code level, it’s breaking change on binary level. After updating NuGet packages, Elasticsearch container cannot be instantiated. Could you update versions for other projects too, please? |
The goal of changes
Not often, but in some cases, it's needed to bootstrap MongoDB for test purposes in replica set mode. One of the features is change streams.
In addition, to bootstrap MongoDB replica set isn't an easy task and some preparation to use such instance is needed.
"/usr/bin/mongod", "--bind_ip_all", "--replSet", "rs0"
. By this reason I've added opportunity to specify entrypoint32017:27017
port mapping. It means that Mongo DB will be available for use with the32017
port, which works perfectly instandalone
mode due to no need in the server selection mechanism. In case of replica set mode, where selection mechanism is involved, MongoDB established a connection with the client, but after the server, the selection will return27017
port instead of32017
due to such value is placed in replica set configuration. After that client will be disconnected by timeout. This is the exact reason why static hardcoded27017:27017
port mappings are used.GetDirectNodeConnectionString
. After direct connection, replica set must be initialized withreplSetInitiate
command. The logic for replica set initialization is addressed inMongoSingleReplicaSetContainerInitializer
.In addition, the auth mechanism via environment variables doesn't work. More details can be found at docker-library/mongo#339
P.S.: should be merged after #33