test(promql): share the repartition and fused series test fixtures (#10787)

* test(promql): consolidate series repartition test children

Replace the seven copies of the scripted child plan with one TestChild
whose partitions are opened by a closure, and give RawPartition
constructors for its three shapes. Merge the identical output/output_of
helpers and drop the unused raw late-failure path.

The output queues are unbounded, so comments and fixture sizes that
assumed a full queue were wrong; restate those tests by what they
exercise and remove TEST_FIXTURE_VOLUME. Rename tests whose names
contradicted their assertions and trim narrating comments.

Remove three tests whose path is covered elsewhere:
- same_canonical_key_chains_merge_into_one_series, covered by
  multiple_producers_and_owners_merge_exact_full_label_identities
- a_child_partition_that_fails_mid_stream_ends_every_output_with_its_error,
  folded into a_child_failure_is_terminal_on_every_output
- dropping_a_raw_destination_releases_its_partial_chain, the one-chunk
  case of dropping_a_raw_open_chain_cancels_and_releases_its_reservation

Signed-off-by: Dennis Zhuang <killme2008@gmail.com>

* test(promql): trim fused series test setup and dead checks

Add frame_node, state_export_node, final_node, explicit and
decode_frames helpers for the node builds, input tuples and frame
decodes repeated across the file; move frame_decode up so both test
modules share it.

binding_of ignored its schema argument, so drop it, and drop the
equality check that compared two bindings built the same way. The
state-export decode test serializes the node directly: serialize
refuses nothing, so the payload rewrite it worked around is not needed.

empty_first_source_does_not_end_gather_early could not fail, since a
one-to-one match with an empty left side answers nothing either way.
Give the left side fill(0) so an early end changes the answer.

Remove two tests whose path is covered elsewhere:
- a_single_consumer_keeps_the_empty_closing_chunk_in_its_frame,
  same fixture and assertions as
  a_frame_carries_the_closing_chunk_a_row_table_drops
- series_frame_rate_matches_plain_rows_bitwise, covered by
  frame_output::abs_rate_frame_matches_plain_rows_with_exact_values_and_labels

Also fix a comment cut mid-sentence and drop comments that narrate
review history.

Signed-off-by: Dennis Zhuang <killme2008@gmail.com>

* test(promql): name two repartition tests for what they pin

Signed-off-by: Dennis Zhuang <killme2008@gmail.com>

* test(promql): restore the checks the merged exchange tests dropped

Signed-off-by: Dennis Zhuang <killme2008@gmail.com>

* test(promql): compare frame and plain rows for a bare rate root too

Signed-off-by: Dennis Zhuang <killme2008@gmail.com>

---------

Signed-off-by: Dennis Zhuang <killme2008@gmail.com>
This commit is contained in:
dennis zhuang
2026-12-02 10:36:53 +00:00
committed by GitHub
parent 6a3ad83333
commit 97f7db3dec
3 changed files with 826 additions and 2211 deletions
File diff suppressed because it is too large Load Diff
@@ -46,23 +46,6 @@ fn instant_tree(schema: Arc<SeriesSchema>, grid: Arc<EvalGrid>) -> NativeTree {
.expect("instant selector tree is valid")
}
async fn frame_decode(
exec: Arc<dyn ExecutionPlan>,
) -> Vec<(datatypes::series::samples::Series, bool)> {
let batches = collect(Arc::clone(&exec), SessionContext::default().task_ctx())
.await
.expect("frame output executes");
let stream = Box::pin(RecordBatchStreamAdapter::new(
exec.schema(),
futures::stream::iter(batches.into_iter().map(Ok)),
));
unpack_evaluated_series(stream, None)
.expect("evaluated frame schema decodes")
.try_collect::<Vec<_>>()
.await
.expect("evaluated frame decodes")
}
fn compact_float_rows(
decoded: &[(datatypes::series::samples::Series, bool)],
) -> Vec<(i64, Vec<Option<u64>>)> {
@@ -156,7 +139,7 @@ async fn sparse_instant_frame_preserves_positions_nulls_and_nan_across_formats()
true,
);
let batches = vec![frame_of(&schema, &chunk)];
let binding = binding_of(&tree, Arc::clone(&schema), vec![HOST.into(), NAME.into()]);
let binding = binding_of(&tree, vec![HOST.into(), NAME.into()]);
let make_node = |format| {
FusedSeries::try_new_with_format(
Arc::from("instant(x)"),
@@ -202,9 +185,9 @@ async fn sparse_instant_frame_preserves_positions_nulls_and_nan_across_formats()
}
#[tokio::test]
async fn abs_rate_frame_matches_plain_rows_with_exact_values_and_labels() {
async fn rate_frame_matches_plain_rows_with_exact_values_and_labels() {
let rate = rate_tree();
let tree = NativeTree::try_new(NativeNode {
let abs_rate = NativeTree::try_new(NativeNode {
expr: NativeExpr::Map {
input: Box::new(rate.root().clone()),
op: BoundMap {
@@ -214,11 +197,17 @@ async fn abs_rate_frame_matches_plain_rows_with_exact_values_and_labels() {
output: rate.root().output.clone(),
})
.unwrap();
for (promql, tree) in [("rate(x[5m])", rate), ("abs(rate(x[5m]))", abs_rate)] {
assert_frame_matches_plain_rows(promql, tree).await;
}
}
async fn assert_frame_matches_plain_rows(promql: &'static str, tree: NativeTree) {
let batches = two_series_frames();
let binding = binding(&tree);
let make_node = |format| {
FusedSeries::try_new_with_format(
Arc::from("abs(rate(x[5m]))"),
Arc::from(promql),
tree.clone(),
binding.clone(),
vec![input_plan(frame_schema())],
@@ -319,7 +308,7 @@ async fn rewritten_identical_labels_keep_disjoint_chains_in_one_encoder() {
),
];
let batches = frames_of(&schema, &chunks);
let binding = binding_of(&tree, Arc::clone(&schema), vec![HOST.into(), NAME.into()]);
let binding = binding_of(&tree, vec![HOST.into(), NAME.into()]);
let make_node = |format| {
FusedSeries::try_new_with_format(
Arc::from("rewritten instant"),
File diff suppressed because it is too large Load Diff