cluster

package
v0.12.0 Latest Latest
Warning

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

Go to latest
Published: Oct 26, 2021 License: Apache-2.0 Imports: 32 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 (

	// 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 ExecuteQueriesUsingVtgate

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

ExecuteQueriesUsingVtgate sends query to vtgate using vtgate session.

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 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 VerifyLocalMetadata

func VerifyLocalMetadata(t *testing.T, tablet *Vttablet, ksName string, shardName string, cell string)

VerifyLocalMetadata Verify Local Metadata of a tablet

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 WaitForReplicationPos

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

WaitForReplicationPos will wait for replication position to catch-up

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
	BaseTabletUID      int
	Hostname           string
	TopoFlavor         string
	TopoPort           int
	TmpDirectory       string
	OriginalVTDATAROOT string
	CurrentVTDATAROOT  string
	ReusingVTDATAROOT  bool

	VtgateMySQLPort int
	VtgateGrpcPort  int
	VtctldHTTPPort  int

	// standalone executable
	VtctlclientProcess VtctlClientProcess
	VtctlProcess       VtctlProcess

	// background executable processes
	TopoProcess     TopoProcess
	VtctldProcess   VtctldProcess
	VtgateProcess   VtgateProcess
	VtworkerProcess VtworkerProcess
	VtbackupProcess VtbackupProcess
	VtorcProcess    *VtorcProcess

	//Extra arguments for vtTablet
	VtTabletExtraArgs []string

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

	VtctldExtraArgs []string

	EnableSemiSync bool

	context.Context
	context.CancelFunc
	// contains filtered or unexported fields
}

LocalProcessCluster Testcases need to use this to iniate a cluster

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) 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) ListBackups

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

ListBackups Lists back preset in shard

func (*LocalProcessCluster) NewOrcProcess added in v0.8.0

func (cluster *LocalProcessCluster) NewOrcProcess(configFile string) *VtorcProcess

NewOrcProcess 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) 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 ...interface{}) (err error)

StartKeyspace 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) StartVtbackup

func (cluster *LocalProcessCluster) StartVtbackup(newInitDBFile string, initalBackup 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) StartVtworker

func (cluster *LocalProcessCluster) StartVtworker(cell string, extraArgs ...string) error

StartVtworker starts a vtworker

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) 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 healthy as per vtgate

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) CleanupFiles

func (mysqlctl *MysqlctlProcess) CleanupFiles(tabletUID int)

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

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) Stop

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

Stop executes mysqlctl command to stop mysql instance

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 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
	SkipPreflight bool
}

VtctlClientParams encapsulated params to provide if non-default

type VtctlClientProcess

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

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) 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) (result string, err 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) 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
	TopoImplementation string
	TopoGlobalAddress  string
	TopoGlobalRoot     string
	TopoServerAddress  string
	TopoRootPath       string
}

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 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
	GatewayImplementation string
	ServiceMap            string
	MySQLAuthServerImpl   string
	Directory             string
	VerifyURL             string
	SysVarSetEnabled      bool
	PlannerVersion        planbuilder.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 planbuilder.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]interface{}, error)

GetVars returns map of vars

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) 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 VtorcProcess added in v0.8.0

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

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

func (*VtorcProcess) Setup added in v0.8.0

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

Setup starts orc process with required arguements

func (*VtorcProcess) TearDown added in v0.8.0

func (orc *VtorcProcess) TearDown() error

TearDown shuts down the running vtorc 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
	EnableSemiSync              bool
	SupportsBackup              bool
	ServingStatus               string
	DbPassword                  string
	DbPort                      int
	VreplicationTabletType      string
	DbFlavor                    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 int, grpcPort int, tabletUID int, cell string, shard string, keyspace string, vtctldPort int, tabletType string, topoPort int, hostname string, tmpDirectory string, extraArgs []string, enableSemiSync bool) *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) 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]interface{}

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) 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

type VtworkerProcess

type VtworkerProcess struct {
	Name                   string
	Binary                 string
	CommonArg              VtctlProcess
	ServiceMap             string
	LogDir                 string
	Port                   int
	GrpcPort               int
	VerifyURL              string
	Directory              string
	ExecuteRetryTime       string
	Cell                   string
	Server                 string
	CommandDisplayInterval string
	ExtraArgs              []string
	// contains filtered or unexported fields
}

VtworkerProcess is a generic handle for a running vtworker . It can be spawned manually

func VtworkerProcessInstance

func VtworkerProcessInstance(httpPort int, grpcPort int, topoPort int, hostname string, tmpDirectory string) *VtworkerProcess

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

func (*VtworkerProcess) ExecuteCommand

func (vtworker *VtworkerProcess) ExecuteCommand(args ...string) (err error)

ExecuteCommand executes any vtworker command

func (*VtworkerProcess) ExecuteCommandInBg

func (vtworker *VtworkerProcess) ExecuteCommandInBg(args ...string) (*exec.Cmd, error)

func (*VtworkerProcess) ExecuteVtworkerCommand

func (vtworker *VtworkerProcess) ExecuteVtworkerCommand(port int, grpcPort int, args ...string) (err error)

ExecuteVtworkerCommand executes any vtworker command

func (*VtworkerProcess) GetVars

func (vtworker *VtworkerProcess) GetVars() (map[string]interface{}, error)

GetVars returns map of vars

func (*VtworkerProcess) IsHealthy

func (vtworker *VtworkerProcess) IsHealthy() bool

IsHealthy function checks if vtworker process is up and running

func (*VtworkerProcess) Setup

func (vtworker *VtworkerProcess) Setup(cell string) (err error)

Setup starts vtworker process with required arguements

func (*VtworkerProcess) TearDown

func (vtworker *VtworkerProcess) TearDown() error

TearDown shutdowns the running vtworker process

Jump to

Keyboard shortcuts

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