Skip to content

test(engine): end-to-end tests for schema-timeline query dispatch - #50

Merged
zzylol merged 1 commit into
mainfrom
test/phase3-cross-boundary-e2e
Apr 20, 2026
Merged

zzylol merged 1 commit into
mainfrom
test/phase3-cross-boundary-e2e

Conversation

@zzylol

@zzylol zzylol commented Apr 20, 2026

Copy link
Copy Markdown
Contributor

Summary

Adds three end-to-end tests against a real SimpleEngine + SimpleMapStore + SchemaRegistry that exercise the full path from a PromQL query → schema registry lookup → per-segment store query → combine_statistic → Prometheus warnings.

Also sweeps the codebase of Phase 3 / Phase 3a / Phase 3b-2-b rollout-stage labels that no longer add signal and replaces them with functional names — schema-timeline dispatch, §7 timeline, per-segment dispatch. The underlying mechanism is unchanged; only comments, doc-strings, debug-log text, and the test-file name move.

Tests

  1. sum_query_across_reconfigure_boundary_returns_combined_full_result
    Two agg_ids for the same metric, boundary in the middle of the query range, each seeded with one SumAccumulator. Retired-but-not-Expired coverage so both segments are Sketch. Asserts Full(30.0) = 10.0 + 20.0 combined, no warnings.

  2. sum_query_with_purged_segment_returns_partial_with_warnings
    Same topology but agg_1 is Expired → coverage is Purged. Dispatcher puts agg_1 in unresolved, executes only agg_2 (20.0), and combine_statistic(Sum) returns Partial { covered: Some(20.0), missing: [agg_1 segment] }. Asserts the response carries the best-effort scalar AND a populated warnings list that references the metric, the unresolved agg_id=1, and GET /api/v1/db/timeline.

  3. single_schema_query_falls_through_to_default_path
    Regression guard: one schema, no boundary in the query range → dispatcher returns None, default single-agg path answers, no warnings attach.

Placement

src/tests/schema_timeline_dispatch_tests.rs (inside the crate, not tests/) so the tests can reach #[cfg(test)] SchemaRegistry::insert_raw_for_testing without leaking a test-only API into the public crate surface. Uses the same (ts, ts) single-point-bucket seed pattern as engine_factories, adjusted with a host label because the engine's format_final_results drops None-keyed elements.

Rename sweep

All Phase 3… labels in the code comments / docstrings / debug-log strings for this feature now read as the functional thing they describe:

Before After
Phase 3b-2-b: per-segment dispatch Per-segment dispatch across the §7 schema timeline
Phase 3 timeline dispatch: (log) schema-timeline dispatch:
Phase 3b-2-a refactor extracted forced-agg-id entry point
Phase 3a added the §7 timeline read API §7 schema timeline read API

Unrelated "Phase 3: T2 sweep" in flusher.rs (persistence step numbering, not sketch-db rollout phase) is left alone.

Engine tweak

try_handle_query_promql_via_timeline gained two debug! lines — per-segment result count and pre-combine groups/unresolved summary — so operators can correlate per-segment behaviour in production logs. No behaviour change.

Validation

  • cargo test -p query_engine_rust --lib737 pass (+3)
  • cargo clippy --all-targets -- -D warnings — clean
  • cargo fmt --all -- --check — clean

🤖 Generated with Claude Code

Adds three e2e tests against a real `SimpleEngine +
SimpleMapStore + SchemaRegistry` that exercise the full path
from a PromQL query → schema registry lookup → per-segment
store query → `combine_statistic` → Prometheus `warnings`.

Also sweeps the codebase of "Phase 3 / Phase 3a / Phase 3b-2-b"
rollout-stage labels that no longer add signal and replaces
them with functional names — schema-timeline dispatch, §7
timeline, per-segment dispatch. The underlying mechanism (an
already-merged method on `SimpleEngine`) is unchanged; only
comments, doc-strings, debug-log text, and the test-file
name move.

## Tests

1. `sum_query_across_reconfigure_boundary_returns_combined_full_result`
   Two agg_ids for the same metric, boundary in the middle of
   the query range, each seeded with one SumAccumulator.
   Retired-but-not-Expired coverage so both segments are
   `Sketch`. Asserts the result is `Full(30.0)` = 10.0 + 20.0
   combined, with no warnings.

2. `sum_query_with_purged_segment_returns_partial_with_warnings`
   Same topology but agg_1 is Expired → coverage is `Purged`.
   The dispatcher puts agg_1 in `unresolved`, executes only
   agg_2 (20.0), and `combine_statistic(Sum)` returns
   `Partial { covered: Some(20.0), missing: [agg_1 segment] }`.
   Asserts the response carries the best-effort scalar AND a
   populated `warnings` list referencing the metric, the
   unresolved `agg_id=1`, and the `GET /api/v1/db/timeline`
   read API.

3. `single_schema_query_falls_through_to_default_path`
   Regression guard — one schema, no boundary in the query
   range, dispatcher returns `None`, default single-agg path
   answers, no warnings attach.

Placement: `src/tests/schema_timeline_dispatch_tests.rs`
(inside the crate, not `tests/`) so we can reach the
`#[cfg(test)] SchemaRegistry::insert_raw_for_testing` helper
without leaking a test-only API into the public crate surface.
Seed pattern mirrors `engine_factories` — `(ts, ts)` single-
point buckets plus a `host` label because the engine's
`format_final_results` drops None-keyed elements.

Engine tweak in the same PR: `try_handle_query_promql_via_timeline`
gained two `debug!` lines — per-segment result count and
pre-combine groups / unresolved summary — so operators can
correlate per-segment behaviour in production logs. No
behaviour change.

737 lib tests pass (+3), clippy clean, fmt clean.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@zzylol zzylol changed the title test(engine): Phase 3 cross-boundary e2e — task #34 gap #3 test(engine): end-to-end tests for schema-timeline query dispatch Apr 20, 2026
@zzylol
zzylol force-pushed the test/phase3-cross-boundary-e2e branch from b0793f7 to 0d88366 Compare April 20, 2026 17:16
@zzylol
zzylol merged commit 2f94bfc into main Apr 20, 2026
@zzylol
zzylol deleted the test/phase3-cross-boundary-e2e branch April 20, 2026 17:19
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