testhelpers

package
v0.3.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 28, 2026 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CreateTestDatabase

func CreateTestDatabase(t *testing.T, conn driver.Conn) string

CreateTestDatabase creates a uniquely-named test database and registers a t.Cleanup that drops it synchronously.

The unique suffix is 64 random bits from crypto/rand. Earlier versions derived the suffix from `unsafe.Pointer(t)`, which is unreliable: Go may reuse heap addresses for *testing.T after earlier tests complete, so two tests that happen to land on the same address get the same dbName. That manifested as intermittent "Replica /clickhouse/<db>/... already exists" failures on ReplicatedMergeTree fixtures shared by multiple tests (e.g. query_log_archive, sharded_events in TestEnd2End vs. TestLive_Introspection_AllStatements) because their ZK paths embed dbName.

Cleanup uses DROP DATABASE ... SYNC so the database's ZooKeeper metadata is released before the test returns — without SYNC, ClickHouse delays the drop by `database_atomic_delay_before_drop_table_sec` (default 480s), which leaves Replica entries lingering and racing later tests that happen to pick a colliding name.

func EqualProto

func EqualProto(t *testing.T, want, got proto.Message)

func GetTestConnection

func GetTestConnection(t *testing.T) driver.Conn

GetTestConnection returns a shared ClickHouse connection for tests The connection is initialized once and reused across all tests

func InitTestLogger

func InitTestLogger()

InitTestLogger initializes the logger in test mode (suppresses output)

func PingClickHouse

func PingClickHouse(conn driver.Conn) error

PingClickHouse performs a basic connectivity test

func RequireClickHouse

func RequireClickHouse(t *testing.T) driver.Conn

RequireClickHouse skips the test if ClickHouse is not available

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL