m12-pr16: partition rotation health invariants (tests/db/test_partition_health.py)#34
Open
BalaShankar9 wants to merge 1 commit into
Open
m12-pr16: partition rotation health invariants (tests/db/test_partition_health.py)#34BalaShankar9 wants to merge 1 commit into
BalaShankar9 wants to merge 1 commit into
Conversation
…on_health.py) Adds 15 unit tests pinning health invariants for the events_outbox partition rotation introduced in m7-pr27a (ADR-0037). Complements the existing tests/integration/test_outbox_partitions.py (migration regex + opt-in live-DB) by covering gaps that integration test does not: Time-math (5 tests, pure helper mirroring SQL date_trunc + i months) - YYYY_MM zero-pad - current month + N (count = N+1) - year roll at December - 25-month span at max lookahead, monotonic, no dups - day-of-month invariance Cross-file contract (8 tests against migration / runbook / ADR) - bootstrap and cron use identical months_ahead (=4) - p_months_ahead bounds 0..24 RAISE present - EXCEPTION WHEN OTHERS still inserts audit row with err_msg - audit columns pinned (table_name text, ran_at timestamptz, etc.) - cron command body is bare function call (no error-swallowing wrapper) - daily 00:01 UTC schedule literal - runbook 36h alert window contract (24h cadence + 12h grace) - ADR-0037 status remains Accepted - SAFETY header references ADR-0037 Sanity (1 test): helper count vs constant. Why "health" vs existing rotation tests: the migration tests pin WHAT was deployed; these pin the INVARIANTS the daily job and alert depend on. If someone changes cron to twice-daily but forgets to update the runbook alert window, or renames an audit column the Prometheus query reads, that drift now fails CI. Files - backend/tests/db/__init__.py (new, empty) - backend/tests/db/test_partition_health.py (new, 15 tests) - context/TESTING_CONTEXT.md (moved from Planned to Shipped m12-pr16) - context/CHANGELOG_INTELLIGENCE.md (m12-pr16 row) Validation - pytest tests/db/test_partition_health.py -v -> 15 passed in 0.03s - No other tests touched; no production code touched. Stacked on PR #33 (m12-pr15). Base branch: m12-pr15-test-dlq.
There was a problem hiding this comment.
Pull request overview
Adds a new “health invariants” unit test suite that statically pins the cross-file contract for events_outbox partition rotation (migration ↔ cron schedule ↔ runbook ↔ ADR), complementing the existing integration coverage.
Changes:
- Added 15 unit tests (
backend/tests/db/test_partition_health.py) that verify time-math invariants and contract invariants across the rotation migration, runbook, and ADR. - Added
backend/tests/db/__init__.pyto establish thetests/dbpackage. - Updated context docs to mark this test suite as shipped and to add the m12-pr16 changelog ledger row.
Reviewed changes
Copilot reviewed 3 out of 4 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| context/TESTING_CONTEXT.md | Moves the partition health tests entry from “Planned” to “Shipped (m12-pr16)”. |
| context/CHANGELOG_INTELLIGENCE.md | Adds the m12-pr16 ledger row and links m12-pr15 to PR #33. |
| backend/tests/db/test_partition_health.py | New unit tests that pin partition rotation invariants across migration/runbook/ADR plus pure time-math helper checks. |
| backend/tests/db/init.py | New (empty) package marker for backend/tests/db. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
m12-pr16: partition rotation health invariants (tests/db/test_partition_health.py)
Adds 15 unit tests pinning health invariants for the events_outbox
partition rotation introduced in m7-pr27a (ADR-0037). Complements the
existing tests/integration/test_outbox_partitions.py (migration regex
Time-math (5 tests, pure helper mirroring SQL date_trunc + i months)
Cross-file contract (8 tests against migration / runbook / ADR)
Sanity (1 test): helper count vs constant.
Why "health" vs existing rotation tests: the migration tests pin
WHAT was deployed; these pin the INVARIANTS the daily job and alert
depend on. If someone changes cron to twice-daily but forgets to
update the runbook alert window, or renames an audit column the
Prometheus query reads, that drift now fails CI.
Files
Validation
Stacked on PR #33 (m12-pr15). Base branch: m12-pr15-test-dlq.