cluster

package
v0.16.2 Latest Latest
Warning

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

Go to latest
Published: May 9, 2023 License: Apache-2.0 Imports: 44 Imported by: 1

Documentation

Index

Constants

View Source
const (
	DefaultCell      = "zone1"
	DefaultStartPort = 6700
)

DefaultCell : If no cell name is passed, then use following

Variables

View Source
var (
	InsertTabletTemplateKsID = `insert into %s (id, msg) values (%d, '%s') /* id:%d */`
)
View Source
var (

	// PerfTest controls whether to run the slower end-to-end tests that check the system's performance
	PerfTest = flag.Bool("perf-test", false, "include end-to-end performance tests")
)

Functions

func CheckSrvKeyspace added in v0.15.0

func CheckSrvKeyspace(t *testing.T, cell string, ksname string, expectedPartition map[topodatapb.TabletType][]string, ci LocalProcessCluster)

CheckSrvKeyspace confirms that the cell and keyspace contain the expected shard mappings.

func ExecuteOnTablet added in v0.15.0

func ExecuteOnTablet(t *testing.T, query string, vttablet Vttablet, ks string, expectFail bool)

ExecuteOnTablet executes a query on the specified vttablet. It should always be called with a primary tablet for a keyspace/shard.

func ExecuteQueriesUsingVtgate

func ExecuteQueriesUsingVtgate(t *testing.T, session *vtgateconn.VTGateSession, query string)

ExecuteQueriesUsingVtgate sends query to vtgate using vtgate session.

func GetMajorVersion added in v0.12.5

func GetMajorVersion(binaryName string) (int, error)

func GetPasswordUpdateSQL added in v0.15.0

func GetPasswordUpdateSQL(localCluster *LocalProcessCluster) string

GetPasswordUpdateSQL returns the SQL for updating the users' passwords to the static creds used throughout tests.

func GetPrimaryPosition added in v0.12.0

func GetPrimaryPosition(t *testing.T, vttablet Vttablet, hostname string) (string, string)

GetPrimaryPosition gets the executed replication position of given vttablet

func GetSrvKeyspace added in v0.15.0

func GetSrvKeyspace(t *testing.T, cell string, ksname string, ci LocalProcessCluster) *topodatapb.SrvKeyspace

GetSrvKeyspace returns the SrvKeyspace structure for the cell and keyspace.

func NewConnParams

func NewConnParams(port int, password, socketPath, keyspace string) mysql.ConnParams

NewConnParams creates ConnParams corresponds to given arguments.

func PanicHandler

func PanicHandler(t *testing.T)

PanicHandler handles the panic in the testcase.

func ResetTabletDirectory

func ResetTabletDirectory(tablet Vttablet) error

ResetTabletDirectory transitions back to tablet state (i.e. mysql process restarts with cleaned directory and tablet is off)

func StartMySQL

func StartMySQL(ctx context.Context, tablet *Vttablet, username string, tmpDirectory string) error

StartMySQL starts mysqlctl process

func StartMySQLAndGetConnection

func StartMySQLAndGetConnection(ctx context.Context, tablet *Vttablet, username string, tmpDirectory string) (*mysql.Conn, error)

StartMySQLAndGetConnection create a connection to tablet mysql

func VerifyRowsInTablet

func VerifyRowsInTablet(t *testing.T, vttablet *Vttablet, ksName string, expectedRows int)

VerifyRowsInTablet Verify total number of rows in a tablet

func VerifyRowsInTabletForTable

func VerifyRowsInTabletForTable(t *testing.T, vttablet *Vttablet, ksName string, expectedRows int, tableName string)

VerifyRowsInTabletForTable verifies the total number of rows in a table. This is used to check that replication has caught up with the changes on primary.

func WaitForHealthyShard added in v0.16.1

func WaitForHealthyShard(vtctldclient *VtctldClientProcess, keyspace, shard string) error

WaitForHealthyShard waits for the given shard info record in the topo server to list a tablet (alias and uid) as the primary serving tablet for the shard. This is done using "vtctldclient GetShard" and parsing its JSON output. All other watchers should then also see this shard info status as well.

func WaitForReplicationPos

func WaitForReplicationPos(t *testing.T, tabletA *Vttablet, tabletB *Vttablet, hostname string, timeout float64)

WaitForReplicationPos will wait for replication position to catch-up

func WaitForTabletSetup added in v0.15.0

func WaitForTabletSetup(vtctlClientProcess *VtctlClientProcess, expectedTablets int, expectedStatus []string) error

func WriteDbCredentialToTmp added in v0.15.0

func WriteDbCredentialToTmp(tmpDir string) string

WriteDbCredentialToTmp writes JSON formatted db credentials to the specified tmp directory.

Types

type ConsulConfigs added in v0.10.3

type ConsulConfigs struct {
	Ports   PortsInfo `json:"ports"`
	DataDir string    `json:"data_dir"`
	LogFile string    `json:"log_file"`
}

ConsulConfigs are the configurations that are added the config files which are used by consul

type Keyspace

type Keyspace struct {
	Name      string
	SchemaSQL string
	VSchema   string
	Shards    []Shard
}

Keyspace : Cluster accepts keyspace to launch it

type LocalProcessCluster

type LocalProcessCluster struct {
	Keyspaces          []Keyspace
	Cell               string
	DefaultCharset     string
	BaseTabletUID      int
	Hostname           string
	TopoFlavor         string
	TopoPort           int
	TmpDirectory       string
	OriginalVTDATAROOT string
	CurrentVTDATAROOT  string
	ReusingVTDATAROOT  bool

	VtgateMySQLPort int
	VtgateGrpcPort  int
	VtctldHTTPPort  int

	// major version numbers
	VtTabletMajorVersion int
	VtctlMajorVersion    int

	// standalone executable
	VtctlclientProcess  VtctlClientProcess
	VtctldClientProcess VtctldClientProcess
	VtctlProcess        VtctlProcess

	// background executable processes
	TopoProcess     TopoProcess
	VtctldProcess   VtctldProcess
	VtgateProcess   VtgateProcess
	VtbackupProcess VtbackupProcess
	VTOrcProcesses  []*VTOrcProcess

	// Extra arguments for vtTablet
	VtTabletExtraArgs []string

	// Extra arguments for vtGate
	VtGateExtraArgs      []string
	VtGatePlannerVersion plancontext.PlannerVersion

	VtctldExtraArgs []string

	context.Context
	context.CancelFunc

	HasPartialKeyspaces bool
	// contains filtered or unexported fields
}

LocalProcessCluster Testcases need to use this to iniate a cluster

func NewBareCluster added in v0.16.0

func NewBareCluster(cell string, hostname string) *LocalProcessCluster

NewBareCluster instantiates a new cluster and does not assume existence of any of the vitess processes

func NewCluster

func NewCluster(cell string, hostname string) *LocalProcessCluster

NewCluster instantiates a new cluster

func (*LocalProcessCluster) CtrlCHandler

func (cluster *LocalProcessCluster) CtrlCHandler()

CtrlCHandler handles the teardown for the ctrl-c.

func (*LocalProcessCluster) DisableVTOrcRecoveries added in v0.16.0

func (cluster *LocalProcessCluster) DisableVTOrcRecoveries(t *testing.T)

DisableVTOrcRecoveries stops all VTOrcs from running any recoveries

func (*LocalProcessCluster) EnableVTOrcRecoveries added in v0.16.0

func (cluster *LocalProcessCluster) EnableVTOrcRecoveries(t *testing.T)

EnableVTOrcRecoveries allows all VTOrcs to run any recoveries

func (*LocalProcessCluster) ExecOnTablet added in v0.14.2

func (cluster *LocalProcessCluster) ExecOnTablet(ctx context.Context, vttablet *Vttablet, sql string, binds map[string]any, opts *querypb.ExecuteOptions) (*sqltypes.Result, error)

ExecOnTablet executes a query on the local cluster Vttablet and returns the result.

func (*LocalProcessCluster) ExecOnVTGate added in v0.14.2

func (cluster *LocalProcessCluster) ExecOnVTGate(ctx context.Context, addr string, target string, sql string, binds map[string]any, opts *querypb.ExecuteOptions) (*sqltypes.Result, error)

ExecOnVTGate executes a query on a local cluster VTGate with the provided target, bindvars, and execute options.

func (*LocalProcessCluster) GetAndReservePort

func (cluster *LocalProcessCluster) GetAndReservePort() int

GetAndReservePort gives port for required process

func (*LocalProcessCluster) GetAndReserveTabletUID

func (cluster *LocalProcessCluster) GetAndReserveTabletUID() int

GetAndReserveTabletUID gives tablet uid

func (*LocalProcessCluster) GetVTParams added in v0.15.0

func (cluster *LocalProcessCluster) GetVTParams(dbname string) mysql.ConnParams

GetVTParams returns mysql.ConnParams with host and port only for regular tests enabling global routing, and also dbname if we are testing for a cluster with a partially moved keyspace

func (LocalProcessCluster) ListBackups

func (cluster LocalProcessCluster) ListBackups(shardKsName string) ([]string, error)

ListBackups Lists back preset in shard

func (*LocalProcessCluster) NewVTOrcProcess added in v0.15.0

func (cluster *LocalProcessCluster) NewVTOrcProcess(config VTOrcConfiguration) *VTOrcProcess

NewVTOrcProcess creates a new VTOrcProcess object

func (*LocalProcessCluster) NewVtgateInstance

func (cluster *LocalProcessCluster) NewVtgateInstance() *VtgateProcess

NewVtgateInstance returns an instance of vtgateprocess

func (*LocalProcessCluster) NewVtgrProcess added in v0.12.0

func (cluster *LocalProcessCluster) NewVtgrProcess(clusters []string, config string, grPort int) *VtgrProcess

NewVtgrProcess creates a new VtgrProcess object

func (*LocalProcessCluster) NewVttabletInstance

func (cluster *LocalProcessCluster) NewVttabletInstance(tabletType string, UID int, cell string) *Vttablet

NewVttabletInstance creates a new vttablet object

func (*LocalProcessCluster) PrintMysqlctlLogFiles added in v0.14.0

func (cluster *LocalProcessCluster) PrintMysqlctlLogFiles()

PrintMysqlctlLogFiles prints all the log files associated with the mysqlctl binary

func (LocalProcessCluster) RemoveAllBackups

func (cluster LocalProcessCluster) RemoveAllBackups(t *testing.T, shardKsName string)

RemoveAllBackups removes all the backup corresponds to list backup.

func (*LocalProcessCluster) RestartVtgate

func (cluster *LocalProcessCluster) RestartVtgate() (err error)

RestartVtgate starts vtgate with updated configs

func (*LocalProcessCluster) SetupCluster added in v0.8.0

func (cluster *LocalProcessCluster) SetupCluster(keyspace *Keyspace, shards []Shard) (err error)

SetupCluster creates the skeleton for a cluster by creating keyspace shards and initializing tablets and mysqlctl processes. This does not start any process and user have to explicitly start all the required services (ex topo, vtgate, mysql and vttablet)

func (*LocalProcessCluster) StartKeyspace

func (cluster *LocalProcessCluster) StartKeyspace(keyspace Keyspace, shardNames []string, replicaCount int, rdonly bool, customizers ...any) (err error)

func (*LocalProcessCluster) StartKeyspaceLegacy added in v0.13.0

func (cluster *LocalProcessCluster) StartKeyspaceLegacy(keyspace Keyspace, shardNames []string, replicaCount int, rdonly bool, customizers ...any) (err error)

