Open-Source Wikis

/

CockroachDB

/

Packages

/

testutils

cockroachdb/cockroach

testutils

pkg/testutils/ is the catch-all for testing helpers. It is the most-imported test-only package in the repo.

Sub-packages

Sub-package Purpose
pkg/testutils/serverutils/ Boot a *server.TestServer plus *kv.DB for integration tests
pkg/testutils/testcluster/ Multi-node test cluster wrapper
pkg/testutils/skip/ Skip tests under specific build flags (race, deadlock, stress)
pkg/testutils/datapathutils/ Resolve testdata paths in Bazel sandbox
pkg/testutils/lint/ CRDB-specific lint rules
pkg/testutils/sqlutils/ Common SQL test helpers
pkg/testutils/jobutils/ Job-related test helpers
pkg/testutils/storageutils/ Storage-engine test helpers
pkg/testutils/keysutils/ Key construction helpers
pkg/testutils/echotest/ Golden-file stdin/stdout tests
pkg/testutils/diagutils/ Diagnostics-related helpers
pkg/testutils/release/ Release-test scaffolding
pkg/testutils/listenerutil/ Test listener helpers
pkg/testutils/colcontainerutils/ colexec test helpers
pkg/testutils/floatcmp/ Approximate float equality
pkg/testutils/fingerprintutils/ Span fingerprints for replication tests
pkg/testutils/grpcutils/ gRPC test helpers
pkg/testutils/pgrepltest/ pg-replication harness
pkg/testutils/pgurlutils/ URL helpers
pkg/testutils/tracetest/ Tracing assertion helpers
pkg/testutils/upgrades/ Cluster-version migration test scaffolding

Common patterns

// Boot a single-node test server.
ctx := context.Background()
s, sqlDB, kvDB := serverutils.StartServer(t, base.TestServerArgs{})
defer s.Stopper().Stop(ctx)
// Boot a 3-node cluster.
tc := testcluster.StartTestCluster(t, 3, base.TestClusterArgs{})
defer tc.Stopper().Stop(ctx)
// Skip flaky tests under stress.
skip.UnderStress(t, "this test is too slow under stress")

Built by Factory AutoWiki from public repository content. It is a generated preview for codebase exploration, not source-maintained documentation.

testutils – CockroachDB wiki | Factory