Skip to content

test: replace pgxmock with real-cluster testserver integration tests - #289

Merged
sravotto merged 1 commit into
mainfrom
sr8/integration
Sep 15, 2026
Merged

sravotto merged 1 commit into
mainfrom
sr8/integration

Conversation

@sravotto

@sravotto sravotto commented Sep 15, 2026 •

Copy link
Copy Markdown
Contributor

Summary

  • pgxmock tests asserted exact SQL strings and hand-crafted result sets, so they never validated the embedded SQL/DDL or real transaction semantics against actual CockroachDB.
  • Adds internal/testutil, a shared test harness built on the already-used cockroach-go/v2/testserver, and converts the store, collector, and admin CLI tests to run against a real single-node cluster.
  • Tests that need a live cluster are gated behind //go:build integration so the default go test ./... stays fast and doesn't link testserver; CI gains a matching integration-tests job, and the staticcheck step now also runs with -tags=integration (production code exercised only from these tests would otherwise show up as unused).
  • github.com/pashagolub/pgxmock/v3 is fully removed from go.mod/go.sum.
  • Along the way, confirmed USE $1 with a bind parameter works against real CRDB, and found that collector.go's counter/gauge type switch doesn't handle int64 (what pgx returns for CRDB's INT) - worked around in test fixtures by following the existing FLOAT8-cast convention rather than touching production code.

@sravotto
sravotto force-pushed the sr8/integration branch 3 times, most recently from e0353f5 to 9ad335c Compare September 15, 2026 19:32
pgxmock tests asserted exact SQL strings and hand-crafted result sets,
so they never validated the embedded SQL/DDL or real transaction
semantics against actual CockroachDB. Add internal/testutil, a shared
harness built on the already-used cockroach-go/v2/testserver, and
convert the store, collector, and admin CLI tests to run against a
real cluster. Tests that need a live cluster are gated behind
//go:build integration so the default "go test ./..." stays fast and
doesn't link testserver; github.com/pashagolub/pgxmock/v3 is fully
removed from go.mod/go.sum.

CI gains a matching integration-tests job, run as a matrix against
latest, 25.4, and 24.3 CockroachDB. testutil.StartCluster resolves
CRDB_TEST_SERIES (e.g. "25.4") to the newest non-withdrawn patch in
that series via the same release feed testserver itself uses for
"latest stable", so CI doesn't need a hardcoded patch version that
goes stale. The staticcheck step now also runs with -tags=integration,
since production code exercised only from these tests (e.g. server.go's
isLeaseHolder/getJob) would otherwise show up as unused.

Co-Authored-By: roachdev-claude <roachdev-claude-bot@cockroachlabs.com>
@sravotto
sravotto marked this pull request as ready for review September 15, 2026 19:46
@sravotto
sravotto merged commit 41f68c7 into main Sep 15, 2026
10 checks passed
@sravotto
sravotto deleted the sr8/integration branch September 15, 2026 19:59
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