fix(test): serialize retention env-var tests to stop CI flake - #315
Merged
Conversation
TRAPFALL_RETENTION_DAYS is process-global; cargo test runs tests on parallel threads, so retention_days_custom_env and retention_days_invalid_falls_back raced each other's set/remove and failed intermittently. Guard both with a shared mutex.
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
Adds a shared
Mutexguard (RETENTION_ENV_LOCK) around the two tests that mutateTRAPFALL_RETENTION_DAYS(retention_days_custom_env,retention_days_invalid_falls_back).Why
Env vars are process-global while
cargo testruns tests on parallel threads. The two tests raced each other'sset_var/remove_var, making CI fail intermittently (observed on PR #314:retention_days_custom_env ... left: 90, right: 30). The previous "single-threaded test" SAFETY comment was incorrect.Testing
cargo test -p trapfalld --lib config::passed 6 consecutive full-module runs (previously failed within 3 runs)cargo clippy -p trapfalldandcargo fmt --checkclean