kaizendorks / pymongo_inmemory

A mongo mocking library with an ephemeral MongoDB running in memory.
MIT License
40 stars 13 forks source link

Status: Not running - Happening sometimes on CI when port assigned is 27018 #17

Closed fabriciols closed 4 years ago

fabriciols commented 4 years ago

Sometimes (appear to be random) my tests got stuck looping this message when running on Azure Devops CI

2020-04-27T20:29:26.7466043Z 2020-04-27T17:29:26.743-0300 I NETWORK  [initandlisten] waiting for connections on port 27018
2020-04-27T20:29:26.7467365Z 2020-04-27T17:29:26.743-0300 I STORAGE  [LogicalSessionCacheRefresh] createCollection: config.system.sessions with generated UUID: 037cab30-ab6a-4c58-8ae3-9f50992d856e
2020-04-27T20:29:26.7468920Z 2020-04-27T17:29:26.743-0300 I INDEX    [LogicalSessionCacheRefresh] build index on: config.system.sessions properties: { v: 2, key: { lastUse: 1 }, name: "lsidTTLIndex", ns: "config.system.sessions", expireAfterSeconds: 1800 }
2020-04-27T20:29:26.7470587Z 2020-04-27T17:29:26.744-0300 I INDEX    [LogicalSessionCacheRefresh]    building index using bulk method; build may temporarily use up to 500 megabytes of RAM
2020-04-27T20:29:26.7471713Z 2020-04-27T17:29:26.744-0300 I INDEX    [LogicalSessionCacheRefresh] build index done.  scanned 0 total records. 0 secs
2020-04-27T20:29:27.2496620Z exception: connect failed
2020-04-27T20:29:27.2499036Z 2020-04-27 17:29:26,784           ??? mongod.py    (0120) - Status: Not running
2020-04-27T20:29:27.2500316Z 2020-04-27 17:29:26,785           ??? mongod.py    (0117) - Getting status
2020-04-27T20:29:27.2501078Z exception: connect failed
2020-04-27T20:29:27.2502150Z 2020-04-27 17:29:26,849           ??? mongod.py    (0120) - Status: Not running
2020-04-27T20:29:27.2503631Z 2020-04-27 17:29:26,849           ??? mongod.py    (0117) - Getting status
2020-04-27T20:29:27.2504478Z exception: connect failed
2020-04-27T20:29:27.2505437Z 2020-04-27 17:29:26,909           ??? mongod.py    (0120) - Status: Not running
2020-04-27T20:29:27.2506667Z 2020-04-27 17:29:26,910           ??? mongod.py    (0117) - Getting status
2020-04-27T20:29:27.2507574Z exception: connect failed
2020-04-27T20:29:27.2509194Z 2020-04-27 17:29:26,969           ??? mongod.py    (0120) - Status: Not running
2020-04-27T20:29:27.2510321Z 2020-04-27 17:29:26,969           ??? mongod.py    (0117) - Getting status
2020-04-27T20:29:27.2511055Z exception: connect failed
2020-04-27T20:29:27.2512145Z 2020-04-27 17:29:27,034           ??? mongod.py    (0120) - Status: Not running
2020-04-27T20:29:27.2513616Z 2020-04-27 17:29:27,035           ??? mongod.py    (0117) - Getting status
2020-04-27T20:29:27.2514367Z exception: connect failed
2020-04-27T20:29:27.2515316Z 2020-04-27 17:29:27,095           ??? mongod.py    (0120) - Status: Not running
2020-04-27T20:29:27.2516587Z 2020-04-27 17:29:27,096           ??? mongod.py    (0117) - Getting status
2020-04-27T20:29:27.2517314Z exception: connect failed
2020-04-27T20:29:27.2518280Z 2020-04-27 17:29:27,168           ??? mongod.py    (0120) - Status: Not running
2020-04-27T20:29:27.2519529Z 2020-04-27 17:29:27,169           ??? mongod.py    (0117) - Getting status
2020-04-27T20:29:27.2520360Z exception: connect failed
2020-04-27T20:29:27.2521462Z 2020-04-27 17:29:27,233           ??? mongod.py    (0120) - Status: Not running
2020-04-27T20:29:27.2523848Z 2020-04-27 17:29:27,233           ??? mongod.py    (0117) - Getting status
2020-04-27T20:29:27.2928305Z exception: connect failed
2020-04-27T20:29:27.2946114Z 2020-04-27 17:29:27,293           ??? mongod.py    (0120) - Status: Not running
2020-04-27T20:29:27.2947458Z 2020-04-27 17:29:27,294           ??? mongod.py    (0117) - Getting status
2020-04-27T20:29:27.3629183Z exception: connect failed
2020-04-27T20:29:27.3648635Z 2020-04-27 17:29:27,364           ??? mongod.py    (0120) - Status: Not running
2020-04-27T20:29:27.3653610Z 2020-04-27 17:29:27,364           ??? mongod.py    (0117) - Getting status

My guess the problem is related to the port assigned, maybe the OS take some time to release the port 27017 when the process is killed, and in the next time we try to put the mongod up, it get the port 27018 and stopped to work

I have attached a full log.

Using the latest version: 0.1.2 pymongo_inmemory.txt

ekarademir commented 4 years ago

Hey, thanks for trying this library. I'll have a look.

ekarademir commented 4 years ago

The issue was not particular to the port, but how we checked the health of the server. There is now a PR #22 for fixing this. This was a crucial bug, thank you for reporting @fabriciols