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 CheckEqualBoxErrors(t *testing.T, expected tarantool.BoxError, actual tarantool.BoxError)
- func CheckPoolStatuses(args interface{}) error
- func ConnectWithValidation(t testing.TB, server string, opts tarantool.Opts) *tarantool.Connection
- func ConvertUint64(v interface{}) (result uint64, err error)
- func DeleteRecordByKey(t *testing.T, conn tarantool.Connector, space interface{}, index interface{}, ...)
- func ExtractRequestBody(req tarantool.Request, resolver tarantool.SchemaResolver, ...) ([]byte, 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 SkipIfErrorExtendedInfoUnsupported(t *testing.T)
- func SkipIfErrorMessagePackTypeUnsupported(t *testing.T)
- func SkipIfFeatureDropped(t *testing.T, feature string, major, minor, patch uint64)
- func SkipIfFeatureSupported(t *testing.T, feature string, major, minor, patch uint64)
- func SkipIfFeatureUnsupported(t *testing.T, feature string, major, minor, patch uint64)
- func SkipIfGreaterOrEqual(t *testing.T, reason string, major, minor, patch uint64)
- func SkipIfIdSupported(t *testing.T)
- func SkipIfIdUnsupported(t *testing.T)
- func SkipIfLess(t *testing.T, reason string, major, minor, patch uint64)
- func SkipIfPaginationUnsupported(t *testing.T)
- func SkipIfSQLUnsupported(t testing.TB)
- func SkipIfStreamsUnsupported(t *testing.T)
- func SkipIfWatchersSupported(t *testing.T)
- func SkipIfWatchersUnsupported(t *testing.T)
- func StopTarantool(inst TarantoolInstance)
- func StopTarantoolInstances(instances []TarantoolInstance)
- func StopTarantoolWithCleanup(inst TarantoolInstance)
- func WaitUntilReconnected(conn *tarantool.Connection, retries uint, timeout time.Duration) bool
- type CheckStatusesArgs
- type ListenOnInstanceArgs
- type StartOpts
- type StrangerRequest
- type TarantoolInstance
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CheckEqualBoxErrors ¶ added in v1.10.0
CheckEqualBoxErrors checks equivalence of tarantool.BoxError objects.
Tarantool errors are not comparable by nature:
tarantool> msgpack.decode(mp_error_repr) == msgpack.decode(mp_error_repr) --- - false ...
Tarantool error file and line could differ even between different patches.
So we check equivalence of all attributes except for Line and File. For Line and File, we check that they are filled with some non-default values (lines are counted starting with 1 and empty file path is not expected too).
func CheckPoolStatuses ¶
func CheckPoolStatuses(args interface{}) error
func ConnectWithValidation ¶ added in v1.7.0
ConnectWithValidation tries to connect to a Tarantool instance. It returns a valid connection if it is successful, otherwise finishes a test with an error.
func ConvertUint64 ¶ added in v1.11.0
msgpack.v2 and msgpack.v5 return different uint types in responses. The function helps to unify a result.
func DeleteRecordByKey ¶ added in v1.7.0
func ExtractRequestBody ¶ added in v1.11.0
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 SkipIfErrorExtendedInfoUnsupported ¶ added in v1.10.0
SkipIfErrorExtendedInfoUnsupported skips test run if Tarantool without IPROTO_ERROR (0x52) support is used.
func SkipIfErrorMessagePackTypeUnsupported ¶ added in v1.10.0
SkipIfErrorMessagePackTypeUnsupported skips test run if Tarantool without MP_ERROR type over iproto support is used.
func SkipIfFeatureDropped ¶ added in v1.10.0
SkipIfFeatureDropped skips test run if Tarantool had dropped support of a feature.
func SkipIfFeatureSupported ¶ added in v1.10.0
SkipIfFeatureSupported skips test run if Tarantool supports a feature. Helper if useful when we want to test if everything is alright on older versions.
func SkipIfFeatureUnsupported ¶ added in v1.10.0
SkipIfFeatureUnsupported skips test run if Tarantool does not yet support a feature.
func SkipIfGreaterOrEqual ¶ added in v1.10.0
SkipIfGreaterOrEqual skips test run if Tarantool version is greater or equal than expected.
func SkipIfIdSupported ¶ added in v1.10.0
SkipIfIdSupported skips test run if Tarantool with IPROTO_ID support is used. Skip is useful for tests validating that protocol info is processed as expected even for pre-IPROTO_ID instances.
func SkipIfIdUnsupported ¶ added in v1.10.0
SkipIfIdUnsupported skips test run if Tarantool without IPROTO_ID support is used.
func SkipIfLess ¶ added in v1.10.0
SkipIfLess skips test run if Tarantool version is less than expected.
func SkipIfPaginationUnsupported ¶ added in v1.11.0
SkipIfPaginationUnsupported skips test run if Tarantool without pagination is used.
func SkipIfSQLUnsupported ¶ added in v1.7.0
func SkipIfStreamsUnsupported ¶ added in v1.7.0
SkipOfStreamsUnsupported skips test run if Tarantool without streams support is used.
func SkipIfWatchersSupported ¶ added in v1.10.0
SkipIfWatchersSupported skips test run if Tarantool with watchers support is used.
func SkipIfWatchersUnsupported ¶ added in v1.10.0
SkipOfStreamsUnsupported skips test run if Tarantool without watchers support is used.
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.
func WaitUntilReconnected ¶ added in v1.10.0
WaitUntilReconnected waits until connection is reestablished. Returns false in case of connection is not in the connected state after specified retries count, true otherwise.
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 { // Auth is an authentication method for a Tarantool instance. Auth tarantool.Auth // 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 // ClientServer changes a host to connect to test startup of a Tarantool // instance. By default, it uses Listen value as the host for the connection. ClientServer string // ClientTransport changes Opts.Transport for a connection that checks startup // of a Tarantool instance. ClientTransport string // ClientSsl changes Opts.Ssl for a connection that checks startup of // a Tarantool instance. ClientSsl tarantool.SslOpts // WorkDir is box.cfg work_dir parameter for a Tarantool instance: // a folder to store data files. If not specified, helpers create a // new temporary directory. // Folder must be unique for each Tarantool process used simultaneously. // https://www.tarantool.io/en/doc/latest/reference/configuration/#confval-work_dir WorkDir string // SslCertsDir is a path to a directory with SSL certificates. It will be // copied to the working directory. SslCertsDir 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 retry attempts to ping tarantool. If the // value < 0 then there will be no ping tarantool at all. ConnectRetry int // RetryTimeout is a time between tarantool ping retries. RetryTimeout time.Duration // MemtxUseMvccEngine is flag to enable transactional // manager if set to true. MemtxUseMvccEngine bool }
type StrangerRequest ¶ added in v1.7.0
type StrangerRequest struct { }
func NewStrangerRequest ¶ added in v1.7.0
func NewStrangerRequest() *StrangerRequest
func (*StrangerRequest) Async ¶ added in v1.10.0
func (sr *StrangerRequest) Async() bool
func (*StrangerRequest) Body ¶ added in v1.7.0
func (sr *StrangerRequest) Body(resolver tarantool.SchemaResolver, enc *encoder) error
func (*StrangerRequest) Code ¶ added in v1.7.0
func (sr *StrangerRequest) Code() int32
func (*StrangerRequest) Conn ¶ added in v1.7.0
func (sr *StrangerRequest) Conn() *tarantool.Connection
func (*StrangerRequest) Ctx ¶ added in v1.7.0
func (sr *StrangerRequest) Ctx() context.Context
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)