typegoose / mongodb-memory-server

Manage & spin up mongodb server binaries with zero(or slight) configuration for tests.
https://typegoose.github.io/mongodb-memory-server/
MIT License
2.61k stars 187 forks source link

Can't run mongodb memory server, instance closed with code "127" #480

Closed me-nkr closed 3 years ago

me-nkr commented 3 years ago

Versions

package: mongo-memory-server

What is your question?

when I write this following code

const mongod = await new MongoMemoryServer() ;
console.log(await mongod.getUri());
await mongod.stop() ;

I get the following error

MongoMS:MongoMemoryServer Called MongoMemoryServer.ensureInstance() method +0ms
  MongoMS:MongoMemoryServer  - no running instance, call `start()` command +2ms
  MongoMS:MongoMemoryServer Called MongoMemoryServer.start() method +1ms
  MongoMS:MongoMemoryServer starting with port 36887, since undefined was locked: 36887 +15ms
  MongoMS:MongoMemoryServer Starting MongoDB instance with following options: {"port":36887,"dbName":"b5e2a186-5445-4fd3-b2ad-47f7f5761932","ip":"127.0.0.1","storageEngine":"ephemeralForTest","dbPath":"/tmp/mongo-mem--6991-2czqRh3CtUpp","tmpDir":{"name":"/tmp/mongo-mem--6991-2czqRh3CtUpp"},"uri":"mongodb://127.0.0.1:36887/b5e2a186-5445-4fd3-b2ad-47f7f5761932?"} +7ms
  MongoMS:MongoBinary MongoBinary options: {
  "downloadDir": "/home/ubuntu/Projects/Web/CowinTracker/server/node_modules/.cache/mongodb-memory-server/mongodb-binaries",
  "platform": "linux",
  "arch": "arm64",
  "version": "4.0.14",
  "checkMD5": false
} +0ms
  MongoMS:MongoBinary MongoBinary: Download lock removed +17ms
  MongoMS:MongoBinary MongoBinary: Mongod binary path: "/home/ubuntu/Projects/Web/CowinTracker/server/node_modules/.cache/mongodb-memory-server/mongodb-binaries/4.0.14/mongod" +2ms
  MongoMS:MongoInstance Mongo[36887]: Called MongoInstance._launchKiller(parent: 6991, child: 7002): +0ms
  MongoMS:MongoInstance Mongo[36887]: STDERR: /home/ubuntu/Projects/Web/CowinTracker/server/node_modules/.cache/mongodb-memory-server/mongodb-binaries/4.0.14/mongod: error while loading shared libraries: libcrypto.so.1.0.0: cannot open shared object file: No such file or directory
  MongoMS:MongoInstance  +33ms
  MongoMS:MongoInstance Mongo[36887]: Mongod instance closed with an non-0 code! +6ms
  MongoMS:MongoInstance Mongo[36887]: CLOSE: 127 +1ms
  MongoMS:MongoInstance Mongo[36887]: MongodbInstance: Instance has failed: Mongod instance closed with code "127" +1ms
(node:6991) UnhandledPromiseRejectionWarning: Mongod instance closed with code "127"
(Use `node --trace-warnings ...` to show where the warning was created)
(node:6991) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 1)
(node:6991) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
  MongoMS:MongoInstance Mongo[36887]: [MongoKiller]: exit - [null,"SIGTERM"] +12ms

then I made symlinks for libssl1.1 as libssl.so.1.0.0 and libcrypto.so.1.1 as libcrypto.so.1.0.0, and I got

