testhelpers

package
v0.0.0-...-6ee8545 Latest Latest
Warning

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

Go to latest
Published: Feb 7, 2023 License: Apache-2.0 Imports: 21 Imported by: 0

Documentation

Index

Constants

View Source
const (
	Superuser   = true
	NoSuperuser = false
)

Variables

View Source
var ConnectorPort = nat.Port("9201/tcp")

Functions

func AddDataNode1

func AddDataNode1(db *pgx.Conn, database string) error

func AddDataNode2

func AddDataNode2(db *pgx.Conn, database string) error

func DbSetup

func DbSetup(DBName string, superuser SuperuserStatus, deferNode2Setup bool, extensionState TestOptions) (*pgxpool.Pool, error)

func GetReadOnlyConnection

func GetReadOnlyConnection(t testing.TB, DBName string) *pgxpool.Pool

func MakePromUserPromAdmin

func MakePromUserPromAdmin(t testing.TB, dbName string)

func PgConnectURL

func PgConnectURL(dbName string, superuser SuperuserStatus) string

func PgConnectURLUser

func PgConnectURLUser(dbName string, user string) string

func PgxPoolWithRegisteredTypes

func PgxPoolWithRegisteredTypes(connectURL string) (*pgxpool.Pool, error)

func PgxPoolWithRole

func PgxPoolWithRole(t testing.TB, dbName string, role string) *pgxpool.Pool

func PrintContainerLogs

func PrintContainerLogs(container testcontainers.Container)

func StartConnectorWithImage

func StartConnectorWithImage(ctx context.Context, dbContainer testcontainers.Container, image string, version semver.Version, printLogs bool, cmds []string, dbname string) (testcontainers.Container, error)

func StartDatabaseImage

func StartDatabaseImage(ctx context.Context,
	t Result,
	image string,
	testDataDir string,
	dataDir string,
	printLogs bool,
	extensionState TestOptions,
) (testcontainers.Container, io.Closer, error)

func StartPGContainer

func StartPGContainer(
	ctx context.Context,
	t Result,
	extensionState TestOptions,
	testDataDir string,
	printLogs bool,
) (testcontainers.Container, io.Closer, error)

StartPGContainer starts a postgreSQL container for use in testing

func StartPromContainer

func StartPromContainer(storagePath string, ctx context.Context) (testcontainers.Container, string, nat.Port, error)

StartPromContainer starts a Prometheus container for use in testing

func StopContainer

func StopContainer(ctx context.Context, container testcontainers.Container, printLogs bool, t Result)

func TempDir

func TempDir(name string) (string, error)

TempDir returns a temp directory for tests

func WithDB

func WithDB(t testing.TB, DBName string, superuser SuperuserStatus, deferNode2Setup bool, extensionState TestOptions, f func(db *pgxpool.Pool, t testing.TB, connectString string))

WithDB establishes a database for testing and calls the callback

Types

type CloseAll

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

func (*CloseAll) Append

func (c *CloseAll) Append(closer func())

func (CloseAll) Close

func (c CloseAll) Close() error

type JaegerContainer

type JaegerContainer struct {
	Container                 testcontainers.Container
	GrpcReceivingPort, UIPort nat.Port
	// contains filtered or unexported fields
}

func StartJaegerContainer

func StartJaegerContainer(printLogs bool) (jaegerContainer *JaegerContainer, err error)

func (*JaegerContainer) Close

func (c *JaegerContainer) Close() error

type OptionState

type OptionState int
const (
	Timescale OptionState = timescaleBit
	Multinode OptionState = timescaleBit | multinodeBit

	TimescaleNightly          OptionState = timescaleBit | timescaleNightlyBit
	TimescaleNightlyMultinode OptionState = timescaleBit | multinodeBit | timescaleNightlyBit
)

type Result

type Result interface {
	Failed() bool
}

type SuperuserStatus

type SuperuserStatus = bool

type TestOptions

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

func NewTestOptions

func NewTestOptions(options OptionState, timescaleDockerImage string) TestOptions

func (TestOptions) GetDockerImageName

func (e TestOptions) GetDockerImageName() string

func (*TestOptions) SetTimescaleDockerImage

func (e *TestOptions) SetTimescaleDockerImage(timescaleDockerImage string)

func (TestOptions) TryGetDockerImagePgVersion

func (e TestOptions) TryGetDockerImagePgVersion() (string, error)

func (*TestOptions) UseMultinode

func (e *TestOptions) UseMultinode()

func (*TestOptions) UseTimescaleDB

func (e *TestOptions) UseTimescaleDB()

func (*TestOptions) UseTimescaleNightly

func (e *TestOptions) UseTimescaleNightly()

func (*TestOptions) UseTimescaleNightlyMultinode

func (e *TestOptions) UseTimescaleNightlyMultinode()

func (TestOptions) UsesMultinode

func (e TestOptions) UsesMultinode() bool

func (TestOptions) UsesTimescaleDB

func (e TestOptions) UsesTimescaleDB() bool

func (TestOptions) UsesTimescaleNightly

func (e TestOptions) UsesTimescaleNightly() bool

Jump to

Keyboard shortcuts

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