Skip to content

fix(test): serialize retention env-var tests to stop CI flake - #315

Merged
ajianaz merged 1 commit into
developfrom
fix/flaky-retention-env-test
Sep 3, 2026
Merged

fix(test): serialize retention env-var tests to stop CI flake#315
ajianaz merged 1 commit into
developfrom
fix/flaky-retention-env-test

Conversation

@ajianaz

@ajianaz ajianaz commented Sep 3, 2026

Copy link
Copy Markdown
Contributor

What

Adds a shared Mutex guard (RETENTION_ENV_LOCK) around the two tests that mutate TRAPFALL_RETENTION_DAYS (retention_days_custom_env, retention_days_invalid_falls_back).

Why

Env vars are process-global while cargo test runs tests on parallel threads. The two tests raced each other's set_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 trapfalld and cargo fmt --check clean

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.
@ajianaz
ajianaz merged commit 32d8eb0 into develop Sep 3, 2026
17 checks passed
@ajianaz
ajianaz deleted the fix/flaky-retention-env-test branch September 3, 2026 06:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant