Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 36 additions & 0 deletions .github/workflows/integration-cluster.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
name: Integration (cluster migrations)

# Cluster variant of the schema migration lane (#920): runs gigapipe's
# migrations ON CLUSTER against a two-node ClickHouse cluster and checks that
# every node gets every declared table. It runs on the release cadence (pushes
# to master, or by hand), and on pull requests that change the migrations or
# this lane.
on:
push:
branches: [ "master" ]
workflow_dispatch:
pull_request:
branches: [ "master" ]
paths:
- "ctrl/qryn/**"
- "test/integration/cluster/**"
- "scripts/test/**"
- "test/integration/migrations*_test.go"
- ".github/workflows/integration-cluster.yml"

permissions:
contents: read

jobs:
migrations-cluster:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v7

- name: Set up Go
uses: actions/setup-go@v7
with:
go-version-file: go.mod

- name: Cluster migration lane
run: make test-integration-cluster
19 changes: 3 additions & 16 deletions .github/workflows/integration.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,30 +20,17 @@ jobs:
go-version-file: go.mod

- name: Build gigapipe
run: go build -o gigapipe ./cmd/gigapipe
run: make build

# The image version lives in the compose file, shared with run.sh.
- name: Start ClickHouse
run: docker compose -f test/integration/docker-compose.yml up -d --wait clickhouse

- name: Start gigapipe
run: |
CLICKHOUSE_SERVER=localhost CLICKHOUSE_PORT=9000 PORT=3100 BULK_MAX_AGE_MS=100 \
./gigapipe > gigapipe.log 2>&1 &
echo $! > gigapipe.pid

- name: Wait for gigapipe
run: |
for i in $(seq 1 60); do
if curl -sf http://localhost:3100/api/v1/status/buildinfo >/dev/null; then
echo "gigapipe ready"; exit 0
fi
sleep 1
done
echo "gigapipe never became ready; logs:"; cat gigapipe.log; exit 1
run: make integration-start

- name: Run integration tests
run: GIGAPIPE_URL=http://localhost:3100 go test -tags integration -count=1 -v ./test/integration/...
run: make test-integration

- name: gigapipe logs on failure
if: failure()
Expand Down
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,5 @@
/.claude/
/.superpowers/
/gigapipe
/gigapipe.log
/gigapipe.pid
42 changes: 41 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@ DURATION ?= 60s
LINT_NEW_FROM_REV ?= origin/master

.PHONY: docker e2e-deps e2e-build e2e-test e2e-cleanup e2e-full e2e-ci \
fmt-check build test-unit lint fuzz
fmt-check build test-unit integration-start test-integration test-integration-cluster \
lint fuzz

docker:
docker build -t gigapipe .
Expand All @@ -40,6 +41,45 @@ build:
test-unit:
go test -race ./...

# Start the binary built by `make build` in the background against the
# ClickHouse at CLICKHOUSE_SERVER:CLICKHOUSE_PORT and wait until it answers.
# Output goes to gigapipe.log. Used by the integration CI lane; locally,
# test/integration/run.sh starts ClickHouse and gigapipe in Docker instead.
integration-start:
CLICKHOUSE_SERVER=$${CLICKHOUSE_SERVER:-localhost} CLICKHOUSE_PORT=$${CLICKHOUSE_PORT:-9000} \
PORT=$${PORT:-3100} BULK_MAX_AGE_MS=$${BULK_MAX_AGE_MS:-100} \
./gigapipe > gigapipe.log 2>&1 & echo $$! > gigapipe.pid
@for i in $$(seq 1 60); do \
if curl -sf http://localhost:$${PORT:-3100}/api/v1/status/buildinfo >/dev/null; then \
echo "gigapipe ready"; exit 0; \
fi; \
sleep 1; \
done; \
echo "gigapipe never became ready; logs:"; cat gigapipe.log; exit 1

# Run the Go integration tests against the gigapipe at GIGAPIPE_URL
# (default http://localhost:3100).
test-integration:
go test -tags integration -count=1 -v ./test/integration/...

