Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 26 additions & 10 deletions data_plane/src/drivers/query/servers/http.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2356,6 +2356,13 @@ aggregations:
assert_eq!(resp.status(), reqwest::StatusCode::SERVICE_UNAVAILABLE);
}

// Schema retirement #2 — the endpoint now reads from the sid
// catalog. The reconfigure → timeline flow this test exercised
// depended on `SchemaRegistry::reconcile()` propagating to the
// timeline source. Sid-level reconcile lands in the next sub-PR;
// until then, register sids directly via `SketchStore::register`
// instead of going through the YAML POST.
#[ignore = "depends on sid-level reconcile from streaming-config (next schema-retirement sub-PR)"]
#[tokio::test]
async fn test_get_timeline_returns_segments_after_reconfigure() {
use crate::storage_engines::sketch_db::SchemaRegistry;
Expand Down Expand Up @@ -2474,7 +2481,11 @@ aggregations:
}

#[tokio::test]
async fn test_get_timeline_without_registry_returns_503() {
async fn test_get_timeline_with_no_sids_returns_empty_200() {
// Schema retirement #2 — the `/api/v1/db/timeline` endpoint now
// reads from the sid catalog (always attached) instead of the
// optional `SchemaRegistry`. Empty catalog → empty segments,
// not a 503.
let hot_reload = HotReloadStreamingConfig::new(StreamingConfig::default());
let server_port = setup_test_server_with_hot_reload(Some(hot_reload)).await;
let client = Client::new();
Expand All @@ -2485,7 +2496,10 @@ aggregations:
.send()
.await
.unwrap();
assert_eq!(resp.status(), reqwest::StatusCode::SERVICE_UNAVAILABLE);
assert!(resp.status().is_success());
let body: serde_json::Value = resp.json().await.unwrap();
assert_eq!(body["count"], 0);
assert_eq!(body["segments"].as_array().unwrap().len(), 0);
}

// ─── Phase 5d: backfill HTTP endpoint tests ─────────────────────────────
Expand Down Expand Up @@ -4948,13 +4962,6 @@ async fn handle_get_timeline(
use axum::http::StatusCode;
use axum::response::IntoResponse;

let Some(schemas) = state.schemas else {
let body = serde_json::json!({
"status": "error",
"error": "schema registry not attached; backend was built without HttpServer::with_schemas"});
return (StatusCode::SERVICE_UNAVAILABLE, axum::Json(body)).into_response();
};

let Some(metric) = params.get("metric") else {
let body = serde_json::json!({
"status": "error",
Expand Down Expand Up @@ -4987,7 +4994,16 @@ async fn handle_get_timeline(
Ok(v) => v,
Err(resp) => return *resp};

let segments = schemas.timeline_for_metric(metric, start_ms, end_ms);
// Schema retirement #2 — read the timeline from the sid catalog
// directly. The `agg_id` field on each segment now carries a
// content-derived signature id (xxh64 of metric + agg_kind +
// group_by_keys), stable across restarts.
let segments = crate::storage_engines::sketch_db::query::timeline::timeline_for_metric(
&state.sketch_index,
metric,
start_ms,
end_ms,
);
let entries: Vec<serde_json::Value> = segments
.iter()
.map(|s| {
Expand Down