Skip to content

test(prom): PromQL parity harness against Prometheus (M3, #922) - #1069

Open
Guess-Who-sec wants to merge 4 commits into
metrico:masterfrom
Guess-Who-sec:test/m3-promql-parity
Open

Guess-Who-sec wants to merge 4 commits into
metrico:masterfrom
Guess-Who-sec:test/m3-promql-parity

Conversation

@Guess-Who-sec

@Guess-Who-sec Guess-Who-sec commented Nov 5, 2026 •

Copy link
Copy Markdown
Contributor

Part of #922 (M3): the PromQL parity harness. Next in #922: baseline ratchet (#1112), triage, release-gate skeleton, k6 fix.

No dependencies: branches from master.

What it does

make parity-prom runs the PromQL compliance suite (Apache-2.0) with a real Prometheus as the reference and gigapipe built from this tree as the target, then prints how many queries agree, differ and were skipped. Report-only: differences don't fail it; the ratchet PR makes it a gate.

No hardcoded versions. The test is in gigapipe's root module behind the parity build tag (no nested go.mod), and the reference Prometheus is installed with go install github.com/prometheus/prometheus/cmd/prometheus@<version in go.mod>, so it always matches gigapipe's go.mod and Dependabot updates both.

How the data gets in: the suite replays a recorded 70-minute dataset through a scrape endpoint. Gigapipe doesn't scrape, so its target scrapes the replayer itself and sends the samples to /api/v1/prom/remote/write. It starts answering the suite's queries only after the replayer has served every snapshot (the first empty scrape) and the reference holds the same data.

Same data on both sides: the replay is scraped every 250ms instead of the suite's 15ms, because Prometheus's scrape timeout is the interval, and a scrape that misses it loses its snapshot on the reference side only. As a check, the reference must hold as many demo_num_cpus samples as were sent to gigapipe, or the setup fails with both counts.

Files

  • compatibility/prometheus/parity_test.go (//go:build parity): the two targets and TestPromQLParity
  • compatibility/prometheus/run.sh: installs Prometheus at go.mod's version, starts the test/integration stack, runs the suite, prints the counts
  • compatibility/prometheus/README.md, .gitignore
  • go.mod / go.sum: add github.com/prometheus/compliance; no existing dependency changes version
  • Makefile: parity-prom target, in .PHONY

Result today (master a2c307c9)

660 queries at the suite's 10s step: 544 agree, 116 differ, 0 skipped, identical query by query across 7 runs (a run now takes ~2.5 min including the gigapipe build; the first go install of Prometheus takes another ~5 min).

  • 113 native-histogram queries: not covered yet; this target doesn't send native histograms.
  • 3 negative offsets (offset -1m, -5m, -10m): gigapipe returns [PQRC001] negative offset is disabled.

The 15 [1h] differences from the first version are gone: the reference now has a 2-hour out-of-order window. Without it, the same run gives 529 / 131 with those 15 back.

At a 60s step (PARITY_STEP=60s make parity-prom), where metrics_15s can be used: 539 agree, 121 differ, 0 skipped, identical across 2 runs. The same 116 plus 5 that differ only at 60s:

  • last_over_time(demo_memory_usage_bytes[1m|5m|15m|1h]): same values, but gigapipe drops the metric name, which Prometheus keeps.
  • predict_linear(demo_disk_usage_bytes[1m], 600): Prometheus returns 3 series, gigapipe none.

service_name is still dropped from the comparison, as agreed; PARITY_KEEP_SERVICE_NAME=1 keeps it.

Verification

What was run:

Potential risks

  • Not in CI yet. It only runs with make parity-prom; the release-gate PR adds it to CI.
  • First run is slow: go install builds Prometheus from source (~5 min, ~140 MB binary in bin/<version>/, gitignored). prometheus --version shows no version number, since go install doesn't set it.
  • Port 3100: uses the integration stack, so it can't run at the same time as test/integration/run.sh.
  • Suite updates change the queries: the compliance module is now updated by Dependabot with the rest of go.mod, so a bump can change the counts; the ratchet PR's baseline will show that.
  • Clean-room: the suite is used as a library dependency; no code is copied. The scrape config in parity_test.go is a standard Prometheus scrape config written for this test.

@socket-security

socket-security Bot commented Nov 5, 2026 •

Copy link
Copy Markdown

Review the following changes in direct dependencies. Learn more about Socket for GitHub.

Diff Package Supply Chain
Security
Vulnerability Quality Maintenance License
Addedgithub.com/​prometheus/​compliance@​v0.0.0-20261029144141-6ae8d35df52c82100100100100

View full report

@Guess-Who-sec

Copy link
Copy Markdown
Contributor Author

@rita7lopes one small thing for your review: run.sh always starts its own gigapipe on port 3100, but it still accepts a different GIGAPIPE_URL if one is set (export GIGAPIPE_URL="${GIGAPIPE_URL:-http://localhost:3100}"). In that case it would build and start the local stack but send the test to the other URL. The README now says to leave it unset when using run.sh. Would you rather run.sh always use http://localhost:3100 (a one-line change), or keep the override?

@Guess-Who-sec

Copy link
Copy Markdown
Contributor Author

@rita7lopes before you review: your reason for dropping tools/ in #1059 partly applies here too. compatibility/prometheus/go.mod is a second module with a hand-written go 1.27.3 that go-version-sync doesn't update (it only edits the root go.mod and the Dockerfiles), and Dependabot doesn't watch it. Its go.sum is about 100 lines. A stale go line there doesn't break the build (it's a minimum), but it's the same upkeep. This ties into question 5 (keep it here or move it to gigapipe-tests). Happy to go either way.

@rita7lopes rita7lopes left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, this is the right approach. A few things before I merge:

  1. Please don't hardcode versions, I don't want to update them by hand. Move the test into the root module (no nested go.mod), and replace the Prometheus download with go install github.com/prometheus/prometheus/cmd/prometheus@$(go list -m -f '{{.Version}}' github.com/prometheus/prometheus). The reference then always matches gigapipe's go.mod, and the checksum table goes away. Please remove version numbers from the README too.
  2. The suite starts querying once the last snapshot is served, and the previous snapshot already satisfies its readiness check, so the first queries can run before the last one is stored. Please start the query proxy only after the first empty scrape.
  3. run.sh should always use its own http://localhost:3100. With GIGAPIPE_URL set in the shell, it writes test data into that instance.
  4. Please count skipped queries too. The suite skips any query whose error contains "501".
  5. The suite queries at a 10s step, so gigapipe answers from raw samples and metrics_15s is never used. Please say so in the README. Before #1112 records a baseline, I'd like a second run at a 60s step.
  6. Please add parity-prom to .PHONY when you update from master.

Your questions: 1 and 2, yes. 3, keep dropping it. 4, record as not covered yet. 5, keep it here. 6, please try storage.tsdb.out_of_order_time_window: 2h on the reference: its up sample is stamped now, so anything older than 1 hour is rejected, which matches the 7 snapshots. With that, both sides should have the same data.

Run the PromQL compliance suite with a real Prometheus 3.15.1 as the
reference and gigapipe built from this tree as the target. Gigapipe
doesn't scrape, so its target scrapes the suite's replayer itself,
remote-writes the samples and proxies the queries. `make parity-prom`
prints how many queries agree; it is report-only for now.

The suite lives in its own module under compatibility/prometheus, so
gigapipe's go.mod and binary are unchanged.
- move the parity test into the root module behind the parity build tag
- install the reference with go install at go.mod's Prometheus version
- start answering queries only after every snapshot is stored
- give the reference a 2h out-of-order window so both sides hold the same data
- always test run.sh's own gigapipe, count skipped queries
- PARITY_STEP rewrites the range query step on both sides
- add parity-prom to .PHONY
@Guess-Who-sec

Copy link
Copy Markdown
Contributor Author

Thanks, all done, rebased onto current master (a2c307c9). Description updated.

  1. Versions: the test is in the root module behind //go:build parity, the nested go.mod is gone, and run.sh installs Prometheus with go install …@$(go list -m -f '{{.Version}}' github.com/prometheus/prometheus) into bin/<version>/. No checksum table, and no version numbers in the README. Root go.mod only gains prometheus/compliance (plus its indirect deps); the gigapipe binary's package list is identical to master's.

  2. Proxy timing: the query proxy now starts after the first empty scrape. In a logged run it started after all 174 snapshots.

  3. GIGAPIPE_URL: run.sh sets http://localhost:3100 unconditionally.

  4. Skipped: run.sh prints agree / differ / skipped. Checked with a planted proxy answering 501 for demo_num_cpus queries: 26 skipped. The other 4 are ShouldFail cases, where any error counts as agreeing before the 501 check.

  5. 10s step: noted in the README (gigapipe reads raw samples for any step under 15s). PARITY_STEP=60s rewrites the range-query step on both sides through a small proxy, since the suite has no option for it. At 60s: 539 agree / 121 differ, the 10s set plus 5:

    • last_over_time(demo_memory_usage_bytes[1m|5m|15m|1h]): same values, but gigapipe drops the metric name.
    • predict_linear(demo_disk_usage_bytes[1m], 600): gigapipe returns no series, Prometheus 3.

    From reading select.go, both are functions metrics_15s can serve (predict_linear because it's missing from supportedFunctions), so they look like rollup-path bugs. Should I open issues for them, or leave them to test(prom): PromQL parity baseline and ratchet (M3, #922) #1112's baseline?

  6. .PHONY: added, on its own .PHONY: parity-prom line next to the target. The shared .PHONY line is also edited by test(integration): seed package and write-read harness for logs (M2 2/4, #920) #1061 (and the PRs stacked on it), so this keeps them merging cleanly.

Your question 6, the out-of-order window: confirmed. With out_of_order_time_window: 2h all 15 [1h] differences agree, 544 agree / 116 differ (113 native histograms, not covered yet, plus the 3 negative offsets). Without it, the same run gives 529 / 131.

I'll rebase #1112 and #1117 onto this next.

The suite scrapes every 15ms and Prometheus caps the scrape timeout at the
interval, so a scrape slower than 15ms was abandoned and its snapshot lost
on the reference side only. Every query covering it then differed: 2 of 9
local runs reported about 250 false differences.

- scrape the replay every 250ms (the suite allows 2 minutes for it)
- before serving queries, check the reference holds as many demo_num_cpus
  samples as were sent to gigapipe, and fail the setup with both counts if
  it doesn't
@Guess-Who-sec

Copy link
Copy Markdown
Contributor Author

One more fix, found while recording #1112's baseline: the harness could lose a snapshot on the reference side.

The suite scrapes every 15ms, and Prometheus caps the scrape timeout at the interval (the running reference reports scrapeTimeout: 15ms). A scrape slower than that is abandoned, but the replayer has already moved on, so that snapshot is missing from the reference only, and every query covering it differs. It happened in 2 of 9 local runs (about 250 false differences each). Delaying one scrape on purpose reproduces it exactly: Prometheus logs context deadline exceeded, and count_over_time gives 11 on the reference against 12 on gigapipe.

Fixed in 669fa5c:

  • The replay is scraped every 250ms (the suite's WithScrapeInterval). It can't go much higher, because the suite allows 2 minutes for the replay. Setup now takes ~49s instead of ~20s.
  • Before gigapipe answers any query, the reference must hold as many demo_num_cpus samples as were sent to gigapipe. If not, the setup fails with both counts instead of reporting differences. With one scrape delayed past the timeout: the reference holds 519 demo_num_cpus samples, gigapipe was sent 522, and run.sh reports that the suite didn't run.

Results unchanged: 3 runs at 10s, 544 / 116, the same queries; 60s, 539 / 121.

This branch has not been deployed

No deployments
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.

2 participants