MongoMS:MongoMemoryServer Called MongoMemoryServer.ensureInstance() method +0ms
  MongoMS:MongoMemoryServer  - no running instance, call `start()` command +2ms
  MongoMS:MongoMemoryServer Called MongoMemoryServer.start() method +1ms
  MongoMS:MongoMemoryServer starting with port 44329, since undefined was locked: 44329 +15ms
  MongoMS:MongoMemoryServer Starting MongoDB instance with following options: {"port":44329,"dbName":"87b2273b-5395-4ce7-96e9-2e308dda8490","ip":"127.0.0.1","storageEngine":"ephemeralForTest","dbPath":"/tmp/mongo-mem--6748-z6u2mT0Nh6K5","tmpDir":{"name":"/tmp/mongo-mem--6748-z6u2mT0Nh6K5"},"uri":"mongodb://127.0.0.1:44329/87b2273b-5395-4ce7-96e9-2e308dda8490?"} +6ms
  MongoMS:MongoBinary MongoBinary options: {
  "downloadDir": "/home/ubuntu/Projects/Web/CowinTracker/server/node_modules/.cache/mongodb-memory-server/mongodb-binaries",
  "platform": "linux",
  "arch": "arm64",
  "version": "4.0.14",
  "checkMD5": false
} +0ms
  MongoMS:MongoBinary MongoBinary: Download lock removed +17ms
  MongoMS:MongoBinary MongoBinary: Mongod binary path: "/home/ubuntu/Projects/Web/CowinTracker/server/node_modules/.cache/mongodb-memory-server/mongodb-binaries/4.0.14/mongod" +0ms
  MongoMS:MongoInstance Mongo[44329]: Called MongoInstance._launchKiller(parent: 6748, child: 6759): +0ms
  MongoMS:MongoInstance Mongo[44329]: STDERR: /home/ubuntu/Projects/Web/CowinTracker/server/node_modules/.cache/mongodb-memory-server/mongodb-binaries/4.0.14/mongod: /lib/aarch64-linux-gnu/libcrypto.so.1.0.0: version `OPENSSL_1.0.0' not found (required by /home/ubuntu/Projects/Web/CowinTracker/server/node_modules/.cache/mongodb-memory-server/mongodb-binaries/4.0.14/mongod)
  MongoMS:MongoInstance /home/ubuntu/Projects/Web/CowinTracker/server/node_modules/.cache/mongodb-memory-server/mongodb-binaries/4.0.14/mongod: /lib/aarch64-linux-gnu/libcurl.so.4: version `CURL_OPENSSL_3' not found (required by /home/ubuntu/Projects/Web/CowinTracker/server/node_modules/.cache/mongodb-memory-server/mongodb-binaries/4.0.14/mongod)
  MongoMS:MongoInstance /home/ubuntu/Projects/Web/CowinTracker/server/node_modules/.cache/mongodb-memory-server/mongodb-binaries/4.0.14/mongod: /lib/aarch64-linux-gnu/libssl.so.1.0.0: version `OPENSSL_1.0.0' not found (required by /home/ubuntu/Projects/Web/CowinTracker/server/node_modules/.cache/mongodb-memory-server/mongodb-binaries/4.0.14/mongod)
  MongoMS:MongoInstance /home/ubuntu/Projects/Web/CowinTracker/server/node_modules/.cache/mongodb-memory-server/mongodb-binaries/4.0.14/mongod: /lib/aarch64-linux-gnu/libssl.so.1.0.0: version `OPENSSL_1.0.1' not found (required by /home/ubuntu/Projects/Web/CowinTracker/server/node_modules/.cache/mongodb-memory-server/mongodb-binaries/4.0.14/mongod)
  MongoMS:MongoInstance  +38ms
  MongoMS:MongoInstance Mongo[44329]: Mongod instance closed with an non-0 code! +6ms
  MongoMS:MongoInstance Mongo[44329]: CLOSE: 1 +1ms
  MongoMS:MongoInstance Mongo[44329]: MongodbInstance: Instance has failed: Mongod instance closed with code "1" +0ms
(node:6748) UnhandledPromiseRejectionWarning: Mongod instance closed with code "1"
(Use `node --trace-warnings ...` to show where the warning was created)
(node:6748) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 1)
(node:6748) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
  MongoMS:MongoInstance Mongo[44329]: [MongoKiller]: exit - [null,"SIGTERM"] +14ms

how can I overcome these errors ?

hasezoey commented 3 years ago

did you already try another mongodb version than the default (4.0.14) like 4.2 or 4.4

btw, did you already try the beta version?


aside from that i now saw that you try to use it on arm64, then you should really try the beta version, it added support for ubuntu arm64, or you need to manually define what archive name to use

me-nkr commented 3 years ago

did you already try another mongodb version than the default (4.0.14) like 4.2 or 4.4

no

btw, did you already try the beta version?

no

and can you tell me how ?

hasezoey commented 3 years ago

i updated your comment to better reflect what something means, please change it if not right