# The two-node ClickHouse cluster of the e2e stack, with the host ports the
# cluster migration test needs (test/integration/cluster/docker-compose.yml).
CLUSTER_COMPOSE = docker compose -p gigapipe-migrations-cluster \
-f scripts/test/e2e/docker-compose.yml -f test/integration/cluster/docker-compose.yml

# Run the cluster variant of the schema migration lane: start the cluster, run
# the test against it and stop the cluster afterwards, also when it fails to
# start. It publishes ClickHouse on 127.0.0.1 ports 9000, 8123 and 8124, so
# stop the stack of test/integration/run.sh first.
test-integration-cluster: build
$(CLUSTER_COMPOSE) up -d --wait e2e-clickhouse e2e-clickhouse2; status=$$?; \
if [ $$status -eq 0 ]; then \
go test -tags integration,integration_cluster -count=1 -v -run TestSchemaMigrationsCluster ./test/integration/...; \
status=$$?; \
fi; \
$(CLUSTER_COMPOSE) down -v --remove-orphans; \
exit $$status

# Run golangci-lint with the repo's committed config, gating only issues
# introduced since LINT_NEW_FROM_REV so this doesn't fail on pre-existing
# repo-wide debt. golangci-lint is deliberately unpinned: @latest keeps up with
Expand Down
2 changes: 2 additions & 0 deletions docs/contributing.md
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,8 @@ recipes), plus parser-fuzz helpers for the query transpilers:
make fmt-check # fail if any Go file is not gofmt-formatted
make build # build the gigapipe binary the way CI does
make test-unit # go test -race ./..., matching CI
make test-integration # integration tests against GIGAPIPE_URL (see test/integration/run.sh)
make test-integration-cluster # cluster migration lane on a two-node ClickHouse cluster (Docker)
make lint # golangci-lint, gated to issues new since origin/master
make fuzz HEAD=promql DURATION=60s # run the native Go parser fuzz target for a query head
```
Expand Down
33 changes: 33 additions & 0 deletions test/integration/cluster/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# Additions to scripts/test/e2e/docker-compose.yml for the cluster variant of
# the schema migration lane: it runs the e2e stack's two ClickHouse nodes
# (test_cluster_two_shards; the image version is in
# scripts/test/docker-compose.clickhouse.yml) and only adds what the test needs
# from the host. `make test-integration-cluster` uses both files.
#
# Ports are published on 127.0.0.1 only: the default user has no password.
# CLICKHOUSE_SKIP_USER_SETUP keeps the image from limiting that user to
# connections from inside the container, so the e2e users.xml applies as
# written.
services:
e2e-clickhouse:
environment:
CLICKHOUSE_SKIP_USER_SETUP: "1"
ports:
- "127.0.0.1:9000:9000"
- "127.0.0.1:8123:8123"
healthcheck:
test: ["CMD", "wget", "--spider", "-q", "http://localhost:8123/ping"]
interval: 2s
timeout: 3s
retries: 30

e2e-clickhouse2:
environment:
CLICKHOUSE_SKIP_USER_SETUP: "1"
ports:
- "127.0.0.1:8124:8123"
healthcheck:
test: ["CMD", "wget", "--spider", "-q", "http://localhost:8123/ping"]
interval: 2s
timeout: 3s
retries: 30
5 changes: 4 additions & 1 deletion test/integration/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,12 @@ services:
environment:
# Newer images limit the passwordless default user to the container.
CLICKHOUSE_SKIP_USER_SETUP: "1"
# Published for the CI lane, which runs gigapipe on the host.
# Published for the CI lane, which runs gigapipe on the host, and for the
# tests that start their own gigapipe (migrations, ruler boot order) and
# read ClickHouse over HTTP.
ports:
- "127.0.0.1:9000:9000"
- "127.0.0.1:8123:8123"
healthcheck:
test: ["CMD", "wget", "--spider", "-q", "http://localhost:8123/ping"]
interval: 2s
Expand Down
Loading
Loading