Skip to content

test(extract): make the fan-out drain test deterministic - #1165

Merged
jasonssdev merged 8 commits into
mainfrom
test/deterministic-fan-out-drain
Sep 30, 2026
Merged

jasonssdev merged 8 commits into
mainfrom
test/deterministic-fan-out-drain

Conversation

@jasonssdev

Copy link
Copy Markdown
Owner

Summary

Makes test_concurrent_fan_out_drains_in_flight_windows_before_it_raises deterministic. The old test ordered a slow window against a failing one with time.sleep(0.3), so on a loaded runner window 1 could be cancelled before it started and the drained flag was never set. The new test orders everything with threading.Events: window 0 fails only after window 1 is provably in its call, window 1 stays there until the test releases it, and the test asserts the fan-out is still running while window 1 is in flight, then that it raised OllamaUnavailable after the drain. Test-only; no production change.

Related issue

Closes #1164

Type of change

  • Tests

How was this tested?

  • New test passes 200 consecutive runs in a shell loop, no failure.
  • Mutation: changing pool.shutdown(wait=True, ...) to wait=False in extraction/concept.py turns the test red (assert runner.is_alive(), "fan-out returned with a window in flight"); reverted byte-exactly and __pycache__ purged.
  • ruff check ., ruff format --check ., mypy . clean; tests/unit/extraction/test_concept.py 368 passed.

Checklist

  • Conventional Commit title with a project scope
  • Tests added or updated
  • No CHANGELOG entry (test-only)

Notes for reviewers

The bounded runner.join(timeout=0.5) only bounds the failing (mutant) case; with a correct drain the runner cannot finish while window 1 is held, so the assertion cannot flake.

Other time.sleep( used for thread ordering in tests/unit/extraction and tests/unit/cli/test_ingest.py: none. The only remaining match is a docstring at test_concept.py (_WindowKeyedLLM-adjacent test) that explains why a sleep is not used.

@jasonssdev
jasonssdev merged commit 2eba5ab into main Sep 30, 2026
9 checks passed
@jasonssdev
jasonssdev deleted the test/deterministic-fan-out-drain branch September 30, 2026 18:44
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.

bug: test_concurrent_fan_out_drains_in_flight_windows_before_it_raises is timing-dependent and flakes on CI

1 participant