tests

package
v2.44.0 Latest Latest
Warning

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

Go to latest
Published: Jan 30, 2026 License: Apache-2.0 Imports: 31 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var CloudClickHouse = false
View Source
var JSONTestDate, _ = time.Parse(time.RFC3339, "2024-12-13T02:09:30.123Z")
View Source
var LocalClickHouse = false
View Source
var RemoteClickHouse = false

Functions

func AssertIsTimeoutError

func AssertIsTimeoutError(t *testing.T, err error)

AssertIsTimeoutError ensures that the error provided is a timeout error. It recursively unwraps the provided error and ensures the core error implements the Timeout() method and it returns true. context deadline error, os deadline error and poll deadline error each implement this and return true.

func BuildTestJSONPaths

func BuildTestJSONPaths() *chcol.JSON

func CheckMinServerServerVersion

func CheckMinServerServerVersion(conn driver.Conn, major, minor, patch uint64) bool

func CleanupNativeConn

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

func ClientOptionsFromEnv

func ClientOptionsFromEnv(env ClickHouseTestEnvironment, settings datastore.Settings, useHTTP bool) datastore.Options

func CreateDatabase

func CreateDatabase(testSet string) error

func GetClickHouseTestVersion

func GetClickHouseTestVersion() string

func GetConnection

func GetConnection(testSet string, t *testing.T, protocol datastore.Protocol, settings datastore.Settings, tlsConfig *tls.Config, compression *datastore.Compression) (driver.Conn, error)

func GetConnectionHTTP

func GetConnectionHTTP(testSet string, sessionName string, settings datastore.Settings, tlsConfig *tls.Config, compression *datastore.Compression) (driver.Conn, error)

func GetConnectionTCP

func GetConnectionTCP(testSet string, settings datastore.Settings, tlsConfig *tls.Config, compression *datastore.Compression) (driver.Conn, error)

func GetConnectionWithOptions

func GetConnectionWithOptions(options *datastore.Options) (driver.Conn, error)

func GetEnv

func GetEnv(key, fallback string) string

func GetJWTConnection

func GetJWTConnection(testSet string, settings datastore.Settings, tlsConfig *tls.Config, maxConnLifetime time.Duration, jwtFunc datastore.GetJWTFunc) (driver.Conn, error)

func IsSetInEnv

func IsSetInEnv(key string) bool

func OptionsToDSN

func OptionsToDSN(o *datastore.Options) string

func PrintMemUsage

func PrintMemUsage()

PrintMemUsage outputs the current, total and OS memory being used. As well as the number of garbage collection cycles completed. thanks to https://golangcode.com/print-the-current-memory-usage/

func RandAsciiString

func RandAsciiString(n int) string

func RandIPv4

func RandIPv4() net.IP

func RandIPv6

func RandIPv6() net.IP

func RandIntString

func RandIntString(n int) string

func ResetRandSeed

func ResetRandSeed()

func Runtime

func Runtime(m *testing.M, ts string) (exitCode int)

func SetTestEnvironment

func SetTestEnvironment(testSet string, environment ClickHouseTestEnvironment)

func SkipNotCloud

func SkipNotCloud(t *testing.T, reasons ...string)

SkipNotCloud skips the test if it's not run on ClickHouse Cloud

func SkipOnCloud

func SkipOnCloud(t *testing.T, reasons ...string)

SkipOnCloud skips the test if it's run on ClickHouse Cloud

func SkipOnHTTP

func SkipOnHTTP(t *testing.T, protocol datastore.Protocol, reasons ...string)

SkipOnHTTP skips the test if the protocol is HTTP

func TestClientDefaultSettings

func TestClientDefaultSettings(env ClickHouseTestEnvironment) datastore.Settings

func TestClientWithDefaultOptions

func TestClientWithDefaultOptions(env ClickHouseTestEnvironment, settings datastore.Settings) (driver.Conn, error)

func TestClientWithDefaultSettings

