Skip to content

Fix flaky test_kick_scan_is_idempotent (drain scan threads)#13

Merged
cryptopoly merged 1 commit intomainfrom
feature/video-gen
Apr 29, 2026
Merged

Fix flaky test_kick_scan_is_idempotent (drain scan threads)#13
cryptopoly merged 1 commit intomainfrom
feature/video-gen

Conversation

@cryptopoly
Copy link
Copy Markdown
Owner

Summary

Fix

  • Track spawned scan threads on ChaosEngineState and prune dead entries on each kick.
  • Add idempotent ChaosEngineState.shutdown(timeout=5.0) that joins all alive scan threads.
  • Tests assign their constructed state to self.state and drain it in tearDown before self.tmp.cleanup().

Verification

  • tests/test_state_async_library.py now deterministic locally (5/5 runs).
  • Full backend pytest green on Linux runner via run 25129383727 (test job + 3-OS build matrix all ✓).
  • npx tsc --noEmit clean.
  • npm test 179/179 pass.

Test plan

  • Target test 5×
  • Full backend pytest
  • TypeScript typecheck
  • Vitest suite
  • CI matrix (test + macos-latest + ubuntu-22.04 + windows-latest) on workflow_dispatch

Race in test_kick_scan_is_idempotent: tearDown's tmp.cleanup() ran
while a daemon library-scan thread was still writing
library_cache.json into the tmpdir, yielding OSError [Errno 39]
Directory not empty.

Track spawned scan threads on ChaosEngineState and add a shutdown()
method that joins them. Tests now drain the state before cleaning
up the tmpdir, eliminating the race.
@cryptopoly cryptopoly merged commit 23f93fe into main Apr 29, 2026
6 checks passed
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