common

package
v0.0.2-beta.2 Latest Latest
Warning

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

Go to latest
Published: Mar 11, 2022 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// DefaultYugabyteDBMasterImageName specifies the default Docker image name used in tests.
	DefaultYugabyteDBMasterImageName = "yugabytedb/yugabyte"
	// DefaultYugabyteDBImageVersion specifies the default Docker image version used in tests.
	DefaultYugabyteDBImageVersion = "2.13.0.0-b42"
	// DefaultYugabyteDBContainerUser specifies the default Docker container user.
	DefaultYugabyteDBContainerUser = "yugabyte"
	// DefaultReplicationFactor specifies the default replication factor.
	DefaultReplicationFactor = 1
	// DefaultYugabyteDBFsDataPath specifies the default path of the data directory in the container.
	DefaultYugabyteDBFsDataPath = "/mnt/data"
	// DefaultYugabyteDBMasterRPCPort is the default YugabyteDB RPC port used inside of the container.
	// Currently cannot be changed.
	DefaultYugabyteDBMasterRPCPort = 7100

	// DefaultYugabyteDBTServerRPCPort is the default YugabyteDB RPC port used inside of the container.
	// Currently cannot be changed.
	DefaultYugabyteDBTServerRPCPort = 9100
	// DefaultYugabyteDBTServerYSQLPort is the default YugabyteDB PostgreSQL port used inside of the container.
	// Currently cannot be changed.
	DefaultYugabyteDBTServerYSQLPort = 5433

	// DefaultMasterPrefix is the default master prefix value, if no prefix specified.
	DefaultMasterPrefix = "yb-master"

	// DefaultYugabyteDBEnvVarImageName is an environment variable name used to override the default YugabyteDB docker image name.
	DefaultYugabyteDBEnvVarImageName = "TEST_YUGABYTEDB_IMAGE_NAME"
	// DefaultYugabyteDEnvVarImageVersion is an environment variable name used to override the default YugabyteDB docker image tag.
	DefaultYugabyteDEnvVarImageVersion = "TEST_YUGABYTEDB_IMAGE_VERSION"
)

Variables

This section is empty.

Functions

func CompareStringSlices

func CompareStringSlices(t *testing.T, this, that []string)

CompareStringSlices cpmpares if two string slices have the same length and same values.

func Eventually

func Eventually(t *testing.T, maxTimes int, f func() error, messageLabels ...interface{})

Eventually retries the request maximum number of tries and stops on success, or error.

func GetEnvOrDefault

func GetEnvOrDefault(key, fallback string) string

GetEnvOrDefault returns the value of an environment variable or fallback value, if environment variable is undefined or empty.

func StringSlicesEqual

func StringSlicesEqual(t *testing.T, this, that []string) bool

StringSlicesEqual compares two slices without failing the test.

func WaitForContainerExit0

func WaitForContainerExit0(t *testing.T, pool *dockertest.Pool, containerID string) error

WaitForContainerExit0 waits for the container to exist with code 0.

Types

type AllocatedAdditionalPort

type AllocatedAdditionalPort interface {
	Allocated() string
	Requested() dc.Port
	Use()
}

AllocatedAdditionalPort holds references to allocated ports when other ports are requested.

func NewDefaultAllocatedAdditionalPort

func NewDefaultAllocatedAdditionalPort(r dc.Port, a string, supplier RandomPortSupplier) AllocatedAdditionalPort

NewDefaultAllocatedAdditionalPort returns an instance of a default AllocatedAdditionalPort implementation.

type AllocatedAdditionalPorts

type AllocatedAdditionalPorts = map[dc.Port]AllocatedAdditionalPort

AllocatedAdditionalPorts is a short hand type storing all allocated additional ports for a single container.

type DockerCommand

type DockerCommand = []string

DockerCommand is the YugabyteDB Docker image command.

type MasterInternalAddresses

type MasterInternalAddresses = []string

MasterInternalAddresses is a list of internal masters addresses used to form the cluster.

type MultiMasterAllocatedAdditionalPorts

type MultiMasterAllocatedAdditionalPorts = map[string]AllocatedAdditionalPorts

MultiMasterAllocatedAdditionalPorts is a short hand type storing all allocated additional ports for masters. The mapping is:

master name => allocated ports

Master names can be obtainer from masters test context.

type RPCBindAddress

type RPCBindAddress = string

RPCBindAddress is the bind address used by the test container.

type RandomPortSupplier

type RandomPortSupplier interface {
	Cleanup()
	Discover() error
	DiscoveredHost() (string, bool)
	DiscoveredPort() (string, bool)
}