StartKeyspaceLegacy starts required number of shard and the corresponding tablets keyspace : struct containing keyspace name, Sqlschema to apply, VSchema to apply shardName : list of shard names replicaCount: total number of replicas excluding shard primary and rdonly rdonly: whether readonly tablets needed customizers: functions like "func(*VttabletProcess)" that can modify settings of various objects after they're created.

func (*LocalProcessCluster) StartTopo

func (cluster *LocalProcessCluster) StartTopo() (err error)

StartTopo starts topology server

func (*LocalProcessCluster) StartUnshardedKeyspace

func (cluster *LocalProcessCluster) StartUnshardedKeyspace(keyspace Keyspace, replicaCount int, rdonly bool) error

StartUnshardedKeyspace starts unshared keyspace with shard name as "0"

func (*LocalProcessCluster) StartUnshardedKeyspaceLegacy added in v0.13.0

func (cluster *LocalProcessCluster) StartUnshardedKeyspaceLegacy(keyspace Keyspace, replicaCount int, rdonly bool) error

StartUnshardedKeyspaceLegacy starts unshared keyspace with shard name as "0"

func (*LocalProcessCluster) StartVTOrc added in v0.15.3

func (cluster *LocalProcessCluster) StartVTOrc(keyspace string) error

StartVTOrc starts a VTOrc instance

func (*LocalProcessCluster) StartVtbackup

func (cluster *LocalProcessCluster) StartVtbackup(newInitDBFile string, initialBackup bool,
	keyspace string, shard string, cell string, extraArgs ...string) error

StartVtbackup starts a vtbackup

func (*LocalProcessCluster) StartVtgate

func (cluster *LocalProcessCluster) StartVtgate() (err error)

StartVtgate starts vtgate

func (*LocalProcessCluster) StartVttablet

func (cluster *LocalProcessCluster) StartVttablet(tablet *Vttablet, servingStatus string,
	supportBackup bool, cell string, keyspaceName string, hostname string, shardName string) error

StartVttablet starts a new tablet

func (*LocalProcessCluster) StreamTabletHealth added in v0.14.2

func (cluster *LocalProcessCluster) StreamTabletHealth(ctx context.Context, vttablet *Vttablet, count int) (responses []*querypb.StreamHealthResponse, err error)

StreamTabletHealth invokes a HealthStream on a local cluster Vttablet and returns the responses. It returns an error if the stream ends with fewer than `count` responses.

func (*LocalProcessCluster) Teardown

func (cluster *LocalProcessCluster) Teardown()

Teardown brings down the cluster by invoking teardown for individual processes

func (*LocalProcessCluster) TopoFlavorString added in v0.9.1

func (cluster *LocalProcessCluster) TopoFlavorString() *string

TopoFlavorString returns the topo flavor

func (LocalProcessCluster) VerifyBackupCount

func (cluster LocalProcessCluster) VerifyBackupCount(t *testing.T, shardKsName string, expected int) []string

VerifyBackupCount compares the backup count with expected count.

func (*LocalProcessCluster) VtctlclientGetTablet added in v0.15.4

func (cluster *LocalProcessCluster) VtctlclientGetTablet(tablet *Vttablet) (*topodatapb.Tablet, error)

func (*LocalProcessCluster) VtprocessInstanceFromVttablet

func (cluster *LocalProcessCluster) VtprocessInstanceFromVttablet(tablet *Vttablet, shardName string, ksName string) *VttabletProcess

VtprocessInstanceFromVttablet creates a new vttablet object

func (*LocalProcessCluster) WaitForTabletsToHealthyInVtgate

func (cluster *LocalProcessCluster) WaitForTabletsToHealthyInVtgate() (err error)

WaitForTabletsToHealthyInVtgate waits for all tablets in all shards to be seen as healthy and serving in vtgate. For each shard:

  • It must have 1 (and only 1) healthy primary tablet so we always wait for that
  • For replica and rdonly tablets, which are optional, we wait for as many as we should have based on how the cluster was defined.

type MysqlctlProcess

type MysqlctlProcess struct {
	Name            string
	Binary          string
	LogDirectory    string
	TabletUID       int
	MySQLPort       int
	InitDBFile      string
	ExtraArgs       []string
	InitMysql       bool
	SecureTransport bool
}

MysqlctlProcess is a generic handle for a running mysqlctl command . It can be spawned manually

func MysqlCtlProcessInstance

func MysqlCtlProcessInstance(tabletUID int, mySQLPort int, tmpDirectory string) *MysqlctlProcess

MysqlCtlProcessInstance returns a Mysqlctl handle for mysqlctl process configured with the given Config.

func MysqlCtlProcessInstanceOptionalInit added in v0.9.0

func MysqlCtlProcessInstanceOptionalInit(tabletUID int, mySQLPort int, tmpDirectory string, initMySQL bool) *MysqlctlProcess

MysqlCtlProcessInstanceOptionalInit returns a Mysqlctl handle for mysqlctl process configured with the given Config.

func (*MysqlctlProcess) BasePath added in v0.16.0

func (mysqlctl *MysqlctlProcess) BasePath() string

func (*MysqlctlProcess) BinaryLogsPath added in v0.16.0

func (mysqlctl *MysqlctlProcess) BinaryLogsPath() string

func (*MysqlctlProcess) CleanupFiles

func (mysqlctl *MysqlctlProcess) CleanupFiles(tabletUID int)

CleanupFiles clean the mysql files to make sure we can start the same process again

func (*MysqlctlProcess) Connect added in v0.16.0

func (mysqlctl *MysqlctlProcess) Connect(ctx context.Context, username string) (*mysql.Conn, error)

Connect returns a new connection to the underlying MySQL server

func (*MysqlctlProcess) ExecuteCommandWithOutput

func (mysqlctl *MysqlctlProcess) ExecuteCommandWithOutput(args ...string) (result string, err error)

ExecuteCommandWithOutput executes any mysqlctl command and returns output

