Skip to content

test: drain test waits via fetched recorder, not SQL poll#48

Merged
lesnik512 merged 3 commits into
mainfrom
fix/drain-test-flake-recorder
Jun 9, 2026
Merged

test: drain test waits via fetched recorder, not SQL poll#48
lesnik512 merged 3 commits into
mainfrom
fix/drain-test-flake-recorder

Conversation

@lesnik512

Copy link
Copy Markdown
Member

Summary

  • Removes a Python 3.13/3.14 timing flake in test_drain_finishes_inflight_rows_before_returning that caused the 3.14 matrix leg to miss 1 line of coverage (tests/test_integration.py:1125, the await asyncio.sleep(0.02) inside _wait_until_claimed).
  • Replaces the SQL-poll wait helper with observation of the broker's existing fetched recorder event. The single-caller helper _wait_until_claimed is deleted.
  • Test-only refactor; no production code touched.

Why

On Python 3.13 the test's first SQL poll observed some rows still unclaimed → loop iterated → await asyncio.sleep(0.02) ran → 100% coverage. On 3.14 the worker reliably fetched before the first poll → loop returned on iteration 1 → sleep never ran → 99.98% → fail-under gate trips.

The race is in the test (observation window between publish-commit and worker-fetch), not the package. Observing fetch progress through the broker's own recorder seam removes the race because the event fires at the fetch moment, with no separate observation window.

See planning/specs/2026-06-09-drain-test-flaky-fetch-observation-design.md for the full rationale and planning/plans/2026-06-09-drain-test-flaky-fetch-observation-plan.md for the executed plan.

Test plan

  • just test tests/test_integration.py::test_drain_finishes_inflight_rows_before_returning -v --no-cov passes locally on 3.13
  • just test tests/test_integration.py -v reports tests/test_integration.py at 100% (806 stmts, 0 missed)
  • just lint clean
  • CI 3.13 matrix leg green at 100%
  • CI 3.14 matrix leg green at 100% (this is the leg the change targets)

🤖 Generated with Claude Code

lesnik512 and others added 3 commits June 9, 2026 23:42
Replaces SQL-poll wait helper in test_drain_finishes_inflight_rows_before_returning
with recorder-based fetch observation, removing the 3.13/3.14 timing race that
caused a 99.98% coverage miss on line 1125 of tests/test_integration.py.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Implementation plan for the recorder-based wait refactor of
test_drain_finishes_inflight_rows_before_returning. Three tasks:
baseline confirmation, the refactor itself (with deletion of
_wait_until_claimed), and CI verification on both Python matrix legs.

Spec: planning/specs/2026-06-09-drain-test-flaky-fetch-observation-design.md

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Removes _wait_until_claimed and migrates the lone caller
(test_drain_finishes_inflight_rows_before_returning) to observe
the broker's fetched recorder event. The SQL-poll variant had
a Python 3.13/3.14 timing race that left tests/test_integration.py:1125
uncovered on 3.14, tripping the 100% fail-under gate.

Spec: planning/specs/2026-06-09-drain-test-flaky-fetch-observation-design.md
@lesnik512 lesnik512 self-assigned this Jun 9, 2026
@lesnik512 lesnik512 merged commit 9e98a9e into main Jun 9, 2026
3 checks passed
@lesnik512 lesnik512 deleted the fix/drain-test-flake-recorder branch June 10, 2026 06:04
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