Skip to content
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

Feature: fetch mongodb on package install #46

Closed
wingedfox opened this issue Feb 1, 2018 · 9 comments
Closed

Feature: fetch mongodb on package install #46

wingedfox opened this issue Feb 1, 2018 · 9 comments

Comments

@wingedfox
Copy link
Contributor

I've noticed substantial delay in e2e tests due to on-demand mongodb server download.
On the other hand, on-demand download makes testing without internet access almost impossible because we've to mock 3rd-party infrastructure.

It worth to provide a way to have mongodb server as a part of this npm package or add some optional npm dependency (separate package) to take server from.

@nodkz
Copy link
Owner

nodkz commented Feb 1, 2018

Feel free to create mongodb-memory-server-offline package and add it as optionalDependency. Like it did here https://github.com/graphql-compose/graphql-compose-mongoose/blob/30968a23a40d0bdbf90621984e189439eec13711/src/composeWithMongoose.js#L240-L245 with optional package graphql-compose-pagination.

@nodkz
Copy link
Owner

nodkz commented Feb 1, 2018

Or maybe need to find another solution on your side. Cause mongodb-memory-server-offline will be very FAT package if you will add all supported mongodb versions.

Try to add some options which will instruct where to take mongodb bineries offline from your repo. It will be more right way.

@wingedfox
Copy link
Contributor Author

mongo-memory-server-offline package could fetch server during install phase, which will work for virtually everything, except automatic updates. This way package won't be that fat.

@nodkz
Copy link
Owner

nodkz commented Feb 1, 2018

And how it decide which version of mongodb binaries need to install? 3.4, 3.6

@wingedfox
Copy link
Contributor Author

There are 2 options:

  1. provide a release for each mongo build
  2. provide (cli?) interface to fetch necessary build right from dependent npm script using pre-install hook

@nodkz
Copy link
Owner

nodkz commented Feb 1, 2018

Ok, let take 1st case. But rename packages something like:

  • mongo-memory-server-download-3.4
  • mongo-memory-server-download-3.6

Where this packages at pre-install will download needed mongo binary to path.resolve(os.homedir(), '.mongodb-binaries') folder.

@wingedfox
Copy link
Contributor Author

As long as you won't have 2 different versions for any package given it's OK to use path.resolve(os.homedir(), '.mongodb-binaries',version) and reference correct one from mongo-memory-server.

@masudianpour
Copy link

Any update on this issue?

@nodkz
Copy link
Owner

nodkz commented Aug 21, 2018

By default mongodb-memory-server package installs latest version of mongod in postscripts.
If you want a specific version, you should provide it in your test files with proper timeout for test-runner.

Or you may add some script to your package.json which will execute after package installation:

{
  "scripts": {
    "postinstall": "node ./postinstall.js", 
  }
}

Like it did in this file https://github.com/nodkz/mongodb-memory-server/blob/master/postinstall.js

@nodkz nodkz closed this as completed Aug 21, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants