test: fs: stop the disk space test racing with the filesystem - #442
Merged
Conversation
`a_requirement_beyond_the_available_space_is_rejected` read the free space, then handed the very same number to `ensure_disk_space`, which reads it again. Any other writer on that filesystem moves the second reading, and the boundary case the test was pinned to then falls on the wrong side. It failed exactly that way in the coverage step of https://github.com/UpdateHub/updatehub/actions/runs/32294740390, with `available: 80615378944, required: 80615387136`: 8 KiB vanished while the two readings ran, because `cargo llvm-cov` has the parallel tests writing .profraw files the whole time. Step back from the boundary on both sides. Half of the free space stays available however busy the disk gets, and no filesystem answers with `u64::MAX`, so the rejection no longer depends on what the second reading finds.
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.
a_requirement_beyond_the_available_space_is_rejectedread the free space, then handed the very same number toensure_disk_space, which reads it again:Any other writer on that filesystem moves the second reading, so the boundary case the test was pinned to falls on the wrong side.
It failed exactly that way in the coverage step of run 32294740390:
8 KiB vanished while the two readings ran, because
cargo llvm-covhas the parallel tests writing.profrawfiles the whole time.The fix
Step back from the boundary on both sides. Half of the free space stays available however busy the disk gets, and no filesystem answers with
u64::MAX, so the rejection no longer depends on what the second reading finds.This blocks #441, which the same flake failed on with an unrelated diff.
Verification
cargo test --lib utils::fs: 11 pass, 0 fail.cargo fmt --all -- --check: clean.cargo clippy --locked --all-features --all --tests -- -D clippy::all: clean.