RandomPortSupplier wraps the functionality for random port handling in tests.

func NewRandomPortSupplier

func NewRandomPortSupplier() (RandomPortSupplier, error)

NewRandomPortSupplier creates an initialized instance of a random port supplier.

type TestMasterConfiguration

type TestMasterConfiguration struct {
	YbDBContainerUser string
	YbDBEnv           []string // format: env=value
	YbDBFsDataPath    string
	YbDBDockerImage   string
	YbDBDockerTag     string
	YbDBCmdSupplier   func(MasterInternalAddresses, RPCBindAddress) DockerCommand

	MasterPrefix string

	AdditionalPorts []dc.Port

	LogRegistrationRetryErrors bool
	NoCleanupContainers        bool
	ReplicationFactor          int
}

TestMasterConfiguration is the master configuration for this test.

func ApplyMasterConfigDefaults

func ApplyMasterConfigDefaults(t *testing.T, cfg *TestMasterConfiguration) *TestMasterConfiguration

ApplyMasterConfigDefaults applies default values to the master configuration.

type TestMetricsCallback

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

TestMetricsCallback is the metrics callback to use in tests.

func NewTestMetricsCallback

func NewTestMetricsCallback(t *testing.T) *TestMetricsCallback

NewTestMetricsCallback creates a new configured instance of test metrics callback.

func (*TestMetricsCallback) ClientBytesReceived

func (p *TestMetricsCallback) ClientBytesReceived(n int)

func (*TestMetricsCallback) ClientBytesSent

func (p *TestMetricsCallback) ClientBytesSent(n int)

func (*TestMetricsCallback) ClientConnect

func (p *TestMetricsCallback) ClientConnect()

func (*TestMetricsCallback) ClientError

func (p *TestMetricsCallback) ClientError()

func (*TestMetricsCallback) ClientMessageSendFailure

func (p *TestMetricsCallback) ClientMessageSendFailure()

func (*TestMetricsCallback) ClientMessageSendSuccess

func (p *TestMetricsCallback) ClientMessageSendSuccess()

func (*TestMetricsCallback) ClientReconnectAttempt

func (p *TestMetricsCallback) ClientReconnectAttempt()

func (*TestMetricsCallback) ClientReconnectFailure

func (p *TestMetricsCallback) ClientReconnectFailure()

func (*TestMetricsCallback) ClientReconnectSuccess

func (p *TestMetricsCallback) ClientReconnectSuccess()

func (*TestMetricsCallback) InspectClientBytesReceived

func (p *TestMetricsCallback) InspectClientBytesReceived(t *testing.T) int

func (*TestMetricsCallback) InspectClientBytesSent

func (p *TestMetricsCallback) InspectClientBytesSent(t *testing.T) int

func (*TestMetricsCallback) InspectClientConnect

func (p *TestMetricsCallback) InspectClientConnect(t *testing.T) int

func (*TestMetricsCallback) InspectClientError

func (p *TestMetricsCallback) InspectClientError(t *testing.T) int

func (*TestMetricsCallback) InspectClientMessageSendFailure

func (p *TestMetricsCallback) InspectClientMessageSendFailure(t *testing.T) int

func (*TestMetricsCallback) InspectClientMessageSendSuccess

func (p *TestMetricsCallback) InspectClientMessageSendSuccess(t *testing.T) int

func (*TestMetricsCallback) InspectClientReconnectAttempt

func (p *TestMetricsCallback) InspectClientReconnectAttempt(t *testing.T) int

func (*TestMetricsCallback) InspectClientReconnectFailure

func (p *TestMetricsCallback) InspectClientReconnectFailure(t *testing.T) int

func (*TestMetricsCallback) InspectClientReconnectSuccess

func (p *TestMetricsCallback) InspectClientReconnectSuccess(t *testing.T) int

type TestTServerConfiguration

type TestTServerConfiguration struct {
	YbDBContainerUser string
	YbDBEnv           []string // format: env=value
	YbDBFsDataPath    string
	YbDBDockerImage   string
	YbDBDockerTag     string
	YbDBCmdSupplier   func(MasterInternalAddresses, RPCBindAddress) DockerCommand

	// if empty, a random value will be generated and assigned
	TServerID string

	AdditionalPorts []dc.Port

	LogRegistrationRetryErrors bool
	NoCleanupContainers        bool
}

TestTServerConfiguration is the TServer configuration for this test.

func ApplyTServerConfigDefaults

func ApplyTServerConfigDefaults(t *testing.T, cfg *TestTServerConfiguration) *TestTServerConfiguration

ApplyTServerConfigDefaults applies default values to the master configuration.

Jump to

Keyboard shortcuts

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