Add integration test for get_duration_drift() window query against real TimescaleDB #70

Open
opened 2026-06-21 13:59:00 +00:00 by gertjan · 0 comments
Owner

Follow-up to #68 (duration-drift detection).

TaskRunRepository.get_duration_drift() is only covered by unit tests that mock fetchrow — the actual SQL (percentile_cont median, stddev_pop, the FILTER (WHERE rn > 1) baseline-excludes-latest logic, and the ROW_NUMBER() ... LIMIT N+1 window) is never executed against a real database.

Action: add an integration test (tests/integration/) that:

  • seeds task_runs with a known sequence of success runs + durations,
  • asserts latest, baseline_median, baseline_std, baseline_count come back correct,
  • verifies the latest run is excluded from its own baseline,
  • verifies the None (too-little-history) gate at the SQL boundary.

Reference: src/database/repositories/task_runs.py get_duration_drift().

Follow-up to #68 (duration-drift detection). `TaskRunRepository.get_duration_drift()` is only covered by unit tests that mock `fetchrow` — the actual SQL (`percentile_cont` median, `stddev_pop`, the `FILTER (WHERE rn > 1)` baseline-excludes-latest logic, and the `ROW_NUMBER() ... LIMIT N+1` window) is **never executed against a real database**. **Action:** add an integration test (`tests/integration/`) that: - seeds `task_runs` with a known sequence of `success` runs + durations, - asserts `latest`, `baseline_median`, `baseline_std`, `baseline_count` come back correct, - verifies the latest run is excluded from its own baseline, - verifies the `None` (too-little-history) gate at the SQL boundary. Reference: `src/database/repositories/task_runs.py` `get_duration_drift()`.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
gertjan/bodega#70
No description provided.