Skip to content

test(monitoring): evaluate panel queries on fixture series - #4953

Merged
dan-petty merged 2 commits into
mainfrom
test/4680-panel-query-harness
Nov 12, 2026
Merged

dan-petty merged 2 commits into
mainfrom
test/4680-panel-query-harness

Conversation

@dan-petty

Copy link
Copy Markdown
Owner

No test ran a dashboard panel query, so panels with wrong numbers shipped with no failed test. This adds one evaluator that the dashboard items use.

tests/prometheus/test_dashboard_queries.py reads the cases in tests/fixtures/dashboard_queries/<dashboard>.yaml, replaces the Grafana variables as Grafana does ($__rate_interval from the Min step of the target or the scrape interval of its data source), and runs promtool once for each dashboard. It skips where promtool is not installed. A second test fails when a case query is not the current query of its panel target, and names the dashboard, the panel title and the refId.

devops-cli.yaml holds the four series shapes of the telemetry once each. The promtool run of the alerting tests moves to tests/support/promtool.py. docs/TESTING.md tells how to add a case.

Closes #4680

Change: openspec/changes/archive/2026-11-12-4680-evaluate-panel-queries-on-fixture-series/

Evaluate the queries of the Grafana dashboard panels on fixture series
with the pinned promtool. A case names the panel title, the target refId,
the query and the values of the Grafana variables. The test replaces the
variables as Grafana does and runs promtool once for each dashboard. A
second test fails when a case query is not the current query of its
panel target.

The promtool run of the alerting tests moves to tests/support/promtool.py.
@dan-petty dan-petty added type/test Type test: a new or changed test scope/monitoring Grafana, Prometheus, Loki, alerts and dashboards labels Nov 12, 2026
@dan-petty

Copy link
Copy Markdown
Owner Author

Checks and measurements of this change (devcontainer, promtool 3.15.1, the version of tools.lock):

  • uv run devops ci test tests/prometheus/test_dashboard_queries.py tests/prometheus/test_k8s_monitoring_alerting.py: 96 passed. The promtool tests did not skip.
  • Time: uv run pytest tests/prometheus/test_dashboard_queries.py -n 0 --durations=4 gives 4.27 s for the promtool run of devops-cli.yaml and less than 0.2 s for each other test, on a host that ran other gates at the same time. The new tests add less than 10 s (acceptance criterion 5).
  • Acceptance criterion 2: I changed vector(0) to vector(1) in the query of "AI Spend in Range" in devops-cli.json. test_each_case_holds_the_current_query_of_its_panel_target[devops-cli] failed with devops-cli.json panel 'AI Spend in Range' refId A: the case query is not the panel query, once for each of its 4 cases. I then put the file back.
  • Acceptance criterion 3: I changed the expected value 72 to 73. test_promtool_gives_the_expected_samples_of_each_case[devops-cli] failed with the promtool output in the message (exp: {} 7.3E+01, got: {} 7.2E+01). I then put the file back.
  • Acceptance criterion 4: test_the_cases_hold_each_series_shape passes. devops-cli.yaml has one test group for each of sparse_counter, zero_start, counter_reset and snapshot_gauge.
  • uv run devops ci docs: all documentation files are up to date.

This is a test change, not a fix, so it has no fail-to-pass run.

No live step and no owner step: the change adds tests, a fixture and a document only. CI already installs promtool (step "Install promtool" of ci.yml).

@dan-petty
dan-petty marked this pull request as ready for review November 12, 2026 07:01
@dan-petty
dan-petty merged commit d64c897 into main Nov 12, 2026
23 checks passed
@dan-petty
dan-petty deleted the test/4680-panel-query-harness branch November 12, 2026 07:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

scope/monitoring Grafana, Prometheus, Loki, alerts and dashboards type/test Type test: a new or changed test

Projects

None yet

Development

Successfully merging this pull request may close these issues.

test(monitoring): evaluate panel queries on fixture series

1 participant