Configuration for mongoDB replicaset

Hey!

I need to setup a mongodb replicaSet in travisci, so that I can test mongodb transactions within my repository.

So far there seems to be very few examples of how this should be done. So far I have only found:

https://georgeshank.com/how-to-enable-a-mongodb-replica-set-on-travis/

But it leans on using sleep methods for replicaset setup, which I find little hackish/unreliable. I would have thought that somebody would have more sophisticated method after 5 years.

Same applies to another repo:


Or little bit never version (which probably eliminates sleeps by doing something else meanwhile)

Any guidance? What should I do?

Naturally, a reliable way is to wait for some concrete condition instead that would indicate that the desired moment has come.

So it boils down to how to wait for

Alternatively, something probably appears in the MongoDB server’s log once each of those operations is complete – so you can watch that instead. Although in this case, you’ll be relying on the set and content of log messages – which is probably undocumented and subject to change without notice and between versions as well as dependent on server settings.

I think it might boil down to this in before script:

mongo --eval 'rs.initiate({_id:"rs0", members: [{"_id":1, "host":"localhost:27017"},{"_id":2, "host":"localhost:27018"},{"_id":3, "host":"localhost:27019"}]})'

And maybe then loop
mongo --eval 'rs.status()

Until there is a satisfactory end result.