test: prevent OOM crash in archive-safety too-many-entries test - #1340
Merged
crowecawcaw merged 1 commit intoAug 25, 2026
Merged
Conversation
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>
crowecawcaw
approved these changes
Aug 25, 2026
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.
What
TestArchiveExtractionSafety._fake_zipbuilt oneMagicMockper zip entry.test_rejects_too_many_entriesconstructsMAX_ARCHIVE_ENTRIES + 1(100,001) entries, so it allocated ~100kMagicMockobjects — 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-undergate), andpipeline/publish.shexited 1 — blocking the release publish for 0.60.5.Fix
Replace the per-entry
MagicMockwith a lightweighttypes.SimpleNamespace._check_archive_extraction_safetyonly reads.file_size/.compress_size, whichSimpleNamespaceprovides, so all five tests using_fake_zipare unaffected and the productionMAX_ARCHIVE_ENTRIES = 100_000limit is unchanged.Testing
The full
TestArchiveExtractionSafetyclass (includingtest_rejects_too_many_entries) now passes under a 2 GB virtual-memory cap in 0.14s — previously it OOM-crashed the worker.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.