Skip to content

Commit cbc9131

Browse files
committed
add basic integration tests
1 parent bb28bda commit cbc9131

File tree

8 files changed

+1161
-32
lines changed

8 files changed

+1161
-32
lines changed

.github/workflows/integration.yaml

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
---
2+
name: "Integration Tests"
3+
on: # yamllint disable-line rule:truthy
4+
push:
5+
branches:
6+
- "main"
7+
pull_request:
8+
branches:
9+
- "*"
10+
merge_group:
11+
types:
12+
- "checks_requested"
13+
workflow_dispatch: # Allow manual triggering
14+
15+
env:
16+
GO_VERSION: "~1.24.0"
17+
18+
jobs:
19+
# Matrix job for individual integration tests
20+
integration-tests:
21+
name: "${{ matrix.test.name }}"
22+
runs-on: "depot-ubuntu-24.04"
23+
timeout-minutes: 30
24+
strategy:
25+
fail-fast: true # Cancel remaining tests if one fails
26+
matrix:
27+
test:
28+
- name: "Cluster Creation"
29+
command: "test:integrationRun"
30+
pattern: "TestMultiNodeClusterCreation"
31+
timeout: "15m"
32+
- name: "Cluster Health"
33+
command: "test:integrationRun"
34+
pattern: "TestMultiNodeClusterHealth"
35+
timeout: "20m"
36+
- name: "Pool Functionality"
37+
command: "test:integrationRun"
38+
pattern: "TestMultiNodePoolFunctionality"
39+
timeout: "25m"
40+
- name: "Connection Balancing"
41+
command: "test:integrationRun"
42+
pattern: "TestMultiNodeConnectionBalancing"
43+
timeout: "20m"
44+
- name: "Error Handling"
45+
command: "test:integrationRun"
46+
pattern: "TestMultiNodeErrorHandling"
47+
timeout: "15m"
48+
49+
steps:
50+
- uses: "actions/checkout@v4"
51+
- uses: "authzed/actions/setup-go@main"
52+
with:
53+
go-version: "${{ env.GO_VERSION }}"
54+
55+
- name: "Run ${{ matrix.test.name }} Test"
56+
run: |
57+
echo "Running integration test: ${{ matrix.test.name }}"
58+
echo "Command: go run mage.go ${{ matrix.test.command }} \"${{ matrix.test.pattern }}\""
59+
timeout ${{ matrix.test.timeout }} go run mage.go ${{ matrix.test.command }} "${{ matrix.test.pattern }}"
60+
61+
- name: "Collect container logs on failure"
62+
if: failure()
63+
run: |
64+
echo "=== Docker System Info ==="
65+
docker system df || true
66+
echo "=== Running Containers ==="
67+
docker ps -a || true
68+
echo "=== Docker Networks ==="
69+
docker network ls || true
70+
echo "=== Recent Container Logs ==="
71+
docker ps -a --format "table {{.Names}}\t{{.Status}}" | grep -E "(crdb|cockroach|testcontainers)" | head -5 || true
72+
continue-on-error: true