func (*MysqlctlProcess) InitDb

func (mysqlctl *MysqlctlProcess) InitDb() (err error)

InitDb executes mysqlctl command to add cell info

func (*MysqlctlProcess) Start

func (mysqlctl *MysqlctlProcess) Start() (err error)

Start executes mysqlctl command to start mysql instance

func (*MysqlctlProcess) StartProcess

func (mysqlctl *MysqlctlProcess) StartProcess() (*exec.Cmd, error)

StartProcess starts the mysqlctl and returns the process reference

func (*MysqlctlProcess) StartProvideInit added in v0.15.0

func (mysqlctl *MysqlctlProcess) StartProvideInit(init bool) (err error)

StartProvideInit executes mysqlctl command to start mysql instance

func (*MysqlctlProcess) Stop

func (mysqlctl *MysqlctlProcess) Stop() (err error)

Stop executes mysqlctl command to stop mysql instance and kills the mysql instance if it doesn't shutdown in 30 seconds.

func (*MysqlctlProcess) StopProcess

func (mysqlctl *MysqlctlProcess) StopProcess() (*exec.Cmd, error)

StopProcess executes mysqlctl command to stop mysql instance and returns process reference

type MysqlctldProcess

type MysqlctldProcess struct {
	Name         string
	Binary       string
	LogDirectory string
	Password     string
	TabletUID    int
	MySQLPort    int
	InitDBFile   string
	ExtraArgs    []string

	InitMysql bool
	// contains filtered or unexported fields
}

MysqlctldProcess is a generic handle for a running mysqlctld command . It can be spawned manually

func MysqlCtldProcessInstance

func MysqlCtldProcessInstance(tabletUID int, mySQLPort int, tmpDirectory string) *MysqlctldProcess

MysqlCtldProcessInstance returns a Mysqlctld handle for mysqlctld process configured with the given Config.

func (*MysqlctldProcess) CleanupFiles

func (mysqlctld *MysqlctldProcess) CleanupFiles(tabletUID int)

CleanupFiles clean the mysql files to make sure we can start the same process again

func (*MysqlctldProcess) InitDb

func (mysqlctld *MysqlctldProcess) InitDb() (err error)

InitDb executes mysqlctld command to add cell info

func (*MysqlctldProcess) IsHealthy

func (mysqlctld *MysqlctldProcess) IsHealthy() bool

IsHealthy gives the health status of mysql.

func (*MysqlctldProcess) Start

func (mysqlctld *MysqlctldProcess) Start() error

Start starts the mysqlctld and returns the error.

func (*MysqlctldProcess) Stop

func (mysqlctld *MysqlctldProcess) Stop() error

Stop executes mysqlctld command to stop mysql instance

type PortsInfo added in v0.10.3

type PortsInfo struct {
	DNS     int `json:"dns"`
	HTTP    int `json:"http"`
	SerfLan int `json:"serf_lan"`
	SerfWan int `json:"serf_wan"`
	Server  int `json:"server"`
}

PortsInfo is the different ports used by consul

type Shard

type Shard struct {
	Name      string
	Vttablets []*Vttablet
}

Shard with associated vttablets

func (*Shard) PrimaryTablet added in v0.12.0

func (shard *Shard) PrimaryTablet() *Vttablet

PrimaryTablet get the 1st tablet which is always elected as primary

func (*Shard) Rdonly

func (shard *Shard) Rdonly() *Vttablet

Rdonly get the last tablet which is rdonly

func (*Shard) Replica

func (shard *Shard) Replica() *Vttablet

Replica get the last but one tablet which is replica Mostly we have either 3 tablet setup [primary, replica, rdonly]

type TopoProcess

type TopoProcess struct {
	Name               string
	Binary             string
	DataDirectory      string
	LogDirectory       string
	ListenClientURL    string
	AdvertiseClientURL string
	Port               int
	Host               string
	VerifyURL          string
	PeerURL            string
	ZKPorts            string
	// contains filtered or unexported fields
}

TopoProcess is a generic handle for a running Topo service . It can be spawned manually

func TopoProcessInstance

func TopoProcessInstance(port int, peerPort int, hostname string, flavor string, name string) *TopoProcess

TopoProcessInstance returns a TopoProcess handle for a etcd sevice, configured with the given Config. The process must be manually started by calling setup()

func (*TopoProcess) IsHealthy

func (topo *TopoProcess) IsHealthy() bool

IsHealthy function checks if topo server is up and running

func (*TopoProcess) ManageTopoDir

func (topo *TopoProcess) ManageTopoDir(command string, directory string) (err error)

ManageTopoDir creates global and zone in etcd2

func (*TopoProcess) Setup

func (topo *TopoProcess) Setup(topoFlavor string, cluster *LocalProcessCluster) (err error)

Setup starts a new topo service

func (*TopoProcess) SetupConsul

func (topo *TopoProcess) SetupConsul(cluster *LocalProcessCluster) (err error)

SetupConsul spawns a new consul service and initializes it with the defaults. The service is kept running in the background until TearDown() is called.

func (*TopoProcess) SetupEtcd

func (topo *TopoProcess) SetupEtcd() (err error)

SetupEtcd spawns a new etcd service and initializes it with the defaults. The service is kept running in the background until TearDown() is called.

func (*TopoProcess) SetupZookeeper

func (topo *TopoProcess) SetupZookeeper(cluster *LocalProcessCluster) (err error)

SetupZookeeper spawns a new zookeeper topo service and initializes it with the defaults. The service is kept running in the background until TearDown() is called.

func (*TopoProcess) TearDown

func (topo *TopoProcess) TearDown(Cell string, originalVtRoot string, currentRoot string, keepdata bool, topoFlavor string) error

TearDown shutdowns the running topo service

type VTOrcConfiguration added in v0.15.0

