Repository navigation
test(integration): Loki push ingestion conformance (M8, #924) - #1118
Open
Guess-Who-sec wants to merge 11 commits into
Open
Guess-Who-sec wants to merge 11 commits into
Guess-Who-sec wants to merge 11 commits into
Conversation
Guess-Who-sec
force-pushed
the
test/m8-ingest-loki-push
branch
2 times, most recently
from
November 20, 2026 19:06
169f398 to
450baca
Compare
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.
…/4, metrico#920) TestSchemaMigrations runs gigapipe with MODE=init_only against a new database and checks it holds every table and view the single-node scripts in ctrl/qryn/sql declare (plus ver, where the migration runner records its progress). A second run on the same database, as on restarting an existing install, must succeed and change nothing. TestRulerBootOrder starts gigapipe in all mode with the ruler enabled and checks it from outside, as metrico#920 asks: GET /api/v1/rules answers (a ruler started before the reader registers no routes, so the failure is a 404), and a recording rule uploaded through that API writes back samples with the expected values. Moving the ruler before the reader in bootSequence makes both cases fail; restoring the order makes them pass. Both start their own gigapipe process, each with a database of its own, so docker-compose.yml now publishes ClickHouse's ports to the host and run.sh builds the binary first. A process that exits because its port was taken is restarted on another port.
…/4, metrico#920) TestSchemaMigrationsCluster runs gigapipe's migrations with CLUSTER_NAME set against a two-node ClickHouse cluster (test_cluster_two_shards) that reuses the e2e stack's configuration. Every node must hold the objects of the single-node and *_dist.sql scripts, plus ver and ver_dist, and a second run must change nothing. It has its own build tag (integration_cluster) and runs through make test-integration-cluster, which starts the cluster, runs the test and always stops the cluster. A new workflow runs it on the release cadence metrico#920 names (pushes to master, by hand) and on pull requests that change ctrl/qryn or this lane. The ClickHouse helpers can now target a given node, and declaredTables takes the scripts to read, so the single-node and cluster checks share them.
…cluster (M2 4/4, metrico#920) Review of metrico#1063: rerunning the migrations must leave every table's create_table_query unchanged, on every node. The cluster lane runs the e2e stack's two ClickHouse services with an override that only adds ports on 127.0.0.1, healthchecks and CLICKHOUSE_SKIP_USER_SETUP, and is torn down also when it fails to start. The integration stack publishes ClickHouse's HTTP port on 127.0.0.1 for the tests that read it, and the gigapipe processes the tests start listen on 127.0.0.1.
TestLokiPushConformance sends Loki pushes and checks the rows gigapipe stores in ClickHouse: time_series, samples_v3, time_series_gin and metrics_15s. Cases: the M2 seed as JSON and as snappy protobuf, a pinned fingerprint shared by both formats, label order, service_name, label name cleanup, values over 100 characters, structured metadata, lines on two days, and the old labels/entries format. Expected values are what gigapipe stores today, measured. seed.LokiPushProto encodes streams the way Promtail sends them. ClickHouse is read with the clickhouseQuery helper and ports from the M2 lifecycle tests.
Guess-Who-sec
force-pushed
the
test/m8-ingest-loki-push
branch
from
November 25, 2026 15:01
450baca to
032ee2d
Compare
Contributor
Author
|
Rebased onto the updated M2 stack and current |
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Part of #924 (M8): ingestion conformance, the first protocol, Loki push, as you suggested on #924 (one protocol per PR, Loki push and Prometheus remote-write first).
Depends on #1063 (M2 4/4), which builds on #1062 and #1061: this branch is built on the whole M2 stack, so its first 10 commits are theirs (#1061: 4, #1062: 3, #1063: 3). It uses the seed from #1061 and #1062, and #1063's ClickHouse ports and
clickhouseQueryhelper. Merge those first; I'll rebase this one ontomasterthen. Only the last commit is new here.What it does
The M2 round trips check that what goes in comes back out through the query API. This test checks the other end: what a Loki client sends is checked where gigapipe stores it, by reading the rows from ClickHouse. When the storage changes underneath (the samples table split in #972, or the writer refactor in M8), a case fails if any of these change:
TestLokiPushConformanceintest/integration/ingest_loki_push_test.goruns in the existing integration lane (build tagintegration). Every expected value is what gigapipe stores today, measured on a real stack.application/jsontime_series: one row per stream and day, exact labels JSON (service_nameadded fromapp), type 1, emptynameandmetadata.samples_v3: one row per line with the stream's fingerprint, exact nanosecond timestamp and text, value 0, type 1.time_series_gin: one row per label.metrics_15s: line count and bytes per stream. Fingerprints differ between streams.18270485951633840138(default CityHash). This covers the whole path: label cleanup, the addedservice_name, and the hash. Its lines have sub-second timestamps; the seed's are whole seconds.service_nameapp; withservice_namealready set; with neithercheckout; kept asshop;unknownk8s.pod-name(dots and dashes, as in Kubernetes or OpenTelemetry-style names)k8s_pod_name...[ts, line, {"trace_id": …}]time_seriesrows (one per date), same fingerprintlabelsstring plusentrieswith an RFC 3339 timestampOther changes:
seed.LokiPushProtoencodes the seed streams the way Promtail does, with a unit test showing it carries the same streams asLokiPushJSON.clickhouseQuery(CLICKHOUSE_HTTP_URL, defaulthttp://localhost:8123) and the ports test(integration): schema migration and ruler boot-order checks (M2 4/4, #920) #1063 publishes, so this PR doesn't changedocker-compose.yml,run.shor any workflow.Questions for you
service_namewith several candidate labels: gigapipe takes the last candidate in the order the labels arrive. Measured:{job="batch", container="worker"}getsservice_name="worker". So for a client that sends labels sorted by name, the alphabetically last candidate wins. I didn't pin this case. Is that intended?..., so two values that differ only after character 100 become the same label. The test pins today's behaviour. Is that intended?Noticed while writing the test, for #972:
time_seriesis aReplacingMergeTree(date)ordered by(fingerprint, type). On this table,SELECT … FINALkeeps only the newest day's row of a stream: measured, two rows on disk and one withFINAL. The test reads withoutFINALso it sees what's stored.Verification
After rebasing onto the updated M2 stack and current
master(ClickHouse 26.10):master's #1122 made thelinefield of gigapipe's Loki protobuf typesbytes, soseed.LokiPushProtonow writes the line as bytes (same wire format). Checked: the protobuf body sent to a real Loki 3.7.10 was stored exactly (19 lines, sub-second timestamps and a non-ASCII line); the whole integration suite passes on a fresh stack viarun.sh(23 tests, all 10 conformance subtests) and the way the CI lane runs it; with #1122's new decoder, the planted "protobuf drops nanoseconds" and "protobuf lines stored as metric type" changes still fail only the cases meant to catch them;gofmt,go vet(no new findings), the build,go test ./..., golangci-lint and staticcheck are clean.Earlier results, before the rebase:
Real runs (Docker: ClickHouse 24.9.1 + gigapipe built from this tree):
test/integration/run.shmake build integration-start test-integration(22 tests)make test-integration-cluster, still passes; it runs onlyTestSchemaMigrationsCluster, so this test doesn't run against the clusterPlanted changes, each rebuilt and run, then reverted. Each one failed only the case meant to catch it:
.Mistakes in my own test, found and fixed while writing it:
FINAL, which hid the second day (see above).time_seriesas soon as the samples had arrived. gigapipe writes the two separately, so the test now waits for both.time_seriesrow of its fixed stream, including rows left by earlier runs on the same database. Reproduced: a run with a planted bug (JSON lines stored with the metric type) left a type-2 row, and the next run with correct gigapipe then failed. It now checks only the log-type row; the samples check covers this run's type. On that same database the fixed test passed 3 of 3, and the two planted changes aimed at this case still fail it. In CI each run starts with a fresh database, so CI never hit this.gofmt;go vet(no new findings compared with the base) and with-tags integrationandintegration,integration_cluster;CGO_ENABLED=0 go build; rootgo test ./...(37 packages);-raceon the seed package;make lintas CI runs it, and golangci-lint and staticcheck with both tag sets (0 issues)Potential risks
hash_type: bernsteinwould fail that case.logprotoGo types, which follow the Loki push protocol. If those types had a wrong field, the test and the server would agree with each other. I checked this once by hand, outside the test: the sameLokiPushProtobody sent to a real Loki 3.7.10 was accepted (204), and it returned exactly the streams, lines and nanosecond timestamps sent (5 streams, 19 lines, including sub-second times). The test itself doesn't repeat that check.run.shpublishes ClickHouse on ports 9000 and 8123, so a local ClickHouse using those ports has to be stopped first.