.github/workflows/test.yaml

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,27 @@ env:
1414
GO_VERSION: "~1.24.0"
1515
jobs:
1616
unit:
17-
name: "Unit"
18-
runs-on: "ubuntu-latest"
17+
name: "Unit Tests"
18+
runs-on: "depot-ubuntu-24.04"
1919
steps:
20-
- uses: "actions/checkout@v3"
20+
- uses: "actions/checkout@v4"
2121
- uses: "authzed/actions/setup-go@main"
2222
with:
2323
go-version: "${{ env.GO_VERSION }}"
2424
- name: "Unit tests"
2525
run: "go run mage.go test:unit"
26+
27+
# Build validation
28+
build:
29+
name: "Build"
30+
runs-on: "depot-ubuntu-24.04"
31+
needs: unit
32+
steps:
33+
- uses: "actions/checkout@v4"
34+
- uses: "authzed/actions/setup-go@main"
35+
with:
36+
go-version: "${{ env.GO_VERSION }}"
37+
- name: "Build"
38+
run: "go build ./..."
39+
- name: "Vet"
40+
run: "go vet ./..."

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
[![Go Report Card](https://goreportcard.com/badge/github.com/authzed/crdbpool)](https://goreportcard.com/report/github.com/authzed/crdbpool)
44
[![GoDoc](https://pkg.go.dev/badge/s.svg)](https://pkg.go.dev/github.com/authzed/crdbpool)
5+
[![Build & Test](https://github.com/authzed/crdbpool/actions/workflows/test.yaml/badge.svg)](https://github.com/authzed/crdbpool/actions/workflows/test.yaml)
6+
[![Integration Tests](https://github.com/authzed/crdbpool/actions/workflows/integration.yaml/badge.svg)](https://github.com/authzed/crdbpool/actions/workflows/integration.yaml)
57

68
`crdbpool` implements a node-aware connection pool for [CockroachDB] by wrapping [pgx].
79

go.mod

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ go 1.24
44

55
require (
66
github.com/ccoveille/go-safecast v1.6.1
7+
github.com/docker/go-connections v0.5.0
78
github.com/google/uuid v1.6.0
89
github.com/grpc-ecosystem/go-grpc-middleware/v2 v2.3.2
910
github.com/jackc/pgx/v5 v5.7.5
@@ -12,29 +13,75 @@ require (
1213
github.com/prometheus/client_golang v1.22.0
1314
github.com/rs/zerolog v1.34.0
1415
github.com/stretchr/testify v1.10.0
16+
github.com/testcontainers/testcontainers-go v0.38.0
1517
golang.org/x/sync v0.15.0
1618
golang.org/x/time v0.12.0
1719
google.golang.org/grpc v1.73.0
1820
)
1921

2022
require (
23+
dario.cat/mergo v1.0.1 // indirect
24+
github.com/Azure/go-ansiterm v0.0.0-20210617225240-d185dfc1b5a1 // indirect
25+
github.com/Microsoft/go-winio v0.6.2 // indirect
2126
github.com/beorn7/perks v1.0.1 // indirect
27+
github.com/cenkalti/backoff/v4 v4.2.1 // indirect
2228
github.com/cespare/xxhash/v2 v2.3.0 // indirect
29+
github.com/containerd/containerd v1.7.18 // indirect
30+
github.com/containerd/errdefs v1.0.0 // indirect
31+
github.com/containerd/errdefs/pkg v0.3.0 // indirect
32+
github.com/containerd/log v0.1.0 // indirect
33+
github.com/containerd/platforms v0.2.1 // indirect
34+
github.com/cpuguy83/dockercfg v0.3.2 // indirect
2335
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect
36+
github.com/distribution/reference v0.6.0 // indirect
37+
github.com/docker/docker v28.2.2+incompatible // indirect
38+
github.com/docker/go-units v0.5.0 // indirect
39+
github.com/ebitengine/purego v0.8.4 // indirect
40+
github.com/felixge/httpsnoop v1.0.4 // indirect
2441
github.com/go-logr/logr v1.4.3 // indirect
42+
github.com/go-logr/stdr v1.2.2 // indirect
43+
github.com/go-ole/go-ole v1.2.6 // indirect
44+
github.com/gogo/protobuf v1.3.2 // indirect
2545
github.com/jackc/pgpassfile v1.0.0 // indirect
2646
github.com/jackc/pgservicefile v0.0.0-20240606120523-5a60cdf6a761 // indirect
2747
github.com/jackc/puddle/v2 v2.2.2 // indirect
48+
github.com/klauspost/compress v1.18.0 // indirect
49+
github.com/lufia/plan9stats v0.0.0-20211012122336-39d0f177ccd0 // indirect
50+
github.com/magiconair/properties v1.8.10 // indirect
2851
github.com/mattn/go-colorable v0.1.14 // indirect
2952
github.com/mattn/go-isatty v0.0.20 // indirect
53+
github.com/moby/docker-image-spec v1.3.1 // indirect
54+
github.com/moby/go-archive v0.1.0 // indirect
55+
github.com/moby/patternmatcher v0.6.0 // indirect
56+
github.com/moby/sys/sequential v0.6.0 // indirect
57+
github.com/moby/sys/user v0.4.0 // indirect
58+
github.com/moby/sys/userns v0.1.0 // indirect
59+
github.com/moby/term v0.5.0 // indirect
60+
github.com/morikuni/aec v1.0.0 // indirect
3061
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect
62+
github.com/opencontainers/go-digest v1.0.0 // indirect
63+
github.com/opencontainers/image-spec v1.1.1 // indirect
64+
github.com/pkg/errors v0.9.1 // indirect
3165
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 // indirect
66+
github.com/power-devops/perfstat v0.0.0-20210106213030-5aafc221ea8c // indirect
3267
github.com/prometheus/client_model v0.6.2 // indirect
3368
github.com/prometheus/common v0.64.0 // indirect
3469
github.com/prometheus/procfs v0.15.1 // indirect
3570
github.com/rogpeppe/go-internal v1.14.1 // indirect
71+
github.com/shirou/gopsutil/v3 v3.23.12 // indirect
72+
github.com/shirou/gopsutil/v4 v4.25.5 // indirect
73+
github.com/shoenig/go-m1cpu v0.1.6 // indirect
74+
github.com/sirupsen/logrus v1.9.3 // indirect
75+
github.com/testcontainers/testcontainers-go/modules/cockroachdb v0.38.0 // indirect
76+
github.com/tklauser/go-sysconf v0.3.12 // indirect
77+
github.com/tklauser/numcpus v0.6.1 // indirect
78+
github.com/yusufpapurcu/wmi v1.2.4 // indirect
79+
go.opentelemetry.io/auto/sdk v1.1.0 // indirect
80+
go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.49.0 // indirect
3681
go.opentelemetry.io/otel v1.36.0 // indirect
82+
go.opentelemetry.io/otel/metric v1.36.0 // indirect
3783
go.opentelemetry.io/otel/sdk/metric v1.36.0 // indirect
84+
go.opentelemetry.io/otel/trace v1.36.0 // indirect
3885
golang.org/x/crypto v0.39.0 // indirect
3986
golang.org/x/net v0.41.0 // indirect
4087
golang.org/x/sys v0.33.0 // indirect

0 commit comments

Comments
 (0)