cht

package
v0.36.0 Latest Latest
Warning

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

Go to latest
Published: May 24, 2022 License: Apache-2.0 Imports: 22 Imported by: 0

Documentation

Overview

Package cht implements ClickHouse testing utilities, primarily end to end.

Package cht implements running ClickHouse for tests.

Index

Constants

View Source
const EnvBin = "CH_BIN"

EnvBin is environmental variable that sets paths to current ClickHouse binary.

Variables

This section is empty.

Functions

func Bin

func Bin() (string, error)

Bin returns path to current ClickHouse binary.

func BinOrSkip added in v0.16.0

func BinOrSkip(t testing.TB) string

BinOrSkip returns binary path or skips test.

func Ports added in v0.17.1

func Ports(t testing.TB, n int) []int

Ports allocates n free ports.

func Skip added in v0.16.0

func Skip(t testing.TB)

Skip test if e2e is not available.

Types

type Cluster added in v0.16.0

type Cluster struct {
	Secret string  `xml:"secret,omitempty"`
	Shards []Shard `xml:"shard"`
}

type Clusters added in v0.16.0

type Clusters map[string]Cluster

func (Clusters) MarshalXML added in v0.16.0

func (c Clusters) MarshalXML(e *xml.Encoder, start xml.StartElement) error

type Config

type Config struct {
	XMLName xml.Name `xml:"clickhouse"`
	Logger  Logger   `xml:"logger"`
	HTTP    int      `xml:"http_port"`
	TCP     int      `xml:"tcp_port"`
	Host    string   `xml:"listen_host"`

	InterServerHTTP *int `xml:"interserver_http_port,omitempty"`

	Path            string  `xml:"path"`
	TempPath        string  `xml:"tmp_path"`
	UserFilesPath   string  `xml:"user_files_path"`
	UserDirectories UserDir `xml:"user_directories"`

	MarkCacheSize int64 `xml:"mark_cache_size"`
	MMAPCacheSize int64 `xml:"mmap_cache_size"`

	OpenTelemetrySpanLog *OpenTelemetry `xml:"opentelemetry_span_log,omitempty"`

	// ZooKeeper configures ZooKeeper nodes.
	ZooKeeper      []ZooKeeperNode `xml:"zookeeper>node,omitempty"`
	Macros         Map             `xml:"macros,omitempty"`
	DistributedDDL *DistributedDDL `xml:"distributed_ddl,omitempty"`

	// Keeper is config for clickhouse-keeper server.
	Keeper *KeeperConfig `xml:"keeper_server,omitempty"`

	RemoteServers Clusters `xml:"remote_servers,omitempty"`
}

Config for ClickHouse.

type CoordinationConfig added in v0.16.0

type CoordinationConfig struct {
	OperationTimeoutMs          int    `xml:"operation_timeout_ms,omitempty"`
	SessionTimeoutMs            int    `xml:"session_timeout_ms,omitempty"`
	RaftLogsLevel               string `xml:"raft_logs_level,omitempty"`
	HeartBeatIntervalMs         int    `xml:"heart_beat_interval_ms,omitempty"`
	DeadSessionCheckPeriodMs    int    `xml:"dead_session_check_period_ms,omitempty"`
	ElectionTimeoutLowerBoundMs int    `xml:"election_timeout_lower_bound_ms,omitempty"`
	ElectionTimeoutUpperBoundMs int    `xml:"election_timeout_upper_bound_ms,omitempty"`
}

type DistributedDDL added in v0.17.1

type DistributedDDL struct {
	Path               string `xml:"path,omitempty"`
	Profile            string `xml:"profile,omitempty"`
	PoolSize           int    `xml:"pool_size"`
	TaskMaxLifetime    int    `xml:"task_max_lifetime,omitempty"`
	CleanupDelayPeriod int    `xml:"cleanup_delay_period,omitempty"`
	MaxTasksInQueue    int    `xml:"max_tasks_in_queue,omitempty"`
}

type KeeperConfig added in v0.16.0

type KeeperConfig struct {
	XMLName             xml.Name           `xml:"keeper_server"`
	TCPPort             int                `xml:"tcp_port,omitempty"`
	ServerID            int                `xml:"server_id,omitempty"`
	LogStoragePath      string             `xml:"log_storage_path,omitempty"`
	SnapshotStoragePath string             `xml:"snapshot_storage_path,omitempty"`
	Coordination        CoordinationConfig `xml:"coordination_settings"`
	Raft                RaftConfig         `xml:"raft_configuration"`
}

