package: mongo-memory-server
I understood that it is possible to configure mongodb-memory-server to download binaries on npm install instead on the first test run. But I don't understand the config parameters.
Is "disablePostinstall" the parameter I am looking for? If yes, what is the right value to make it download the binaries on npm install? If not, which one is it then?
Thanks ins advance!
Cheers
Fred
the only package that dosnt download anything on npm-install is mongo-memory-server-core, all other download on npm-install by default, it can be disabled with disablePostinstall
Thank you for your reply! This information helped me to fix the issue :-)
It was a bit confusing to me, because I'm using "mongodb-memory-server": "^6.6.3" as a dev dependency and yesterday mocha failed all tests that used mongodb-memory-server. After I raised the execution time as described in the mms docs, it ran through successfully. The subsequent runs succeeded without the higher execution time. So I suspected that all versions download the binaries at first test run. But I figured out that my configuration made it do it.
On install, mms ^6.6.3 downloads MongoDB 4.0.14.
In my script I had specified version 4.2.8 via an env variable:
process.env.MONGOMS_DOWNLOAD_URL = 'https://fastdl.mongodb.org/linux/mongodb-linux-x86_64-ubuntu1804-4.2.8.tgz'
process.env.MONGOMS_VERSION = '4.2.8'
...
this.mongod = new MongoMemoryServer()
So when the first test run started, it tried to download 4.2.8 but failed because of the timeout.
Now I have specified the version and download url in the package.json like this:
{
"config": {
"mongodbMemoryServer": {
"platform": "linux",
"arch": "x64",
"version": "4.2.8",
"md5Check": "1"
}
}
}
Now it's correctly downloading 4.2.8 post install and the first test run succeeds :-)
Thank you again!
Two questions though:
Background: I'm trying to use exactly the same version for testing with mms as I'm using in production.
why is mms downloading an outdated version of mongo?
this version just never got updated again, because it could break some things on an version upgrade - i think it will be returned to "latest" or updated to the latest available version at the time when the next major update (7.0.0) comes
is it possible to specify the downloaded version like i specify node dependencies?
when you mean as in semver, no, the values given are directly added to the url, and not processed any further
-> i already thought about adding something like an wildcard (*), but for that the version generation would need to be rewritten and some steps added
I'm trying to use exactly the same version for testing with mms as I'm using in production.
yes its tricky to get the same version if not using an ubuntu based distro, because the version url is not the same
(example: linux mint will default back to the ubuntu binary, and all other ubuntu based distros that are added)
Cool, thanks a lot for the clarification :-)
Wildcards would be great. In production, I use the "mongo:4.2-bionic" docker image, so for mms it would be great if I could specify "4.2.*" or just "4.2".
I guess using the latest tag would break a lot of existing tests if mongo has breaking changes. It would already help to make the docs more specific about what is happening behind the scenes and how to do the configuration right.
Right now it says about "mongodb-memory-server": "Auto-downloads the latest mongod binary on npm install to: node_modules/.cache/mongodb-binaries." (emphasis is mine) Which I learned is not correct.
Another thing that confused me is that the heading "Configuring which mongod binary to use" is on the same level as the headings of the three flavors of mms, so I thought that this was the go-to configuration option for all of the three. But using env actually breaks the benefit of the flavors that download post-install. It would be great to have a hint about the preferred way of configuration for each of the 3 flavors of mms.
Right now it says about "mongodb-memory-server": "Auto-downloads the latest mongod binary on npm install to: node_modules/.cache/mongodb-binaries." (emphasis is mine) Which I learned is not correct.
yes, this is definitely wrong, could you point me to where this is said?
Configuring which mongod binary to use
yes, this needs addition of in-code and package.json definitions
yes, this is definitely wrong, could you point me to where this is said?
--> here https://github.com/nodkz/mongodb-memory-server/#mongodb-memory-server and here https://github.com/nodkz/mongodb-memory-server/#mongodb-memory-server-global
Most helpful comment
the only package that dosnt download anything on npm-install is
mongo-memory-server-core, all other download on npm-install by default, it can be disabled withdisablePostinstall