type VTOrcConfiguration struct {
	Debug                                 bool
	ListenAddress                         string
	MySQLTopologyUser                     string
	MySQLTopologyPassword                 string
	MySQLReplicaUser                      string
	MySQLReplicaPassword                  string
	RecoveryPeriodBlockSeconds            int
	PreventCrossDataCenterPrimaryFailover bool   `json:",omitempty"`
	LockShardTimeoutSeconds               int    `json:",omitempty"`
	ReplicationLagQuery                   string `json:",omitempty"`
	FailPrimaryPromotionOnLagMinutes      int    `json:",omitempty"`
}

func (*VTOrcConfiguration) AddDefaults added in v0.15.0

func (config *VTOrcConfiguration) AddDefaults(webPort int)

func (*VTOrcConfiguration) ToJSONString added in v0.15.0

func (config *VTOrcConfiguration) ToJSONString() string

ToJSONString will marshal this configuration as JSON

type VTOrcProcess added in v0.15.0

type VTOrcProcess struct {
	VtctlProcess
	Port       int
	LogDir     string
	ExtraArgs  []string
	ConfigPath string
	Config     VTOrcConfiguration
	WebPort    int
	// contains filtered or unexported fields
}

VTOrcProcess is a test struct for running vtorc as a separate process for testing

func (*VTOrcProcess) DisableGlobalRecoveries added in v0.16.0

func (orc *VTOrcProcess) DisableGlobalRecoveries(t *testing.T)

DisableGlobalRecoveries stops VTOrc from running any recoveries

func (*VTOrcProcess) EnableGlobalRecoveries added in v0.16.0

func (orc *VTOrcProcess) EnableGlobalRecoveries(t *testing.T)

EnableGlobalRecoveries allows VTOrc to run any recoveries

func (*VTOrcProcess) GetVars added in v0.15.0

func (orc *VTOrcProcess) GetVars() map[string]any

GetVars gets the variables exported on the /debug/vars page of VTOrc

func (*VTOrcProcess) MakeAPICall added in v0.15.0

func (orc *VTOrcProcess) MakeAPICall(endpoint string) (status int, response string, err error)

MakeAPICall makes an API call on the given endpoint of VTOrc

func (*VTOrcProcess) MakeAPICallRetry added in v0.16.0

func (orc *VTOrcProcess) MakeAPICallRetry(t *testing.T, url string)

MakeAPICallRetry is used to make an API call and retries until success

func (*VTOrcProcess) Setup added in v0.15.0

func (orc *VTOrcProcess) Setup() (err error)

Setup starts orc process with required arguements

func (*VTOrcProcess) TearDown added in v0.15.0

func (orc *VTOrcProcess) TearDown() error

TearDown shuts down the running vtorc service

type VtbackupProcess

type VtbackupProcess struct {
	Name      string
	Binary    string
	CommonArg VtctlProcess
	LogDir    string
	MysqlPort int
	Directory string

	Cell        string
	Keyspace    string
	Shard       string
	TabletAlias string
	Server      string

	ExtraArgs []string
	// contains filtered or unexported fields
}

VtbackupProcess is a generic handle for a running Vtbackup. It can be spawned manually

func VtbackupProcessInstance

func VtbackupProcessInstance(tabletUID int, mysqlPort int, newInitDBFile string, keyspace string, shard string,
	cell string, hostname string, tmpDirectory string, topoPort int, initialBackup bool) *VtbackupProcess

VtbackupProcessInstance returns a vtbackup handle configured with the given Config. The process must be manually started by calling Setup()

func (*VtbackupProcess) Setup

func (vtbackup *VtbackupProcess) Setup() (err error)

Setup starts vtbackup process with required arguements

func (*VtbackupProcess) TearDown

func (vtbackup *VtbackupProcess) TearDown() error

TearDown shutdowns the running vtbackup process

type VtctlClientParams added in v0.11.0

type VtctlClientParams struct {
	DDLStrategy      string
	MigrationContext string
	SkipPreflight    bool
	UUIDList         string
	CallerID         string
}

VtctlClientParams encapsulated params to provide if non-default

type VtctlClientProcess

type VtctlClientProcess struct {
	Name                    string
	Binary                  string
	Server                  string
	TempDirectory           string
	ZoneName                string
	VtctlClientMajorVersion int
}

VtctlClientProcess is a generic handle for a running vtctlclient command . It can be spawned manually

func VtctlClientProcessInstance

func VtctlClientProcessInstance(hostname string, grpcPort int, tmpDirectory string) *VtctlClientProcess

VtctlClientProcessInstance returns a VtctlProcess handle for vtctlclient process configured with the given Config.

func (*VtctlClientProcess) ApplyRoutingRules added in v0.9.0

func (vtctlclient *VtctlClientProcess) ApplyRoutingRules(JSON string) (err error)

ApplyRoutingRules does it

func (*VtctlClientProcess) ApplySchema

func (vtctlclient *VtctlClientProcess) ApplySchema(Keyspace string, SQL string) error

ApplySchema applies SQL schema to the keyspace

func (*VtctlClientProcess) ApplySchemaWithOutput added in v0.8.0

func (vtctlclient *VtctlClientProcess) ApplySchemaWithOutput(Keyspace string, SQL string, params VtctlClientParams) (result string, err error)

ApplySchemaWithOutput applies SQL schema to the keyspace

func (*VtctlClientProcess) ApplyShardRoutingRules added in v0.15.0

func (vtctlclient *VtctlClientProcess) ApplyShardRoutingRules(JSON string) (err error)

ApplyRoutingRules does it

func (*VtctlClientProcess) ApplyVSchema

func (vtctlclient *VtctlClientProcess) ApplyVSchema(Keyspace string, JSON string) (err error)

ApplyVSchema applies vitess schema (JSON format) to the keyspace

func (*VtctlClientProcess) ExecuteCommand

func (vtctlclient *VtctlClientProcess) ExecuteCommand(args ...string) (err error)

