Skip to content

test: fix flaky test_autoclean_folder#34

Merged
knep merged 1 commit into
masterfrom
fix/flaky-autoclean-test
Jun 25, 2026
Merged

test: fix flaky test_autoclean_folder#34
knep merged 1 commit into
masterfrom
fix/flaky-autoclean-test

Conversation

@knep

@knep knep commented Jun 25, 2026

Copy link
Copy Markdown
Owner

Summary

Stabilises user_file_storage_test.py::TestUserFileStorage::test_autoclean_folder, which intermittently failed on CI (most recently Python 3.11, PR #33) with:

AssertionError: True is not false   # assertFalse(os.path.exists(folder))

Root cause

The test creates a folder, starts the background autoclean timer, then asserts the folder is gone after a fixed time.sleep(0.020). The cleanup runs on a threading.Timer; on a loaded runner it hasn't necessarily executed within 20 ms, so the folder may still exist when the assertion runs.

Fix (test-only)

Replace the fixed sleep with active polling — wait up to 2 s for the folder to disappear, then assert. The autoclean (lifetime 2 ms, timer period ~0.08 ms) deletes it far within that window, so the test is deterministic without being timing-fragile.

Testing

  • The test run 25× locally: 25/25 pass.
  • Full backend suite: 1748 passed.

This was the third and last timing-flaky tracked this cycle (after the tests_temp cleanup race and the PTY env read race, both already fixed).

🤖 Generated with Claude Code

test_autoclean_folder intermittently failed on CI ("True is not false"): it
created a folder, started the background autoclean timer, then asserted the
folder was gone after a fixed time.sleep(0.020). On a loaded runner the cleanup
thread hadn't necessarily run within 20ms.

Replace the fixed sleep with active polling (wait up to 2s for the folder to
disappear). The autoclean still deletes it well within that window; the test is
now deterministic. No production code changed.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@knep knep merged commit fa20022 into master Jun 25, 2026
8 checks passed
@knep knep deleted the fix/flaky-autoclean-test branch June 25, 2026 18:03
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