From 6e51c2dbd601a6c8cc5145f5848b06511e92329f Mon Sep 17 00:00:00 2001 From: Neeraj Gartia <80708727+NeerajGartia21@users.noreply.github.com> Date: Tue, 1 Apr 2025 15:42:23 +0530 Subject: [PATCH] [FEATURE] Promltest: support to test expectation annotations (#15995) promqltest: add new expect lines for promql testing framework --------- Signed-off-by: Neeraj Gartia --- promql/promqltest/README.md | 84 ++++++--- promql/promqltest/test.go | 214 +++++++++++++++++++++-- promql/promqltest/test_test.go | 311 +++++++++++++++++++++++++++++++++ 3 files changed, 563 insertions(+), 46 deletions(-) diff --git a/promql/promqltest/README.md b/promql/promqltest/README.md index 25c2653ab3..8854e74724 100644 --- a/promql/promqltest/README.md +++ b/promql/promqltest/README.md @@ -22,7 +22,9 @@ Each test file contains a series of commands. There are three kinds of commands: * `load` * `clear` -* `eval` (including the variants `eval_fail`, `eval_warn`, `eval_info`, and `eval_ordered`) +* `eval` + +> **Note:** The `eval` command variants (`eval_fail`, `eval_warn`, `eval_info`, and `eval_ordered`) are deprecated. Use the new `expect` lines instead (explained in the [`eval` command](#eval-command) section). Additionally, `expected_fail_message` and `expected_fail_regexp` are also deprecated. Each command is executed in the order given in the file. @@ -73,8 +75,8 @@ When loading a batch of classic histogram float series, you can optionally appen ## `eval` command -`eval` runs a query against the test environment and asserts that the result is as expected. -It requires the query to succeed without any (info or warn) annotations. +`eval` runs a query against the test environment and asserts that the result is as expected. +It requires the query to succeed without any failures unless an `expect fail` line is provided. Previously `eval` expected no `info` or `warn` annotation, but now `expect no_info` and `expect no_warn` lines must be explicitly provided. Both instant and range queries are supported. @@ -83,12 +85,18 @@ The syntax is as follows: ``` # Instant query eval instant at