to use the 7 beta you have to npm i -s mongodb-memory-server@beta (replace npm with your package manager, replace -s with whatever dependency section you prefer and replace mongodb-memory-server with whatever package you are using from this repo)

here you can find the migration guide, note that the documentation is written only for 7.x

to change the version read here (also the top of the page)

me-nkr commented 3 years ago

I uninstalled what I had and installed mongodb-memory-server@beta, I am running arm64 btw

still gets this error ; MongoMS:MongoInstance Mongo[42737]: stderrHandler: ""/home/ubuntu/Projects/Web/CowinTracker/server/node_modules/.cache/mongodb-memory-server/mongod-arm64-ubuntu-4.0.20: error while loading shared libraries: libcrypto.so.1.0.0: cannot open shared object file: No such file or directory

hasezoey commented 3 years ago

try to install apt install libssl-dev or try apt install libssl1.1 on ubuntu

me-nkr commented 3 years ago

try to install apt install libssl-dev or try apt install libssl1.1 on ubuntu

both are already installed

hasezoey commented 3 years ago

then it seems like an newer mongodb version is required, maybe try MONGOMS_VERSION=4.2.14 or MONGOMS_VERSION=4.4.5

oh, now that i look i also found that there is again an newer 4.0 version, so maybe MONGOMS_VERSION=4.0.25 will work

me-nkr commented 3 years ago

I don't think 4.2.14 and 4.4.5 is available for arm64

and 4.0.25 gives the same error

hasezoey commented 3 years ago