ExecuteCommand executes any vtctlclient command

func (*VtctlClientProcess) ExecuteCommandWithOutput

func (vtctlclient *VtctlClientProcess) ExecuteCommandWithOutput(args ...string) (string, error)

ExecuteCommandWithOutput executes any vtctlclient command and returns output

func (*VtctlClientProcess) InitShardPrimary added in v0.12.0

func (vtctlclient *VtctlClientProcess) InitShardPrimary(Keyspace string, Shard string, Cell string, TabletUID int) (err error)

InitShardPrimary executes vtctlclient command to make specified tablet the primary for the shard.

func (*VtctlClientProcess) InitTablet

func (vtctlclient *VtctlClientProcess) InitTablet(tablet *Vttablet, cell string, keyspaceName string, hostname string, shardName string) error

InitTablet initializes a tablet

func (*VtctlClientProcess) InitializeShard added in v0.13.0

func (vtctlclient *VtctlClientProcess) InitializeShard(Keyspace string, Shard string, Cell string, TabletUID int) (err error)

InitializeShard executes vtctlclient command to make specified tablet the primary for the shard.

func (*VtctlClientProcess) OnlineDDLCancelAllMigrations added in v0.9.0

func (vtctlclient *VtctlClientProcess) OnlineDDLCancelAllMigrations(Keyspace string) (result string, err error)

OnlineDDLCancelAllMigrations cancels all migrations for a keyspace

func (*VtctlClientProcess) OnlineDDLCancelMigration added in v0.8.0

func (vtctlclient *VtctlClientProcess) OnlineDDLCancelMigration(Keyspace, uuid string) (result string, err error)

OnlineDDLCancelMigration cancels a given migration uuid

func (*VtctlClientProcess) OnlineDDLRetryMigration added in v0.8.0

func (vtctlclient *VtctlClientProcess) OnlineDDLRetryMigration(Keyspace, uuid string) (result string, err error)

OnlineDDLRetryMigration retries a given migration uuid

func (*VtctlClientProcess) OnlineDDLRevertMigration added in v0.10.0

func (vtctlclient *VtctlClientProcess) OnlineDDLRevertMigration(Keyspace, uuid string) (result string, err error)

OnlineDDLRevertMigration reverts a given migration uuid

func (*VtctlClientProcess) OnlineDDLShowRecent added in v0.8.0

func (vtctlclient *VtctlClientProcess) OnlineDDLShowRecent(Keyspace string) (result string, err error)

OnlineDDLShowRecent responds with recent schema migration list

func (*VtctlClientProcess) VExec added in v0.10.0

func (vtctlclient *VtctlClientProcess) VExec(Keyspace, workflow, query string) (result string, err error)

VExec runs a VExec query

type VtctlProcess

type VtctlProcess struct {
	Name               string
	Binary             string
	LogDir             string
	TopoImplementation string
	TopoGlobalAddress  string
	TopoGlobalRoot     string
	TopoServerAddress  string
	TopoRootPath       string
	VtctlMajorVersion  int
}

VtctlProcess is a generic handle for a running vtctl command . It can be spawned manually

func VtctlProcessInstance

func VtctlProcessInstance(topoPort int, hostname string) *VtctlProcess

VtctlProcessInstance returns a VtctlProcess handle for vtctl process configured with the given Config. The process must be manually started by calling setup()

func (*VtctlProcess) AddCellInfo

func (vtctl *VtctlProcess) AddCellInfo(Cell string) (err error)

AddCellInfo executes vtctl command to add cell info

func (*VtctlProcess) CreateKeyspace

func (vtctl *VtctlProcess) CreateKeyspace(keyspace string) (err error)

CreateKeyspace executes vtctl command to create keyspace

func (*VtctlProcess) ExecuteCommand

func (vtctl *VtctlProcess) ExecuteCommand(args ...string) (err error)

ExecuteCommand executes any vtctlclient command

func (*VtctlProcess) ExecuteCommandWithOutput

func (vtctl *VtctlProcess) ExecuteCommandWithOutput(args ...string) (result string, err error)

ExecuteCommandWithOutput executes any vtctlclient command and returns output

type VtctldClientProcess added in v0.14.0

type VtctldClientProcess struct {
	Name                     string
	Binary                   string
	Server                   string
	TempDirectory            string
	ZoneName                 string
	VtctldClientMajorVersion int
}

VtctldClientProcess is a generic handle for a running vtctldclient command . It can be spawned manually

func VtctldClientProcessInstance added in v0.14.0

func VtctldClientProcessInstance(hostname string, grpcPort int, tmpDirectory string) *VtctldClientProcess

VtctldClientProcessInstance returns a VtctldProcess handle for vtctldclient process configured with the given Config.

func (*VtctldClientProcess) ExecuteCommand added in v0.14.0

func (vtctldclient *VtctldClientProcess) ExecuteCommand(args ...string) (err error)

ExecuteCommand executes any vtctldclient command

func (*VtctldClientProcess) ExecuteCommandWithOutput added in v0.14.0

func (vtctldclient *VtctldClientProcess) ExecuteCommandWithOutput(args ...string) (string, error)

ExecuteCommandWithOutput executes any vtctldclient command and returns output

type VtctldProcess

type VtctldProcess struct {
	Name                        string
	Binary                      string
	CommonArg                   VtctlProcess
	ServiceMap                  string
	BackupStorageImplementation string
	FileBackupStorageRoot       string
	LogDir                      string
	Port                        int
	GrpcPort                    int
	VerifyURL                   string
	Directory                   string
	// contains filtered or unexported fields
}

VtctldProcess is a generic handle for a running vtctld . It can be spawned manually

func VtctldProcessInstance

func VtctldProcessInstance(httpPort int, grpcPort int, topoPort int, hostname string, tmpDirectory string) *VtctldProcess