KeeperConfig is config for clickhouse-keeper.

https://clickhouse.com/docs/en/operations/clickhouse-keeper/

type LogEntry added in v0.16.0

type LogEntry struct {
	QueryID  string // f9464441-7023-4df5-89e5-8d16ea6aa2dd
	Severity string // "Debug", "Information", "Trace"
	Name     string // "MemoryTracker", "executeQuery"
	Message  string // "Peak memory usage (for query): 0.00 B."
	ThreadID uint64 // 591781
}

func (LogEntry) Level added in v0.16.0

func (e LogEntry) Level() zapcore.Level

type Logger

type Logger struct {
	Level   string `xml:"level"`
	Console int    `xml:"console,omitempty"`
}

Logger settings.

type Map added in v0.17.1

type Map map[string]string

func (Map) MarshalXML added in v0.17.1

func (m Map) MarshalXML(e *xml.Encoder, start xml.StartElement) error

type OpenTelemetry added in v0.22.0

type OpenTelemetry struct {
	Engine          string `xml:"engine,omitempty"`
	Database        string `xml:"database,omitempty"`
	Table           string `xml:"table,omitempty"`
	FlushIntervalMs int    `xml:"flush_interval_milliseconds,omitempty"`
}

type Option added in v0.16.0

type Option func(o *options)

func With added in v0.16.0

func With(opts ...Option) Option

With composes opts into single Option.

Useful for Many calls.

func WithClusters added in v0.16.0

func WithClusters(c Clusters) Option

func WithDistributedDDL added in v0.17.1

func WithDistributedDDL(ddl DistributedDDL) Option

func WithInterServerHTTP added in v0.17.1

func WithInterServerHTTP(port int) Option

func WithKeeper added in v0.17.1

func WithKeeper(cfg KeeperConfig) Option

func WithLog added in v0.16.0

func WithLog(lg *zap.Logger) Option

func WithMacros added in v0.17.1

func WithMacros(m Map) Option

func WithTCP added in v0.16.0

func WithTCP(port int) Option

func WithZooKeeper added in v0.17.1

func WithZooKeeper(nodes []ZooKeeperNode) Option

type RaftConfig added in v0.16.0

type RaftConfig struct {
	Servers []RaftServer `xml:"servers"`
}

type RaftServer added in v0.16.0

type RaftServer struct {
	ID       int    `xml:"id"`
	Hostname string `xml:"hostname"`
	Port     int    `xml:"port"`
}

type Replica added in v0.16.0

type Replica struct {
	Priority int    `xml:"priority,omitempty"`
	Host     string `xml:"host"`
	Port     int    `xml:"port"`
}

type Server

type Server struct {
	TCP    string
	HTTP   string
	Config Config
}

Server represents testing ClickHouse server.

func Many added in v0.16.0

func Many(t testing.TB, opts ...Option) []Server

Many concurrent calls to New.

func New

func New(t testing.TB, opts ...Option) Server

New creates new ClickHouse server and returns it. Use Many to start multiple servers at once.

Skips tests if CH_E2E variable is set to 0. Fails if CH_E2E is 1, but no binary is available. Skips if CH_E2E is unset and no binary.

Override binary with CH_BIN. Can be clickhouse-server or clickhouse.

type Shard added in v0.16.0

type Shard struct {
	XMLName             xml.Name  `xml:"shard"`
	Weight              int       `xml:"weight,omitempty"`
	InternalReplication bool      `xml:"internal_replication,omitempty"`
	Replicas            []Replica `xml:"replica,omitempty"`
}

type UserDir

type UserDir struct {
	UsersXML UsersXML `xml:"users_xml"`
}

UserDir for ClickHouse.

type UsersXML

type UsersXML struct {
	Path string `xml:"path"`
}

UsersXML config for ClickHouse.

type ZooKeeperNode added in v0.17.1

type ZooKeeperNode struct {
	Index int    `xml:"index,omitempty,attr"`
	Host  string `xml:"host,omitempty"`
	Port  int    `xml:"port,omitempty"`
}

Jump to

Keyboard shortcuts

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