did you also already try putting an v in-front of the versions? (mongodb's file naming is rather inconsistent in this regard)

hasezoey commented 3 years ago

actually, nevermind, i just checked, look into #482 for more

for now, try to overwrite the arch MONGOMS_ARCH=aarch64 (but i dont know if it will even work, probably not) edit: or you can fully overwrite the archive name with (MONGOMS_ARCHIVE_NAME=](https://nodkz.github.io/mongodb-memory-server/docs/api/config-options#archive_name) (find an appropriate file here)

me-nkr commented 3 years ago

This is in my package.json

"config": {
    "mongodbMemoryServer": {
      "arch": "arm64",
      "archive_name" : "http://downloads.mongodb.org/linux/mongodb-linux-aarch64-ubuntu2004-latest.tgzhttp://downloads.mongodb.org/linux/mongodb-linux-aarch64-ubuntu2004-v4.4-latest.tgz",
      "debug": "1"
    }
  }

I'm not sure, but I have a feeling that this has something to do with libcrypto's version.

hasezoey commented 3 years ago

for what you did, you need to use MONGOMS_DOWNLOAD_URL, the archive name is just the mongodb-linux-aarch64-ubuntu2004-latest.tgz part

PS: it seems like you have double-pasted the url in the config PPS: here is how you convert the config options for package.json


I'm not sure, but I have a feeling that this has something to do with libcrypto's version.

yes it does, but currently this package does only support generating arm64 urls, not aarch64, which mongodb seems to use now for higher versions

hasezoey commented 3 years ago

for #482 to be easier to understand and replicate (if needed), could you provide the following:

hasezoey commented 3 years ago

aarch64 should now be correctly downloaded, fix is in 7.0.0-beta.44 if you want to try it (if you had an binary before, you need to remove it, and also the config options to overwrite the archive)

me-nkr commented 3 years ago
  • is the nodejs version used still v14.17.0?

yes

  • is the distro still Ubuntu 20.04.2 aarch64?

yes

  • what is your hardware? (like an raspberry pi?)

Raspberry Pi 4B

  • what is the output of console.log(process.arch)? (just run it in the node repl)

arm64

  • and did the archive aarch64-ubuntu2004-latest work for you?

no

and this is in my package.json now

"config": {
    "mongodbMemoryServer": {
      "arch": "arm64",
      "archiveName" : "linux/mongodb-linux-aarch64-ubuntu2004-latest.tgz",
      "debug": "1"
    }
  }
me-nkr commented 3 years ago

aarch64 should now be correctly downloaded, fix is in 7.0.0-beta.44 if you want to try it (if you had an binary before, you need to remove it, and also the config options to overwrite the archive)

sorry but can you guide me through ? I'm kinda confused

hasezoey commented 3 years ago

and this is in my package.json now

the correct archive name would be mongodb-linux-aarch64-ubuntu2004-latest.tgz

sorry but can you guide me through ? I'm kinda confused

confused on what exactly? there is an migration guide if you still only used 6.x

PS: if you are going to try the beta.44 version, then you would need to also remove the config options arch and archiveName

me-nkr commented 3 years ago

confused on what exactly?

how to use the beta version

hasezoey commented 3 years ago

how to use the beta version

do you mean on how to install it, or how to use is in the code?

me-nkr commented 3 years ago

how to use the beta version

do you mean on how to install it, or how to use is in the code?

install, sorry for not being specific

hasezoey commented 3 years ago

there are 2 methods:

if you want more examples, you could look at this documentation

me-nkr commented 3 years ago
"config": {
    "mongodbMemoryServer": {
      "debug": "1"
    }
  }

this is now in my package.json

I ran npm i mongodb-memory-server@7.0.0-beta.44

still gets the libcrypto error;

MongoMS:MongoInstance Mongo[33475]: stderrHandler: ""/home/ubuntu/Projects/Web/CowinTracker/server/node_modules/.cache/mongodb-memory-server/mongod-arm64-ubuntu-4.0.20: error while loading shared libraries: libcrypto.so.1.0.0: cannot open shared object file: No such file or directory

here is the full log:

 MongoMS:MongoMemoryServer create: Called .create() method +0ms
  MongoMS:MongoMemoryServer start: Called .start() method +8ms
  MongoMS:MongoMemoryServer _startUpInstance: Called MongoMemoryServer._startUpInstance() method +3ms
  MongoMS:MongoMemoryServer getStartOptions +1ms
  MongoMS:MongoMemoryServer _startUpInstance: Creating new MongoDB instance with options: {"instance":{"port":33475,"dbName":"f7e3c463-9aff-40c5-be8d-545817ef1539","ip":"127.0.0.1","storageEngine":"ephemeralForTest","dbPath":"/tmp/mongo-mem--7835-RsXQ62ZHRfSZ","tmpDir":{"name":"/tmp/mongo-mem--7835-RsXQ62ZHRfSZ"}}} +31ms
  MongoMS:MongoInstance create: Called .create() method +0ms
  MongoMS:MongoInstance Mongo[33475]: start +2ms
  MongoMS:MongoBinary getPath +0ms
  MongoMS:utils tryReleaseFile: "/etc/upstream-release/lsb-release" does not exist +0ms
  MongoMS:getos getLinuxInformation: Using etcOsRelease +0ms
  MongoMS:DryMongoBinary generateDownloadPath: Generating Download Path, preferGlobal: "true" +0ms
  MongoMS:DryMongoBinary generateDownloadPath: Paths: {
  legacyHomeCache: '',
  modulesCache: '/home/ubuntu/Projects/Web/CowinTracker/server/node_modules/.cache/mongodb-memory-server/mongod-arm64-ubuntu-4.0.20',
  relative: '/home/ubuntu/Projects/Web/CowinTracker/server/mongodb-binaries/mongod-arm64-ubuntu-4.0.20',
  resolveConfig: ''
} +7ms
  MongoMS:DryMongoBinary generateDownloadPath: Found binary in modulesCache: "/home/ubuntu/Projects/Web/CowinTracker/server/node_modules/.cache/mongodb-memory-server/mongod-arm64-ubuntu-4.0.20" +15ms
  MongoMS:MongoBinary getPath: MongoBinary options: {
  "version": "4.0.20",
  "downloadDir": "/home/ubuntu/Projects/Web/CowinTracker/server/node_modules/.cache/mongodb-memory-server",
  "os": {
    "os": "linux",
    "dist": "ubuntu",
    "codename": "focal",
    "release": "20.04",
    "id_like": "debian"
  },
  "arch": "arm64",
  "systemBinary": "",
  "platform": "linux",
  "checkMD5": false
} +46ms
  MongoMS:DryMongoBinary locateBinary: Trying to locate Binary for version "4.0.20" +3ms
  MongoMS:DryMongoBinary generateDownloadPath: Generating Download Path, preferGlobal: "true" +3ms
  MongoMS:DryMongoBinary generatePaths: resolveConfigValue is not empty +3ms
  MongoMS:DryMongoBinary generateDownloadPath: Paths: {
  legacyHomeCache: '',
  modulesCache: '/home/ubuntu/Projects/Web/CowinTracker/server/node_modules/.cache/mongodb-memory-server/mongod-arm64-ubuntu-4.0.20',
  relative: '/home/ubuntu/Projects/Web/CowinTracker/server/mongodb-binaries/mongod-arm64-ubuntu-4.0.20',
  resolveConfig: '/home/ubuntu/Projects/Web/CowinTracker/server/node_modules/.cache/mongodb-memory-server/mongod-arm64-ubuntu-4.0.20'
} +0ms
  MongoMS:DryMongoBinary generateDownloadPath: Found binary in resolveConfig (DOWNLOAD_DIR): "/home/ubuntu/Projects/Web/CowinTracker/server/node_modules/.cache/mongodb-memory-server/mongod-arm64-ubuntu-4.0.20" +3ms
  MongoMS:DryMongoBinary locateBinary: running generateDownloadPath +0ms
  MongoMS:DryMongoBinary generateDownloadPath: Generating Download Path, preferGlobal: "true" +1ms
  MongoMS:DryMongoBinary generatePaths: resolveConfigValue is not empty +3ms
  MongoMS:DryMongoBinary generateDownloadPath: Paths: {
  legacyHomeCache: '',
  modulesCache: '/home/ubuntu/Projects/Web/CowinTracker/server/node_modules/.cache/mongodb-memory-server/mongod-arm64-ubuntu-4.0.20',
  relative: '/home/ubuntu/Projects/Web/CowinTracker/server/mongodb-binaries/mongod-arm64-ubuntu-4.0.20',
  resolveConfig: '/home/ubuntu/Projects/Web/CowinTracker/server/node_modules/.cache/mongodb-memory-server/mongod-arm64-ubuntu-4.0.20'
} +1ms
  MongoMS:DryMongoBinary generateDownloadPath: Found binary in resolveConfig (DOWNLOAD_DIR): "/home/ubuntu/Projects/Web/CowinTracker/server/node_modules/.cache/mongodb-memory-server/mongod-arm64-ubuntu-4.0.20" +3ms
  MongoMS:DryMongoBinary locateBinary: found binary at "/home/ubuntu/Projects/Web/CowinTracker/server/node_modules/.cache/mongodb-memory-server/mongod-arm64-ubuntu-4.0.20" +1ms
  MongoMS:MongoBinary getPath: Mongod binary path: "/home/ubuntu/Projects/Web/CowinTracker/server/node_modules/.cache/mongodb-memory-server/mongod-arm64-ubuntu-4.0.20" +20ms
  MongoMS:MongoInstance Mongo[33475]: start: Starting Processes +71ms
  MongoMS:MongoInstance Mongo[33475]: _launchMongod: Launching Mongod Process +1ms
  MongoMS:MongoInstance Mongo[33475]: prepareCommandArgs +2ms
  MongoMS:MongoInstance Mongo[33475]: prepareCommandArgs: final arugment array:["--port","33475","--dbpath","/tmp/mongo-mem--7835-RsXQ62ZHRfSZ","--storageEngine","ephemeralForTest","--bind_ip","127.0.0.1","--noauth"] +0ms
  MongoMS:MongoInstance Mongo[33475]: _launchKiller: Launching Killer Process (parent: 7835, child: 7846) +47ms
  MongoMS:MongoInstance Mongo[33475]: stderrHandler: ""/home/ubuntu/Projects/Web/CowinTracker/server/node_modules/.cache/mongodb-memory-server/mongod-arm64-ubuntu-4.0.20: error while loading shared libraries: libcrypto.so.1.0.0: cannot open shared object file: No such file or directory
  MongoMS:MongoInstance "" +25ms
  MongoMS:MongoInstance Mongo[33475]: closeHandler: Mongod instance closed with an non-0 (or non 12 on windows) code! +6ms
  MongoMS:MongoInstance Mongo[33475]: closeHandler: 127 +1ms
hasezoey commented 3 years ago

sorry forgot to mention, you will still need to overwrite the version with MONGOMS_VERSION, the default for 6.x is 4.0.14 and for 7.x (currently) is 4.0.20

me-nkr commented 3 years ago

to which version ?

hasezoey commented 3 years ago

to an higher version than default, we had it earlier in the issue: https://github.com/nodkz/mongodb-memory-server/issues/480#issuecomment-858963570

me-nkr commented 3 years ago

so I tried the following in package.json

"version": "v4.0.25" > got 403 (Mongodb's 404)

"version": "4.0.25" > got libcrypto error

"version": "v4.0-latest" > got 403, but also noticed Used Url: "https://fastdl.mongodb.org/linux/mongodb-linux-arm64-ubuntu2004-v4.0-latest.tgz"

hasezoey commented 3 years ago

you will need to try an higher version than 4.0 / 4.1, so try (like said earlier in the issue) 4.2.14 or 4.4.5

me-nkr commented 3 years ago

version 4.2.14 works fine, in the sense a instance starts and I can getUri and instanceInfo, so thanks for the support. I hope pointing this issue helped. Looking forward to contributing more

andrempeixoto commented 1 year ago

I'm using Ubuntu 22.10 and I'm facing this same issue with mongodb-memory-server when running jest tests.

In order to work around this I needed to install libcrypto.so.1.0.0 from Ubuntu archive since the libcrypto package is not installed by default in Ubuntu 22.04 >=.

You can find how to install it manually from Ubuntu archive repo here: https://stackoverflow.com/a/73251469/9936281

hasezoey commented 1 year ago

@andrempeixoto you could also manually set the version to 6.0.4 (or higher), because that is the version mongodb ships with builds for ubuntu 2204

andrempeixoto commented 1 year ago

I actually already had "mongodb-memory-server": "6.9.6", so should it have worked from the start?

hasezoey commented 1 year ago

@andrempeixoto that is the package version, i was meaning the binary version via the config option

simplexityware commented 1 year ago

I did not install the libcrypto library but just set the config option as follows in my package.json file but the error remains.

 "config": {
    "mongodbMemoryServer": {
      "MONGOMS_VERSION": "6.0.4"
    }
  }
hasezoey commented 1 year ago

@simplexityware

MONGOMS_VERSION

that is the environment variable name, see this page what name to use where (in the case of VERSION it would be version)

U-Sahaj commented 1 year ago

Thank you! Now my tests keep downloading the mongo-memory-server for each test resulting in the following timeout error...

 FAIL  src/mongo.test.ts > Mongo Memory Server Test > Test MongoDB
Error: Test timed out in 5000ms.
If this is a long-running test, pass a timeout value as the last argument or configure it globally with "testTimeout".

My simple test is as follows ..

const runTest = async () => {
  const mongod = await MongoMemoryServer.create();
  await mongod.start();
  const uri = await mongod.getUri()
  // Do your tests here
  console.log('MongoDB URI:', uri)
  await mongod.stop()
}

describe('Mongo Memory Server Test', () => {
  it('Test MongoDB', async () => {
    await runTest()
  })
})

What am I missing?

hasezoey commented 1 year ago

const mongod = await MongoMemoryServer.create(); await mongod.start();

no need for a extra .start, .create is literally a new Class chained with .start` https://github.com/nodkz/mongodb-memory-server/blob/ebee09413ba669307403066cad4df0c9376fdc76/packages/mongodb-memory-server-core/src/MongoMemoryServer.ts#L250-L251

const uri = await mongod.getUri()

.getUri is sync since 7.0.0 (not returning a promise)

await runTest()

the way you have it defined is considered bad practice; only one instance should only be created for the current test suite, not for each test. and even better is if you can create just one instance for all tests, see Integration with Test Runners

Now my tests keep downloading the mongo-memory-server for each test resulting in the following timeout error...

if you dont have the binary already downloaded, then MMS will by default download it when the instance is started - which can take some time. it is recommended to have it auto-download at package install time (using any package other than -core will automatically download a version) or otherwise use a global hook (like jest's globalSetup) to call await MongoBinary.getPath() (or with parameter { version: 'x.x.x' } when wanting some specific version other than defined via environment variable or package json)

https://github.com/nodkz/mongodb-memory-server/blob/ebee09413ba669307403066cad4df0c9376fdc76/packages/mongodb-memory-server-core/src/__tests__/testUtils/globalSetup.ts#L8-L12

U-Sahaj commented 1 year ago

Thank you! Sorry I am new to Typescript as well as Mongo. Please tell me exactly what I need to do including the version in "config" as well as any "npm install mongoldb-memory-server" additional parameters to pass my test to get me started using MMS.

hasezoey commented 1 year ago

to get me started using MMS.

basically follow the quick-start-guide and Integration with test runners (use the section for your test runner like jest or mocha)

you can also look at examples like MMS's own testing or how typegoose uses it or how mongoose uses it (look at the respective package.jsons and test runner configs manually)

if you want more setup help, consider asking on our discord or opening up a new discussion

U-Sahaj commented 1 year ago

Using the integration with test runners link, without any need to change package.json file, I get the same error as the original author of this thread...

 FAIL  src/mongo.test.ts > Mongo Memory Server Test > Test MongoDB
Error: Instance failed to start because a library is missing or cannot be opened: "libcrypto.so.1.1"
 ❯ MongoInstance.checkErrorInLine node_modules/mongodb-memory-server-core/src/util/MongoInstance.ts:678:11
 ❯ MongoInstance.stderrHandler node_modules/mongodb-memory-server-core/src/util/MongoInstance.ts:563:10
 ❯ Socket.emit node:events:512:28
 ❯ Socket.emit node:domain:489:12

What should I do next?

hasezoey commented 1 year ago

Error: Instance failed to start because a library is missing or cannot be opened: "libcrypto.so.1.1"

https://github.com/nodkz/mongodb-memory-server/issues/732

please search existing issues for those errors first

erwanriou commented 1 year ago

this fixed it for me:

wget http://archive.ubuntu.com/ubuntu/pool/main/o/openssl/libssl1.1_1.1.1f-1ubuntu2_amd64.deb
sudo dpkg -i libssl1.1_1.1.1f-1ubuntu2_amd64.deb
insaiyadin commented 1 year ago

this fixed it for me:

wget http://archive.ubuntu.com/ubuntu/pool/main/o/openssl/libssl1.1_1.1.1f-1ubuntu2_amd64.deb
sudo dpkg -i libssl1.1_1.1.1f-1ubuntu2_amd64.deb

Thanks! This solution worked for me!

duluca commented 1 year ago

I had a similar issue with it working fine on my Mac (no mongo install) but failing on a CircleCI build using their own image cimg/node but it worked fine when I switched to node: bullseye which is a Debian 11 release. So, it's definitely a host OS config or compatibility issue.

jdbdnz commented 1 year ago

I had a similar issue with it working fine on my Mac (no mongo install) but failing on a CircleCI build using their own image cimg/node but it worked fine when I switched to node: bullseye which is a Debian 11 release. So, it's definitely a host OS config or compatibility issue.

Specifically, what did you do? I think I have the same issue.

duluca commented 1 year ago

In config.yml for CircleCI, I changed the docker image to node: bullseye. Here's the file within the context of my project https://github.com/duluca/document-ts/blob/main/.circleci/config.yml

Bibekspk commented 1 year ago

this fixed it for me:

wget http://archive.ubuntu.com/ubuntu/pool/main/o/openssl/libssl1.1_1.1.1f-1ubuntu2_amd64.deb
sudo dpkg -i libssl1.1_1.1.1f-1ubuntu2_amd64.deb

Worked for me. Thanks a lot

alamindevms commented 1 year ago

Thanks a lot. This worked for me.

bruceborrett commented 11 months ago

I am able to install and run MongoDB from official repos on Ubuntu 22.04 without any problem, but mongodb-memory-server still fails complaining about libssl1.1, even if I set the binary version to 6.0.4 or even 6.3.0, it still fails. Why is there inconsistent behaviour between the actual mongo libraries and the libraries used by MMS?

hasezoey commented 11 months ago

Why is there inconsistent behaviour between the actual mongo libraries and the libraries used by MMS?

there is none, please provide the binary name you have tested with (just note that the APT repository is not a source for MMS)

if this error still continues with 6.0.4 binaries, please open a new issue providing the debug log

stvnreis commented 10 months ago

this fixed it for me:

wget http://archive.ubuntu.com/ubuntu/pool/main/o/openssl/libssl1.1_1.1.1f-1ubuntu2_amd64.deb
sudo dpkg -i libssl1.1_1.1.1f-1ubuntu2_amd64.deb

Thanks man, you just saved me!