VtctldProcessInstance returns a VtctlProcess handle for vtctl process configured with the given Config. The process must be manually started by calling setup()

func (*VtctldProcess) IsHealthy

func (vtctld *VtctldProcess) IsHealthy() bool

IsHealthy function checks if vtctld process is up and running

func (*VtctldProcess) Setup

func (vtctld *VtctldProcess) Setup(cell string, extraArgs ...string) (err error)

Setup starts vtctld process with required arguements

func (*VtctldProcess) TearDown

func (vtctld *VtctldProcess) TearDown() error

TearDown shutdowns the running vtctld service

type VtgateProcess

type VtgateProcess struct {
	Name                  string
	Binary                string
	CommonArg             VtctlProcess
	LogDir                string
	FileToLogQueries      string
	Port                  int
	GrpcPort              int
	MySQLServerPort       int
	MySQLServerSocketPath string
	Cell                  string
	CellsToWatch          string
	TabletTypesToWait     string
	ServiceMap            string
	MySQLAuthServerImpl   string
	Directory             string
	VerifyURL             string
	VSchemaURL            string
	SysVarSetEnabled      bool
	PlannerVersion        plancontext.PlannerVersion
	// Extra Args to be set before starting the vtgate process
	ExtraArgs []string
	// contains filtered or unexported fields
}

VtgateProcess is a generic handle for a running vtgate . It can be spawned manually

func VtgateProcessInstance

func VtgateProcessInstance(
	port, grpcPort, mySQLServerPort int,
	cell, cellsToWatch, hostname, tabletTypesToWait string,
	topoPort int,
	tmpDirectory string,
	extraArgs []string,
	plannerVersion plancontext.PlannerVersion,
) *VtgateProcess

VtgateProcessInstance returns a Vtgate handle for vtgate process configured with the given Config. The process must be manually started by calling setup()

func (*VtgateProcess) GetStatusForTabletOfShard

func (vtgate *VtgateProcess) GetStatusForTabletOfShard(name string, endPointsCount int) bool

GetStatusForTabletOfShard function gets status for a specific tablet of a shard in keyspace endPointsCount : number of endpoints

func (*VtgateProcess) GetVars

func (vtgate *VtgateProcess) GetVars() (map[string]any, error)

GetVars returns map of vars

func (*VtgateProcess) ReadVSchema added in v0.13.2

func (vtgate *VtgateProcess) ReadVSchema() (*interface{}, error)

ReadVSchema reads the vschema from the vtgate endpoint for it and returns a pointer to the interface. To read this vschema, the caller must convert it to a map

func (*VtgateProcess) Setup

func (vtgate *VtgateProcess) Setup() (err error)

Setup starts Vtgate process with required arguements

func (*VtgateProcess) TearDown

func (vtgate *VtgateProcess) TearDown() error

TearDown shuts down the running vtgate service

func (*VtgateProcess) WaitForStatus

func (vtgate *VtgateProcess) WaitForStatus() bool

WaitForStatus function checks if vtgate process is up and running

func (*VtgateProcess) WaitForStatusOfTabletInShard

func (vtgate *VtgateProcess) WaitForStatusOfTabletInShard(name string, endPointsCount int, timeout time.Duration) error

WaitForStatusOfTabletInShard function waits till status of a tablet in shard is 1 endPointsCount: how many endpoints to wait for

type VtgrProcess added in v0.12.0

type VtgrProcess struct {
	VtctlProcess
	LogDir    string
	ExtraArgs []string
	// contains filtered or unexported fields
}

VtgrProcess represents the vtgr process

func (*VtgrProcess) Start added in v0.12.0

func (vtgr *VtgrProcess) Start(alias string) (err error)

Start starts vtgr process with required arguements

func (*VtgrProcess) TearDown added in v0.12.0

func (vtgr *VtgrProcess) TearDown() error

TearDown shuts down the running vtgr service

type Vttablet

type Vttablet struct {
	Type      string
	TabletUID int
	HTTPPort  int
	GrpcPort  int
	MySQLPort int
	Alias     string
	Cell      string

	// background executable processes
	MysqlctlProcess  MysqlctlProcess
	MysqlctldProcess MysqlctldProcess
	VttabletProcess  *VttabletProcess
	VtgrProcess      *VtgrProcess
}

Vttablet stores the properties needed to start a vttablet process

func (*Vttablet) Restart

func (tablet *Vttablet) Restart() error

Restart restarts vttablet and mysql.

func (*Vttablet) RestartOnlyTablet added in v0.11.0

func (tablet *Vttablet) RestartOnlyTablet() error

RestartOnlyTablet restarts vttablet, but not the underlying mysql instance

func (*Vttablet) ValidateTabletRestart

func (tablet *Vttablet) ValidateTabletRestart(t *testing.T)

ValidateTabletRestart restarts the tablet and validate error if there is any.

type VttabletProcess

type VttabletProcess struct {
	Name                        string
	Binary                      string
	FileToLogQueries            string
	TabletUID                   int
	TabletPath                  string
	Cell                        string
	Port                        int
	GrpcPort                    int
	Shard                       string
	CommonArg                   VtctlProcess
	LogDir                      string
	TabletHostname              string
	Keyspace                    string
	TabletType                  string
	HealthCheckInterval         int
	BackupStorageImplementation string
	FileBackupStorageRoot       string
	ServiceMap                  string
	VtctldAddress               string
	Directory                   string
	VerifyURL                   string
	QueryzURL                   string
	StatusDetailsURL            string
	SupportsBackup              bool
	ServingStatus               string
	DbPassword                  string
	DbPort                      int
	VreplicationTabletType      string
	DbFlavor                    string
	Charset                     string
	ConsolidationsURL           string

	//Extra Args to be set before starting the vttablet process
	ExtraArgs []string
	// contains filtered or unexported fields
}

VttabletProcess is a generic handle for a running vttablet . It can be spawned manually

