Documentation
¶
Overview ¶
Helpers for managing Tarantool process for testing purposes.
Package introduces go helpers for starting a tarantool process and validating Tarantool version. Helpers are based on os/exec calls. Retries to connect test tarantool instance handled explicitly, see tarantool/go-tarantool#136.
Tarantool's instance Lua scripts use environment variables to configure box.cfg. Listen port is set in the end of script so it is possible to connect only if every other thing was set up already.
Index ¶
- func CheckPoolStatuses(args interface{}) error
- func InsertOnInstance(server string, connOpts tarantool.Opts, space interface{}, tuple interface{}) error
- func InsertOnInstances(servers []string, connOpts tarantool.Opts, space interface{}, ...) error
- func IsTarantoolVersionLess(majorMin uint64, minorMin uint64, patchMin uint64) (bool, error)
- func ProcessListenOnInstance(args interface{}) error
- func RestartTarantool(inst *TarantoolInstance) error
- func Retry(f func(interface{}) error, args interface{}, count int, timeout time.Duration) error
- func SetClusterRO(servers []string, connOpts tarantool.Opts, roles []bool) error
- func SetInstanceRO(server string, connOpts tarantool.Opts, isReplica bool) error
- func StopTarantool(inst TarantoolInstance)
- func StopTarantoolInstances(instances []TarantoolInstance)
- func StopTarantoolWithCleanup(inst TarantoolInstance)
- type CheckStatusesArgs
- type ListenOnInstanceArgs
- type StartOpts
- type TarantoolInstance
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CheckPoolStatuses ¶
func CheckPoolStatuses(args interface{}) error
func InsertOnInstance ¶
func InsertOnInstances ¶
func IsTarantoolVersionLess ¶
IsTarantoolVersionLess checks if tarantool version is less than passed <major.minor.patch>. Returns error if failed to extract version.
func ProcessListenOnInstance ¶
func ProcessListenOnInstance(args interface{}) error
ProcessListenOnInstance helper calls "return box.cfg.listen" as many times as there are servers in the connection pool with specified mode. For RO mode expected received ports equals to replica ports. For RW mode expected received ports equals to master ports. For PreferRO mode expected received ports equals to replica ports or to all ports. For PreferRW mode expected received ports equals to master ports or to all ports.
func RestartTarantool ¶
func RestartTarantool(inst *TarantoolInstance) error
RestartTarantool restarts a tarantool instance for tests with specifies parameters (refer to StartOpts) which were specified in inst parameter. inst is a tarantool instance that was started by StartTarantool. Rewrites inst.Cmd.Process to stop instance with StopTarantool. Process must be stopped with StopTarantool.
func SetClusterRO ¶
func SetInstanceRO ¶
func StopTarantool ¶
func StopTarantool(inst TarantoolInstance)
StopTarantool stops a tarantool instance started with StartTarantool. Waits until any resources associated with the process is released. If something went wrong, fails.
func StopTarantoolInstances ¶
func StopTarantoolInstances(instances []TarantoolInstance)
func StopTarantoolWithCleanup ¶
func StopTarantoolWithCleanup(inst TarantoolInstance)
StopTarantoolWithCleanup stops a tarantool instance started with StartTarantool. Waits until any resources associated with the process is released. Cleans work directory after stop. If something went wrong, fails.
Types ¶
type CheckStatusesArgs ¶
type CheckStatusesArgs struct { ConnPool *connection_pool.ConnectionPool Servers []string Mode connection_pool.Mode ExpectedPoolStatus bool ExpectedStatuses map[string]bool }
type ListenOnInstanceArgs ¶
type ListenOnInstanceArgs struct { ConnPool *connection_pool.ConnectionPool Mode connection_pool.Mode ServersNumber int ExpectedPorts map[string]bool }
type StartOpts ¶
type StartOpts struct { // InitScript is a Lua script for tarantool to run on start. InitScript string // Listen is box.cfg listen parameter for tarantool. // Use this address to connect to tarantool after configuration. // https://www.tarantool.io/en/doc/latest/reference/configuration/#cfg-basic-listen Listen string // WorkDir is box.cfg work_dir parameter for tarantool. // Specify folder to store tarantool data files. // Folder must be unique for each tarantool process used simultaneously. // https://www.tarantool.io/en/doc/latest/reference/configuration/#confval-work_dir WorkDir string // User is a username used to connect to tarantool. // All required grants must be given in InitScript. User string // Pass is a password for specified User. Pass string // WaitStart is a time to wait before starting to ping tarantool. WaitStart time.Duration // ConnectRetry is a count of attempts to ping tarantool. ConnectRetry uint // RetryTimeout is a time between tarantool ping retries. RetryTimeout time.Duration }
type TarantoolInstance ¶
type TarantoolInstance struct { // Cmd is a Tarantool command. Used to kill Tarantool process. Cmd *exec.Cmd // Options for restarting a tarantool instance. Opts StartOpts }
TarantoolInstance is a data for instance graceful shutdown and cleanup.
func StartTarantool ¶
func StartTarantool(startOpts StartOpts) (TarantoolInstance, error)
StartTarantool starts a tarantool instance for tests with specifies parameters (refer to StartOpts). Process must be stopped with StopTarantool.
func StartTarantoolInstances ¶
func StartTarantoolInstances(servers []string, workDirs []string, opts StartOpts) ([]TarantoolInstance, error)