test(materialization): GC + scheduler state-machine transition coverage#902
Open
girishjeswani wants to merge 3 commits into
Open
test(materialization): GC + scheduler state-machine transition coverage#902girishjeswani wants to merge 3 commits into
girishjeswani wants to merge 3 commits into
Conversation
…cords-only cascade deletes Hardens garbage-collection coverage for the materialization service (fast-follow to malloydata#888, split out per review as malloydata#895): - deleteMaterialization telemetry: a successful physical-table drop meters outcome=success; a failed drop meters outcome=failure and still deletes the record, so a best-effort drop failure never surfaces to the caller. - buildOneSource staging cleanup: the original build error propagates when the staging-cleanup drop itself fails (leak logged), and a cancelled mid-run build drops its staging table like a failure — no _staging orphan. - Cascade deletes are records-only: deleteByEnvironmentId / deleteByPackage issue a single DELETE and no DDL, documenting that physical-table GC is the caller's responsibility so a materialized table intentionally outlives its record on an env/package delete. Contract comment added on both repo methods. Covers items 1-3 of malloydata#895; the state-machine transition tests (item 4) follow once malloydata#888's scheduler lands on main. Signed-off-by: Girish Jeswani <[email protected]>
…ne transitions Drives the scheduler's transitions end to end against the real store (malloydata#895, item 4), complementing the per-tick unit guards: - a cron edit between ticks re-arms from now (no stale fire from the old cadence) - a package unload/reload prunes arming state and re-anchors without a spurious fire - a fired occurrence advances to the next occurrence (fires once per occurrence, not every tick; the advance is outcome-independent, so the FAILED-fire isolation stays unit-covered) - maxFiresPerTick caps a tick and the capped package fires on the next tick Each test uses its own environment and tears it down in afterEach, since the scheduler sweeps every loaded environment. Signed-off-by: Girish Jeswani <[email protected]>
The integration version drove the prune + re-anchor transition via a package delete + same-name re-add, which races the package-install staging rename on Windows (ENOENT on the staging->final rename; POSIX handles it) — unrelated to the scheduler logic under test. The transition is pure in-memory arming state, so it's now a deterministic unit test in materialization_scheduler.spec.ts (mutating the fake loaded set). The other three transitions stay as integration tests. Signed-off-by: Girish Jeswani <[email protected]>
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.
Summary
Closes #895 — the GC + state-machine-transition coverage split out of #888. All additive tests plus one documenting comment; no behavior change.
Garbage collection
deleteMaterialization({ dropTables })metersrecordDropTables("success")on a successful physical-table drop and("failure")when the drop throws — and the record is still deleted (a best-effort drop failure never surfaces to the caller). Asserted via the OTel in-memory harness._stagingorphan. (Build-SQL failure was already covered.)deleteByEnvironmentId/deleteByPackageissue a singleDELETEand no DDL. A materialized table intentionally outlives its record on env/package delete — physical GC is the caller's responsibility (same contract asdeleteMaterialization's default). Locked in with SQL-shape tests + a contract comment on both repo methods, so a future refactor can't silently add aDROPthere. This is the "explicit decision, not silent" the feat(materialization): standalone scheduler, environment-scoped listing, and schedule management UI #888 review asked to keep visible; the optional standalone cascade-drop is tracked in Optional: standalone cascade-drop of materialized tables on env/package delete #901.State-machine transitions (integration, real store)
Complements the per-tick unit guards by driving each transition end to end through REST-created packages the scheduler sweeps:
now(no stale fire from the old cadence)FAILED-fire isolation stays unit-covered — a genuine failed build isn't reliably reproducible without a brittle fixture)maxFiresPerTickcaps a tick and the capped package fires on the next tickEach transition test uses its own environment and tears it down in
afterEach, since the scheduler sweeps every loaded environment.Testing
typecheck+eslintclean on changed files.Notes