🧪 test(storage): de-flake S3 stage-error tests#614
Merged
Conversation
The S3 begin- and commit-failure tests forced their errors with permission bits: a read-only staging directory and a chmod-000 stage. Root ignores those bits, so on a root runner begin and commit succeed and unwrap_err panics. The commit test also restored the stage's permissions after commit, racing the asynchronous drop that removes the stage and panicking with a not-found when the drop won. Trigger the same failures through conditions no user can bypass and with no cleanup to race: point the staging path at a regular file so creating the staging directory fails as not-a-directory, and remove the local stage before commit reads it so the upload's read fails as not-found. The tests hold on non-root, root, and under coverage instrumentation, and still cover the staging and read failures.
gaborbernat
force-pushed
the
fix/s3-stage-error-tests
branch
from
July 18, 2026 04:25
c8927a9 to
f471063
Compare
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.
Two S3 backend tests added in #605 flake on the coverage and test jobs and are reddening
mainand every open PR. Both forced an I/O error with a permission bit:test_s3_begin_surfaces_a_staging_failuremade the staging directory read-only (0o555), andtest_s3_commit_surfaces_an_unreadable_stagemade the stage file unreadable (0o000), then asserted the operation failed. 🔴 Root ignores permission bits, so on a root runnerbeginandcommitsucceed andunwrap_err()panics. The commit test compounded it by restoring the stage's permissions aftercommit: on failure the staged value is dropped, and its drop spawns the asynchronous cleanup that removes the stage, so the finalset_permissions(...).unwrap()races that removal and panics with a not-found when the drop wins.The fix triggers the same two error paths through conditions no user can bypass and with nothing left to clean up. The begin test points the staging path at a regular file, so creating the staging directory fails with a not-a-directory error for everyone including root. The commit test removes the local stage before
commitreads it to upload, so the read fails as not-found regardless of the running user, and there is no permission to restore, so the assertion no longer races the stage's drop. Both tests drop their#[cfg(unix)]guards since neither relies on Unix permissions anymore. ✅I reproduced the fixed tests as deterministic across 60 back-to-back runs and confirmed they still cover the staging-creation and stage-read failure paths, so the function-coverage gate holds. This addresses the flaky failures seen on
main's coverage job and on #609 and #611.