Documentation
¶
Index ¶
- Constants
- Variables
- func ConnectAndQueryTest(t *testing.T, connections *Connection)
- func CreateDockerNetwork(t *testing.T, name string) *docker.Network
- func GetDockerClient(t *testing.T) *docker.Client
- func RemoveDockerNetwork(t *testing.T, name string)
- type Connection
- type DatabaseContainer
- func (dc *DatabaseContainer) ContainerID() string
- func (dc *DatabaseContainer) EnsureNodeReadiness(t *testing.T, requiredOutput string)
- func (dc *DatabaseContainer) ExecuteCommand(t *testing.T, cmd []string) string
- func (dc *DatabaseContainer) GetContainerConnectionDetails(t *testing.T) *connection.Endpoint
- func (dc *DatabaseContainer) GetContainerLogs(t *testing.T) string
- func (dc *DatabaseContainer) StartContainer(ctx context.Context, t *testing.T)
- func (dc *DatabaseContainer) StopAndRemoveContainer(t *testing.T)
- func (dc *DatabaseContainer) StopContainer(t *testing.T)
Constants ¶
const ( YugaDBType = "yugabyte" //nolint:revive PostgresDBType = "postgres" )
Variables ¶
var YugabyteCMD = []string{
"bin/yugabyted", "start",
"--callhome", "false",
"--background", "false",
"--ui", "false",
"--tserver_flags",
"ysql_max_connections=500," +
"tablet_replicas_per_gib_limit=4000," +
"yb_num_shards_per_tserver=1," +
"minloglevel=3," +
"yb_enable_read_committed_isolation=true",
"--insecure",
}
YugabyteCMD starts yugabyte without SSL and fault tolerance (single server).
Functions ¶
func ConnectAndQueryTest ¶
func ConnectAndQueryTest(t *testing.T, connections *Connection)
ConnectAndQueryTest is an exported function for testing purpose.
func CreateDockerNetwork ¶ added in v0.1.6
CreateDockerNetwork creates a network if it doesn't exist.
func GetDockerClient ¶
GetDockerClient instantiate a new docker client.
func RemoveDockerNetwork ¶ added in v0.1.6
RemoveDockerNetwork removes a Docker network by name.
Types ¶
type Connection ¶
type Connection struct { Endpoints []*connection.Endpoint User string Password string Database string LoadBalance bool }
Connection facilities connecting to a YugabyteDB instance.
func NewConnection ¶
func NewConnection(endpoints ...*connection.Endpoint) *Connection
NewConnection returns a connection parameters with the specified host:port, and the default values for the other parameters.
func PrepareTestEnv ¶
func PrepareTestEnv(t *testing.T) *Connection
PrepareTestEnv initializes a test environment for an existing or uncontrollable db instance.
func PrepareTestEnvWithConnection ¶
func PrepareTestEnvWithConnection(t *testing.T, conn *Connection) *Connection
PrepareTestEnvWithConnection initializes a test environment given a db connection.
func StartAndConnect ¶
func StartAndConnect(ctx context.Context, t *testing.T) *Connection
StartAndConnect connects to an existing Yugabyte instance or creates a containerized new one.
type DatabaseContainer ¶
type DatabaseContainer struct { Name string Image string HostIP string Network string DatabaseType string Tag string Role string Cmd []string Env []string HostPort int DbPort docker.Port PortMap docker.Port PortBinds map[docker.Port][]docker.PortBinding NetToIP map[string]*docker.EndpointConfig AutoRm bool // contains filtered or unexported fields }
DatabaseContainer manages the execution of an instance of a dockerized DB for tests.
func (*DatabaseContainer) ContainerID ¶
func (dc *DatabaseContainer) ContainerID() string
ContainerID returns the container ID.
func (*DatabaseContainer) EnsureNodeReadiness ¶
func (dc *DatabaseContainer) EnsureNodeReadiness(t *testing.T, requiredOutput string)
EnsureNodeReadiness checks the container's readiness by monitoring its logs and ensure its running correctly.
func (*DatabaseContainer) ExecuteCommand ¶
func (dc *DatabaseContainer) ExecuteCommand(t *testing.T, cmd []string) string
ExecuteCommand executes a command and returns the container output.
func (*DatabaseContainer) GetContainerConnectionDetails ¶
func (dc *DatabaseContainer) GetContainerConnectionDetails( t *testing.T, ) *connection.Endpoint
GetContainerConnectionDetails inspect the container and fetches its connection to an endpoint.
func (*DatabaseContainer) GetContainerLogs ¶
func (dc *DatabaseContainer) GetContainerLogs(t *testing.T) string
GetContainerLogs return the output of the DatabaseContainer.
func (*DatabaseContainer) StartContainer ¶
func (dc *DatabaseContainer) StartContainer(ctx context.Context, t *testing.T)
StartContainer runs a DB container, if no specific container details provided, default values will be set.
func (*DatabaseContainer) StopAndRemoveContainer ¶
func (dc *DatabaseContainer) StopAndRemoveContainer(t *testing.T)
StopAndRemoveContainer stops and removes the db container from the docker engine.
func (*DatabaseContainer) StopContainer ¶
func (dc *DatabaseContainer) StopContainer(t *testing.T)
StopContainer stops db container.