func VttabletProcessInstance

func VttabletProcessInstance(port, grpcPort, tabletUID int, cell, shard, keyspace string, vtctldPort int, tabletType string, topoPort int, hostname, tmpDirectory string, extraArgs []string, charset string) *VttabletProcess

VttabletProcessInstance returns a VttabletProcess handle for vttablet process configured with the given Config. The process must be manually started by calling setup()

func (*VttabletProcess) BulkLoad added in v0.11.0

func (vttablet *VttabletProcess) BulkLoad(t testing.TB, db, table string, bulkInsert func(io.Writer))

BulkLoad performs a bulk load of rows into a given vttablet.

func (*VttabletProcess) CreateDB

func (vttablet *VttabletProcess) CreateDB(keyspace string) error

CreateDB creates the database for keyspace

func (*VttabletProcess) GetConsolidations added in v0.16.0

func (vttablet *VttabletProcess) GetConsolidations() (map[string]int, error)

GetConsolidations gets consolidations

func (*VttabletProcess) GetDBStatus

func (vttablet *VttabletProcess) GetDBStatus(status string, ksName string) (string, error)

GetDBStatus returns first matching database variable's value

func (*VttabletProcess) GetDBVar

func (vttablet *VttabletProcess) GetDBVar(varName string, ksName string) (string, error)

GetDBVar returns first matching database variable's value

func (*VttabletProcess) GetStatus

func (vttablet *VttabletProcess) GetStatus() string

GetStatus returns /debug/status endpoint result

func (*VttabletProcess) GetStatusDetails

func (vttablet *VttabletProcess) GetStatusDetails() string

GetStatusDetails gets the status details

func (*VttabletProcess) GetTabletStatus

func (vttablet *VttabletProcess) GetTabletStatus() string

GetTabletStatus returns the tablet state as seen in /debug/vars TabletStateName

func (*VttabletProcess) GetTabletType added in v0.12.0

func (vttablet *VttabletProcess) GetTabletType() string

GetTabletType returns the tablet type as seen in /debug/vars TabletType

func (*VttabletProcess) GetVars

func (vttablet *VttabletProcess) GetVars() map[string]any

GetVars gets the debug vars as map

func (*VttabletProcess) IsShutdown added in v0.12.0

func (vttablet *VttabletProcess) IsShutdown() bool

IsShutdown returns whether a vttablet is shutdown or not

func (*VttabletProcess) QueryTablet

func (vttablet *VttabletProcess) QueryTablet(query string, keyspace string, useDb bool) (*sqltypes.Result, error)

QueryTablet lets you execute a query in this tablet and get the result

func (*VttabletProcess) QueryTabletWithDB

func (vttablet *VttabletProcess) QueryTabletWithDB(query string, dbname string) (*sqltypes.Result, error)

QueryTabletWithDB lets you execute query on a specific DB in this tablet and get the result

func (*VttabletProcess) Setup

func (vttablet *VttabletProcess) Setup() (err error)

Setup starts vttablet process with required arguements

func (*VttabletProcess) TearDown

func (vttablet *VttabletProcess) TearDown() error

TearDown shuts down the running vttablet service and fails after 10 seconds

func (*VttabletProcess) TearDownWithTimeout added in v0.12.0

func (vttablet *VttabletProcess) TearDownWithTimeout(timeout time.Duration) error

TearDownWithTimeout shuts down the running vttablet service and fails once the given duration has elapsed.

func (*VttabletProcess) ToggleProfiling added in v0.11.0

func (vttablet *VttabletProcess) ToggleProfiling() error

ToggleProfiling enables or disables the configured CPU profiler on this vttablet

func (*VttabletProcess) WaitForBinLogPlayerCount

func (vttablet *VttabletProcess) WaitForBinLogPlayerCount(expectedCount int) error

WaitForBinLogPlayerCount waits till binlog player count var matches

func (*VttabletProcess) WaitForBinlogServerState

func (vttablet *VttabletProcess) WaitForBinlogServerState(expectedStatus string) error

WaitForBinlogServerState wait for the tablet's binlog server to be in the provided state.

func (*VttabletProcess) WaitForStatus

func (vttablet *VttabletProcess) WaitForStatus(status string, howLong time.Duration) bool

WaitForStatus waits till desired status of tablet is reached

func (*VttabletProcess) WaitForTabletStatus added in v0.12.0

func (vttablet *VttabletProcess) WaitForTabletStatus(expectedStatus string) error

WaitForTabletStatus waits for 10 second till expected status is reached

func (*VttabletProcess) WaitForTabletStatuses added in v0.12.0

func (vttablet *VttabletProcess) WaitForTabletStatuses(expectedStatuses []string) error

WaitForTabletStatuses waits for 10 second till one of expected statuses is reached

func (*VttabletProcess) WaitForTabletStatusesForTimeout added in v0.12.0

func (vttablet *VttabletProcess) WaitForTabletStatusesForTimeout(expectedStatuses []string, timeout time.Duration) error

WaitForTabletStatusesForTimeout waits till the tablet reaches to any of the provided statuses

func (*VttabletProcess) WaitForTabletTypes

func (vttablet *VttabletProcess) WaitForTabletTypes(expectedTypes []string) error

WaitForTabletTypes waits for 10 second till one of expected statuses is reached

func (*VttabletProcess) WaitForTabletTypesForTimeout

func (vttablet *VttabletProcess) WaitForTabletTypesForTimeout(expectedTypes []string, timeout time.Duration) error

WaitForTabletTypesForTimeout waits till the tablet reaches to any of the provided types

func (*VttabletProcess) WaitForVReplicationToCatchup added in v0.11.0

func (vttablet *VttabletProcess) WaitForVReplicationToCatchup(t testing.TB, workflow, database string, duration time.Duration)

WaitForVReplicationToCatchup waits for "workflow" to finish copying

Jump to

Keyboard shortcuts

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