Repository navigation
test(integration): schema migration and ruler boot-order checks (M2 4/4, #920) - #1063
Guess-Who-sec wants to merge 10 commits into
Conversation
ef40d6a to
11446df
Compare
rita7lopes
left a comment
There was a problem hiding this comment.
Nice, the ruler check and the cluster variant are exactly what #920 asks for. A few small things before I merge:
- "Running the migrations again changes nothing" only compares table names. Please compare
create_table_queryfromsystem.tablestoo, on every node, so a changed column, TTL or view is caught. - Please publish the ClickHouse ports on
127.0.0.1in both compose files. They have no password, and today they're open to the contributor's network. make test-integration-clusterdoesn't stop the cluster ifup --waitfails. Please make the teardown run in that case too.- Please use the same
actions/checkoutandactions/setup-goversions as master in the new workflow.
|
One more: please don't copy the ClickHouse image version, I don't want to update it by hand in several places. Reuse the two ClickHouse services from |
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.
11446df to
c304d26
Compare
|
Thanks @rita7lopes, all done in the last commit. The whole M2 stack is rebased onto current
In the same spirit as point 2: the gigapipe processes the migration and ruler tests start run without authentication and listened on every interface, so they now get Everything passes on ClickHouse 26.10: the whole integration suite through |
Part of M2 (#920), PR 4 of 4. Epic: #917.
M2 is split into four PRs:
Depends on #1062 (M2 3/4) and the PRs below it. Please merge those first. This PR's own changes are its last three commits; the last one addresses the review. The whole M2 stack is rebased onto current
master(with #1127), so #1061 and #1062 were rebased too, without changes.What
Schema migration lane:
TestSchemaMigrations.MODE=init_onlyagainst a new database. The database must then hold every table and view that the single-node scripts inctrl/qryn/sqldeclare: currently 28, read from the scripts so the list needs no upkeep. It must also holdver, where the migration runner records its progress.create_table_queryfromsystem.tables, so a changed column, engine, TTL or view query fails.Cluster variant:
TestSchemaMigrationsCluster. This is the cluster half of #920's migration lane: the same checks withCLUSTER_NAMEset, against a two-node ClickHouse cluster (test_cluster_two_shards).scripts/test/e2e/docker-compose.yml, whose image comes fromscripts/test/docker-compose.clickhouse.yml).test/integration/cluster/docker-compose.ymlis an override that only adds host ports (on127.0.0.1), healthchecks andCLICKHOUSE_SKIP_USER_SETUP, so no image version is written here.*_dist.sqlscripts. Every node must hold every object of both script sets (28 local, 14 distributed), plusverandver_dist. A second run must change nothing on any node: the same tables with the samecreate_table_query.make test-integration-clusterstarts the cluster, runs the test and stops the cluster, also when the cluster fails to start. The tests have their own build tag,integration_cluster, so the normal integration lane does not need a cluster.integration-cluster.yml(same action versions as the other workflows), runs it on the release cadence M2 — Write→read roundtrip harness + regression bank #920 names (pushes tomasterand by hand), and on pull requests that changectrl/qryn/**,scripts/test/**(so a ClickHouse update runs it) or this lane's own files.Boot-order lane:
TestRulerBootOrder. gigapipe starts inallmode withGIGAPIPE_RULER_ENABLED=true(the current name forQRYN_RULER_ENABLED) and a 2s poll interval. The test checks the ruler from outside:GET /api/v1/rulesmust return 200. A ruler started before the reader registers no routes, so it answers 404.app:http_requests:sum = sum by (app) (http_requests_total{…})is uploaded through the rules API. The recorded series must come back with the expected values.How these tests run. Each starts its own gigapipe process with a database of its own. The single-node migration and ruler tests use the ClickHouse of the
run.shstack, so:docker-compose.ymlpublishes ClickHouse's HTTP port too, on127.0.0.1:8123, next to the native portmasteralready publishes on127.0.0.1:9000.run.shbuilds the binary before the tests.127.0.0.1only (HOST=127.0.0.1); gigapipe's default is every interface.Verification
After the rebase onto current
masterand the review changes, on ClickHouse 26.10:run.sh, 3 runs in a row against one stack, and once the way the CI lane runs it. All green, 21 tests each.time_serieswhen the migrations run on an existing database, "running the migrations again changes nothing" fails, namingtime_series changedon the single node and on both cluster nodes. With the previous test code, which compared table names only, it passed. Change reverted.make test-integration-clusterpasses on the e2e stack's two nodes.127.0.0.1:<port>; the same binary withoutHOSTlistens on*:<port>.up --waitfails, the target exits non-zero without running the test and leaves no containers. The previous target stopped at that point and left both nodes running.gofmtis clean.go vet ./...(same findings asmaster),go vetwithintegrationand withintegration,integration_cluster, the build of./cmd/gigapipe,go test ./...and-raceon the seed package pass.make lintand golangci-lint with both tag sets report 0 issues; staticcheck and actionlint are clean, and both compose setups validate.Before the rebase: moving the ruler before the reader in
bootSequencemade both boot-order cases fail (GET /api/v1/rules: status 404); 10 consecutive runs of the whole suite were green; skippingprofiles_dist.sqlfailed both cluster cases naming the four missing*_disttables on each node; and the cluster lane passed in GitHub Actions on a fork (54s job).Potential risks
docker-compose.ymlpublishes ClickHouse on127.0.0.1:9000(as onmaster) and now127.0.0.1:8123. A contributor already running ClickHouse on those ports gets a clash when usingrun.sh.CREATE TABLEandCREATE [MATERIALIZED] VIEWstatements. An object created another way, such as a dictionary, would not be checked.CLICKHOUSE_SKIP_USER_SETUP=1: without it, the image restricts the passwordless default user to connections from inside the container.masterand on pull requests that change the migrations. Locally it uses ports 9000, 8123 and 8124, so therun.shstack has to be stopped first.Left for later
SAMPLES_SPLIT_BY_SIGNALon and off (the acceptance criterion from the M2 — Write→read roundtrip harness + regression bank #920 review). It needs Split samples by signal #972. Once that lands, the round-trip suite runs once per setting and compares the answers.