Pre-download MongoDB binary to EFS during CodeBuild install#2417
Merged
hiroshinishio merged 1 commit intomainfrom Mar 20, 2026
Merged
Pre-download MongoDB binary to EFS during CodeBuild install#2417hiroshinishio merged 1 commit intomainfrom
hiroshinishio merged 1 commit intomainfrom
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
services/aws/download_mongod_binary.mjsthat pre-downloads the MongoDB binary for MongoMemoryServer so it's cached on EFS before Jest tests run, avoiding a ~100MB download eating into the 600s test timeout/mnt/efs/.scripts/before starting CodeBuild; the buildspec calls it afternpm installpackage.jsonconfig section first, then falls back toMONGOMS_VERSION=in test script commands (covers all Foxquilt repos)ubuntu-22.04since Amazon Linux 2023 binaries don't exist for older versions.github/workflows/node-test.ymlCI workflow for Node.js tests using built-innode:testrunner with c8 coveragerun_install_via_codebuild.py(Node copies, Composer skips)Social Media Post (GitAuto)
Jest tests on Lambda kept timing out - not because of slow tests, but because MongoMemoryServer downloads a 100MB binary on every run. We now pre-download it to EFS during the package install step so it's cached before tests start. Version detection parses both package.json config and env vars in test scripts to match whatever version the repo expects.
Social Media Post (Wes)
MongoMemoryServer downloads a ~100MB mongod binary the first time it runs. On Lambda with a 600s timeout, that download silently ate half the budget before a single test executed. The fix wasn't "increase the timeout" - it was moving the download to the install step where it belongs. Wrote a small .mjs script that reads the target version from package.json (two different places it can hide), handles the distro override for older MongoDB on AL2023, and caches the binary on EFS. Tests went from timing out to finishing in seconds.