Skip to content

test: prevent OOM crash in archive-safety too-many-entries test - #1340

Merged
crowecawcaw merged 1 commit into
aws-deadline:mainlinefrom
leon-li-inspire:fix/archive-safety-test-oom
Aug 25, 2026
Merged

test: prevent OOM crash in archive-safety too-many-entries test#1340
crowecawcaw merged 1 commit into
aws-deadline:mainlinefrom
leon-li-inspire:fix/archive-safety-test-oom

Conversation

@leon-li-inspire

Copy link
Copy Markdown
Contributor

What

TestArchiveExtractionSafety._fake_zip built one MagicMock per zip entry. test_rejects_too_many_entries constructs MAX_ARCHIVE_ENTRIES + 1 (100,001) entries, so it allocated ~100k MagicMock objects — hundreds of MB to multiple GB of RAM.

This is the heaviest test in the suite (12–48s even on GitHub runners). On the memory-constrained single-worker publish CodeBuild container, it OOM-killed the pytest-xdist worker (replacing crashed worker gw0). The dead worker dropped its coverage data, total coverage fell to 60.17% (below the 69% fail-under gate), and pipeline/publish.sh exited 1 — blocking the release publish for 0.60.5.

Fix

Replace the per-entry MagicMock with a lightweight types.SimpleNamespace. _check_archive_extraction_safety only reads .file_size / .compress_size, which SimpleNamespace provides, so all five tests using _fake_zip are unaffected and the production MAX_ARCHIVE_ENTRIES = 100_000 limit is unchanged.

Testing

The full TestArchiveExtractionSafety class (including test_rejects_too_many_entries) now passes under a 2 GB virtual-memory cap in 0.14s — previously it OOM-crashed the worker.

$ ulimit -v 2097152; pytest test/unit/.../test_repository.py::TestArchiveExtractionSafety -v
6 passed in 0.14s

Regression source

Introduced by #1181 (job bundle browser/sharing), which added both the archive-safety check and this test. Since #1181 is the only feature in 0.60.5, its own test currently blocks that release from publishing.

TestArchiveExtractionSafety._fake_zip built one MagicMock per zip entry.
test_rejects_too_many_entries constructs MAX_ARCHIVE_ENTRIES + 1 (100,001)
entries, so it allocated ~100k MagicMock objects — hundreds of MB to
multiple GB of RAM. This is the heaviest test in the suite (12-48s even on
GitHub runners) and, on the memory-constrained single-worker publish
CodeBuild container, it OOM-killed the pytest-xdist worker. The dead worker
dropped its coverage data, total coverage fell below the fail-under gate,
and pipeline/publish.sh exited 1 — blocking the release publish.

Replace the per-entry MagicMock with a lightweight types.SimpleNamespace.
_check_archive_extraction_safety only reads .file_size / .compress_size,
which SimpleNamespace provides, so all tests using _fake_zip are unaffected
and the production MAX_ARCHIVE_ENTRIES limit is unchanged.

Verified: the full TestArchiveExtractionSafety class passes under a 2 GB
virtual-memory cap in 0.14s (previously OOM-crashed the worker).

Regression from aws-deadline#1181 (job bundle browser/sharing), which introduced both
the archive-safety check and this test.

Signed-off-by: Leon Li <2182521+leon-li-inspire@users.noreply.github.com>
@leon-li-inspire
leon-li-inspire requested a review from a team as a code owner August 24, 2026 23:36
@github-actions github-actions Bot added the waiting-on-maintainers Waiting on the maintainers to review. label Aug 24, 2026
@crowecawcaw
crowecawcaw merged commit 244ff28 into aws-deadline:mainline Aug 25, 2026
41 of 54 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

waiting-on-maintainers Waiting on the maintainers to review.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants