I am wondering what the community would most recommend for a problem I’m having with setting up a sandbox environment for our team.
Currently, we use two separate MongoDB instances, both 3 member replica sets, for our test and deployment environment respectively. It’s pretty much understood internally that all the data in the test environment is largely throwaway and is just created by the developers in the course of unit testing the application.
I’d like to give the development team the new option of testing with the real live data, but in a separate safe sandbox instance. At first, I initially thought that I could just use the copyDatabase command to dupe the data nightly into a new database and connect the individual developer app servers to this database. The problem is that there is a ton of GridFS data in the system, and duplicating like this wastes a ton of disk i/o, and we’re running in smaller cloud instances.
I’m wary of going this route, especially if there is a better suited alternative.
Is it possible, for instance, to setup a fourth member of the deployment replica set that only ever operates as a slave, set all queries to slaveOkay = True and run tests against that individual node? Would this propagate back to the other members? How would inserts be handled?
What I am suggesting may be impractical, especially if the transfer had to cross the network where it would also waste network transfer. Has anyone ever had to solve a similar problem? Thanks!
Slaves are only for reading. All writes must go to master. This rules out your “fourth slave” option.
As for testing purposes, do you really need exact copy of the database, with all gridfs data? I’d try to copy only a relevant portion of “heavy” data. This rules out
db.copyDatabase()🙂 Do amongodump/mongorestoreinstead.Also, I’d like to point out that test db and staging db should be different databases. Test db is used for unit tests (with mocked/generated data). Staging db is populated with production data and is used for integration/acceptance testing.