-
-
Notifications
You must be signed in to change notification settings - Fork 187
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
miggration from 8.11.4 to 10.1.3 memory shortage on github action #907
Comments
Alternatively, you could also try to use I dont know anything about MMS that could leak that much and i also am not aware of any change in mongodb that would lead to a massive increase. Do you clean your database between test-suites? Is the log / repository public? If so i it would be great to investigate there. |
@hasezoey I could try the version 9 too indeed (they might have a higher default binary that true) yes i do have events between test to clean and clear: // DROP TEST DABASE
beforeEach(async () => await dbhandler.clearDatabase()) the create and clear event are quite standard: const mongoose = require("mongoose")
const { MongoMemoryServer } = require("mongodb-memory-server")
let mongo
module.exports.connect = async () => {
const systemBinary = process.env.MONGOMS_SYSTEM_BINARY || undefined
const version = process.env.MONGOMS_VERSION || "6.0.19"
mongo = await MongoMemoryServer.create({ binary: { version, systemBinary } })
const mongoUri = await mongo.getUri()
await mongoose.set("strictQuery", true)
await mongoose.connect(mongoUri)
}
module.exports.clearDatabase = async () => {
const collections = await mongoose.connection.db.collections()
for (let collection of collections) {
await collection.deleteMany({})
}
} I don't make usage of |
To confirm, are you using jest with global-setup? Or do you start a mongodb-memory-server instance for each test-suite? |
Yes i do have a global setup for jest that is used by all the tests after. "jest": {
"testEnvironment": "node",
"setupFilesAfterEnv": [
"./src/test/setup_test.js"
]
} The main differences between the local and cicd are the command i launch that are respectivly: {
"test": "jest --watchAll --runInBand --verbose",
"test:ci": "jest --forceExit --detectOpenHandles --maxWorkers=10",
} to give you an idea of how would looklike a test: const request = require("supertest")
const app = require("../../../../app")
const eventBuilder = async () => {
const listener = new PreprofileCreatedList(NatsWrapper.client())
const data = global.preprofileGenerator({})
const msg = { ack: jest.fn() }
return { listener, data, msg }
}
it("returns a 200 when fetching list of preprofiles as admin", async () => {
// GENERATE AND APPROVE 3 ARCHITECT PREPROFILES
for (let i = 0; i < 3; i++) {
const { listener, data, msg } = await eventBuilder()
await listener.onMessage(data, msg)
const preprofile = await PreProfile.findById(data._id)
expect(preprofile._id.toString()).toEqual(data._id)
}
// FETCH ARCHITECT WITH ADMIN API
const adminCookie = await global.adminRegister()
const page = 0
const limit = 100
const { body } = await request(app)
.get(`/api/architect/admin/example-endpoint/list?page=${page}&limit=${limit}`)
.set({ Host: "www.example.com" })
.set("Cookie", adminCookie)
.expect(200)
expect(body[0].total).toEqual([{ count: 3 }])
expect(body[0].preprofiles).toHaveLength(3)
}) |
EDIT: Seems to be that JEST increased heap usage with each test, which lead to this ENOMEM. So my problem below is not directly with MMS, but with JEST instead. Hey, I'm not sure if this is related, but since updating Node in my dockerfile vom 20 to 22.13 and then also updating the mongodb-memory-server to 10.1.3, I see a new ENOMEM error when testing, which didn't happen before that. I read that it might have to do with virtual memory and that increasing vm.max_map_count might help. However since I'm using an AWS build environment and FARGATE I think that's not possible there. (Still researching). However I'll try changing the binary and see if that helps. Didn't try that so far. Here the error:
|
Well this is weird, this means that the mongodb binary couldnt even start because it has no memory, to my knowledge this issue(#907) is about running out of memory while a binary is already running (though i dont know yet if the issue is mongodb, MMS, or something else here). I dont think i can help in your case, you will need to look why it is already out-of-memory at that point. (if it is actually MMS, please open a new issue) |
Versions
package: mongodb-memory-server
What is the Problem?
i updated the mongodb-memory-server to latest in order to pass a test that is making use of a feature added in mongodb 5.2 and test passed locally (but much much slower tho). Since i deployed it on the CI but the github action timeout due to memory when i don't even have that much test in it.
Code Example
I have a total of 78 test suite (in some other be i have more than 200 without any issues)
I believe a screen is better than more explainations:
So i believe there might be some sort of memoryleak underneath that generate the issue. In the meantime i will do
The text was updated successfully, but these errors were encountered: