Skip to content

🧪 test(storage): de-flake S3 stage-error tests#614

Merged
gaborbernat merged 1 commit into
tox-dev:mainfrom
gaborbernat:fix/s3-stage-error-tests
Jul 18, 2026
Merged

🧪 test(storage): de-flake S3 stage-error tests#614
gaborbernat merged 1 commit into
tox-dev:mainfrom
gaborbernat:fix/s3-stage-error-tests

Conversation

@gaborbernat

Copy link
Copy Markdown
Member

Two S3 backend tests added in #605 flake on the coverage and test jobs and are reddening main and every open PR. Both forced an I/O error with a permission bit: test_s3_begin_surfaces_a_staging_failure made the staging directory read-only (0o555), and test_s3_commit_surfaces_an_unreadable_stage made the stage file unreadable (0o000), then asserted the operation failed. 🔴 Root ignores permission bits, so on a root runner begin and commit succeed and unwrap_err() panics. The commit test compounded it by restoring the stage's permissions after commit: on failure the staged value is dropped, and its drop spawns the asynchronous cleanup that removes the stage, so the final set_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 commit reads 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.

@gaborbernat gaborbernat added the bug Something isn't working label Jul 18, 2026
@read-the-docs-community

read-the-docs-community Bot commented Jul 18, 2026

Copy link
Copy Markdown

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
gaborbernat force-pushed the fix/s3-stage-error-tests branch from c8927a9 to f471063 Compare July 18, 2026 04:25
@gaborbernat
gaborbernat merged commit 73d8896 into tox-dev:main Jul 18, 2026
27 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant