Skip to content

Pre-download MongoDB binary to EFS during CodeBuild install#2417

Merged
hiroshinishio merged 1 commit intomainfrom
wes
Mar 20, 2026
Merged

Pre-download MongoDB binary to EFS during CodeBuild install#2417
hiroshinishio merged 1 commit intomainfrom
wes

Conversation

@hiroshinishio
Copy link
Copy Markdown
Collaborator

Summary

  • Created services/aws/download_mongod_binary.mjs that 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
  • Lambda copies the script to /mnt/efs/.scripts/ before starting CodeBuild; the buildspec calls it after npm install
  • Version detection reads from package.json config section first, then falls back to MONGOMS_VERSION= in test script commands (covers all Foxquilt repos)
  • For MongoDB <7.0, overrides distro to ubuntu-22.04 since Amazon Linux 2023 binaries don't exist for older versions
  • Added .github/workflows/node-test.yml CI workflow for Node.js tests using built-in node:test runner with c8 coverage
  • Added tests for the script copy logic in run_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.

@hiroshinishio hiroshinishio self-assigned this Mar 20, 2026
@hiroshinishio hiroshinishio merged commit 7509e40 into main Mar 20, 2026
2 checks passed
@hiroshinishio hiroshinishio deleted the wes branch March 20, 2026 22:13
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

Successfully merging this pull request may close these issues.

1 participant