func TestClientWithDefaultSettings(env ClickHouseTestEnvironment) (driver.Conn, error)

func TestDatabaseSQLClientWithDefaultOptions

func TestDatabaseSQLClientWithDefaultOptions(env ClickHouseTestEnvironment, settings datastore.Settings) (*sql.DB, error)

func TestDatabaseSQLClientWithDefaultSettings

func TestDatabaseSQLClientWithDefaultSettings(env ClickHouseTestEnvironment) (*sql.DB, error)

func TestProtocols

func TestProtocols(rootT *testing.T, testFunc func(t *testing.T, protocol datastore.Protocol))

Types

type ClickHouseTestEnvironment

type ClickHouseTestEnvironment struct {
	ContainerID string
	Port        int
	HttpPort    int
	SslPort     int
	HttpsPort   int
	Host        string
	Username    string
	Password    string
	JWT         string
	Database    string
	Version     proto.Version
	ContainerIP string
	Container   testcontainers.Container `json:"-"`
}

func CreateClickHouseTestEnvironment

func CreateClickHouseTestEnvironment(testSet string) (ClickHouseTestEnvironment, error)

func GetExternalTestEnvironment

func GetExternalTestEnvironment(testSet string) (ClickHouseTestEnvironment, error)

func GetTestEnvironment

func GetTestEnvironment(testSet string) (ClickHouseTestEnvironment, error)

type FastTestStruct

type FastTestStruct struct {
	// contains filtered or unexported fields
}

FastTestStruct is a distinctly separate type that implements datastore.JSONSerializer and datastore.JSONDeserializer The struct must be a separate type since the JSON column is unable to ignore the interface implementation.

func BuildFastTestJSONStruct

func BuildFastTestJSONStruct() FastTestStruct

func (*FastTestStruct) DeserializeClickHouseJSON

func (fts *FastTestStruct) DeserializeClickHouseJSON(obj *datastore.JSON) error

DeserializeClickHouseJSON implements datastore.JSONDeserializer for faster struct scanning

func (*FastTestStruct) SerializeClickHouseJSON

func (fts *FastTestStruct) SerializeClickHouseJSON() (*datastore.JSON, error)

SerializeClickHouseJSON implements datastore.JSONSerializer for faster struct appending

type NginxReverseHTTPProxyTestEnvironment

type NginxReverseHTTPProxyTestEnvironment struct {
	HttpPort       int
	NginxContainer testcontainers.Container `json:"-"`
}

func CreateNginxReverseProxyTestEnvironment

func CreateNginxReverseProxyTestEnvironment(datastoreEnv ClickHouseTestEnvironment) (NginxReverseHTTPProxyTestEnvironment, error)

type TestStruct

type TestStruct struct {
	Name   string
	Age    int64
	Active bool
	Score  float64

	Tags    []string
	Numbers []int64

	Address TestStructAddress

	KeysNumbers map[string]int64
	Metadata    map[string]interface{}

	Timestamp time.Time `chType:"DateTime64(3)"`

	DynamicString chcol.Dynamic
	DynamicInt    chcol.Dynamic
	DynamicMap    chcol.Dynamic
}

func BuildTestJSONStruct

func BuildTestJSONStruct() TestStruct

type TestStructAddress

type TestStructAddress struct {
	Street  string `chType:"String"`
	City    string `chType:"String"`
	Country string `chType:"String"`
}

type TinyProxyTestEnvironment

type TinyProxyTestEnvironment struct {
	HttpPort  int
	Container testcontainers.Container `json:"-"`
}

func CreateTinyProxyTestEnvironment

func CreateTinyProxyTestEnvironment(t *testing.T) (TinyProxyTestEnvironment, error)

func (TinyProxyTestEnvironment) ProxyUrl

func (e TinyProxyTestEnvironment) ProxyUrl(t *testing.T) string

Directories

Path Synopsis
issues
209 command
360 command
470 command
476 command
484 command
485 command

Jump to

Keyboard shortcuts

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