Skip to content

test(prof): pin the profiles series discovery response (M5, #919) - #1114

Open
Guess-Who-sec wants to merge 8 commits into
metrico:masterfrom
Guess-Who-sec:test/m5-prof-series-golden
Open

Guess-Who-sec wants to merge 8 commits into
metrico:masterfrom
Guess-Who-sec:test/m5-prof-series-golden

Conversation

@Guess-Who-sec

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

Copy link
Copy Markdown
Contributor

Part of #919 (M5): the series/labels discovery golden.

Depends on #1062 (M2 3/4), which depends on #1061: this branch is built on them, so its first 7 commits are theirs (#1061: 4, #1062: 3). Merge those first; I'll rebase this one onto master then. Only the last commit is new here.

Why this is the only golden left for M5

Your re-scope of #919 keeps hand-written response goldens for one merge, one diff and one series/labels discovery. M2 already pins the first two:

Shape Golden
merge profiles/render_cpu.json (/pyroscope/render) and profiles/flamegraph_cpu.json (Connect SelectMergeStacktraces), in #1062
diff profiles/render_diff_cpu.json (/pyroscope/render-diff), in #1062
series/labels discovery this PR: profiles/series.json (Connect Series)

#1062 checks label names and values but pins no discovery response, and doesn't call Series at all.

What it does

A series check in test/integration/profiles_roundtrip_test.go calls /querier.v1.QuerierService/Series with the run's matcher, as the other profile checks do:

  • Behaviour first: exactly one series per pod and sample type. The fixture uploads 4 pods (checkout p1/p2/p3, payments p1), each with samples/count and cpu/nanoseconds, so 8 series. No label may appear twice in a series.
  • Then the golden: the response is compared with testdata/profiles/series.json. The run label value becomes RUN and series are sorted (the same normalisation as the other goldens); label order within a series isn't compared.

series.json is written by hand, with no regeneration command. I checked each of the 8 entries against the fixture: the profile-type labels match the cpuNanosType / cpuSamplesType constants the other checks use, and service_name, pod and m2_run are exactly what the upload sends.

labelNames isn't sent, so every label comes back. A request with labelNames (only those labels kept, FilterLabelsPlanner) is another shape and isn't covered here.

Question

#919's determinism audit item (no ambient time or rand in the prof transpiler's decisions and responses) isn't in your keep or drop lists. Keep it as a separate task, or drop it? The goldens above pass identically across runs, which covers the responses they pin but isn't the audit #919 describes.

Verification

After rebasing onto the updated #1062 and current master (ClickHouse 26.10): the whole integration suite passes on a fresh stack via test/integration/run.sh (19 tests, including the series case), and gofmt, go vet (no new findings), the build, go test ./..., golangci-lint and staticcheck are clean. The rebase needed no change to this PR.

Earlier results, before the rebase:

  • test/integration/run.sh: 3 runs, 52 passed, 0 failed each
  • Planted change 1: removing the __period_unit__ label from the Series response in reader/service/prof.go fails only series, with "response differs from testdata/profiles/series.json (edit the file by hand if the change is intended)"; its behaviour checks and every other check still pass. Reverted.
  • Planted change 2: sending pod twice in every Series label set fails only series, with label "pod" appears twice in series ... for all 8 series. Reverted.
  • The CI lane's path (ClickHouse 24.9.1 container, make build, make integration-start, make test-integration): 52 passed, 0 failed
  • golangci-lint with --build-tags integration (the default lint run skips these files): 0 issues; go vet -tags integration ./test/integration/ and gofmt clean; root go build ./... and go test ./... pass (37 packages)

Potential risks

metrico#920)

The integration workflow built, started and tested gigapipe with raw
commands. It now runs make build, make integration-start and
make test-integration, and test/integration/run.sh runs the same
make test-integration, so CI and local runs are the same commands.

integration-start waits up to 60s for /api/v1/status/buildinfo and prints
gigapipe.log if gigapipe never answers.
run.sh changed to the repository root before running the tests, but the
EXIT trap runs `docker compose -f docker-compose.yml` with a relative
path, so teardown failed (hidden by `|| true`) and left the gigapipe and
ClickHouse containers running after every run. Run the tests in a
subshell so the trap still runs from test/integration.
…/4, metrico#920)

Add test/integration/seed, a deterministic declaration of the data the
integration tests write: services and pods, from which every signal is
derived. Logs are generated with a fixed random seed, so the same fixture
always produces the same push body; Run only sets the m2_run label that
keeps one run's data apart from earlier runs.

TestLogsRoundTrip pushes the fixture through /loki/api/v1/push and checks
what the Loki read APIs return against it, one named case each: every line
per stream, a line filter, the json parser with a label filter,
count_over_time per pod, labels, label values and series.

The query_range, instant query, label values and series responses are also
compared with pinned copies under testdata/logs/, since that JSON is what
Grafana reads. Run-specific values (the run label, timestamps) are
normalized before the comparison. The pins are maintained by hand; there is
no regeneration mode.

gigapipe's labels endpoint ignores the query parameter Loki uses to narrow
it to a selector, so that case cannot be limited to one run; the series
case covers the label sets.
…ctly (M2 2/4, metrico#920)

Review of metrico#1061: the label values come from SELECT DISTINCT without
ORDER BY, so they are sorted before comparing. The pinned responses are
decoded strictly: an undeclared field or data after the response fails,
and log entries and vector samples must have exactly two elements.
gigapipe.log and gigapipe.pid, created by make integration-start, are
ignored.
…(M2 3/4, metrico#920)

Extend the seed with the other three signals, all derived from the same
declaration of services and pods:

- metrics: per pod, an http_requests_total counter growing by
  RequestsPerScrape at every 15s scrape and a process_resident_memory_bytes
  gauge, sent as a Prometheus remote-write request (snappy protobuf)
- traces: per checkout pod, a POST /checkout -> charge -> INSERT payments
  trace across both services, sent as OTLP/HTTP protobuf; trace IDs are
  derived from the run, so runs never share one
- profiles: per pod, three consecutive 10s CPU profiles uploaded to /ingest
  the way the Pyroscope Go SDK uploads them (multipart pprof, name
  "<app>{labels}")

TestMetricsRoundTrip, TestTracesRoundTrip and TestProfilesRoundTrip read
them back the way their clients do: the Prometheus query API; the Tempo API
as Grafana's Tempo data source uses it (trace by ID as protobuf, TraceQL
search, tag names and values); the Pyroscope Connect API as Grafana's
Pyroscope data source uses it, plus /pyroscope/render and
/pyroscope/render-diff. Every value is checked against the fixture, one
named case each.

Pinned responses under testdata/{metrics,traces,profiles} follow the same
rules as the logs pins: run-specific values normalized, maintained by hand.
The rate query is checked with a 1e-9 tolerance and not pinned, since its
last digits depend on the order the per-pod rates are added.

If data does not show up within 30s, the tests log it and still run every
named case, so a broken ingest path reports which answers are wrong.
…y (M2 3/4, metrico#920)

Review of metrico#1062: the flame graph pins (SelectMergeStacktraces, render,
render-diff) hold call stacks with their total and self values instead
of the raw names and levels arrays, whose order the query doesn't
define. The matrix, search and render responses are decoded strictly,
and matrix points must have exactly two elements.
metrico#920)

Several pinned values of the render responses are zero, empty or null
(leftTicks, rightTicks, spyName, timeline), so a missing key would
decode to the same value: every declared field is now required.
The Connect Series call returns one label set per pod and sample type.
The new check asserts the 8 series the seed fixture uploads (4 pods x
samples/count and cpu/nanoseconds) and that no label repeats within a
series, then compares the response with testdata/profiles/series.json,
written by hand. The run label becomes "RUN" and the series are sorted;
label order within a series is not compared.

With the render and render-diff goldens already pinned in M2, this is the
third response shape metrico#919 asks for: merge, diff, series/labels discovery.
@Guess-Who-sec
Guess-Who-sec force-pushed the test/m5-prof-series-golden branch from d962669 to 546a38b Compare November 25, 2026 15:01
@Guess-Who-sec

Copy link
Copy Markdown
Contributor Author

Rebased onto the updated #1062 and current master (ClickHouse 26.10); no changes to this PR. The suite passes, including the series case.

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.

1 participant