utils

package
v0.15.1 Latest Latest
Warning

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

Go to latest
Published: Nov 29, 2022 License: Apache-2.0 Imports: 22 Imported by: 0

Documentation

Index

Constants

View Source
const (
	Hostname = "localhost"
	Cell1    = "zone1"
	Cell2    = "zone2"
)

Variables

This section is empty.

Functions

func AddSemiSyncKeyspace added in v0.14.0

func AddSemiSyncKeyspace(t *testing.T, clusterInfo *VTOrcClusterInfo)

AddSemiSyncKeyspace is used to setup a new keyspace with semi-sync. It creates a keyspace with 3 tablets

func ChangePrivileges

func ChangePrivileges(t *testing.T, sql string, tablet *cluster.Vttablet, user string)

ChangePrivileges is used to change the privileges of the given user. These commands are executed such that they are not replicated

func CheckPrimaryTablet

func CheckPrimaryTablet(t *testing.T, clusterInfo *VTOrcClusterInfo, tablet *cluster.Vttablet, checkServing bool)

CheckPrimaryTablet waits until the specified tablet becomes the primary tablet Makes sure the tablet type is primary, and its health check agrees.

func CheckReplication

func CheckReplication(t *testing.T, clusterInfo *VTOrcClusterInfo, primary *cluster.Vttablet, replicas []*cluster.Vttablet, timeToWait time.Duration)

CheckReplication checks that the replication is setup correctly and writes succeed and are replicated on all the replicas

func CheckSourcePort

func CheckSourcePort(t *testing.T, replica *cluster.Vttablet, source *cluster.Vttablet, timeToWait time.Duration)

CheckSourcePort is used to check that the replica has the given source port set in its MySQL instance

func IsPrimarySemiSyncSetupCorrectly

func IsPrimarySemiSyncSetupCorrectly(t *testing.T, tablet *cluster.Vttablet, semiSyncVal string) bool

IsPrimarySemiSyncSetupCorrectly checks that the priamry side semi-sync is setup correctly on the given vttablet

func IsSemiSyncSetupCorrectly

func IsSemiSyncSetupCorrectly(t *testing.T, tablet *cluster.Vttablet, semiSyncVal string) bool

IsSemiSyncSetupCorrectly checks that the semi-sync is setup correctly on the given vttablet

func KillTablets

func KillTablets(vttablets []*cluster.Vttablet)

KillTablets is used to kill the tablets

func MakeAPICall

func MakeAPICall(t *testing.T, vtorc *cluster.VTOrcProcess, url string) (status int, response string)

MakeAPICall is used make an API call given the url. It returns the status and the body of the response received

func MakeAPICallRetry added in v0.15.0

func MakeAPICallRetry(t *testing.T, vtorc *cluster.VTOrcProcess, url string, retry func(int, string) bool) (status int, response string)

MakeAPICallRetry is used to make an API call and retry on the given condition. The function provided takes in the status and response and returns if we should continue to retry or not

func PermanentlyRemoveVttablet

func PermanentlyRemoveVttablet(clusterInfo *VTOrcClusterInfo, tablet *cluster.Vttablet)

PermanentlyRemoveVttablet removes the tablet specified from the cluster. It makes it so that this vttablet or mysql instance are not reused for any other test.

func ResetPrimaryLogs

func ResetPrimaryLogs(t *testing.T, curPrimary *cluster.Vttablet)

ResetPrimaryLogs is used reset the binary logs

func RunSQL

func RunSQL(t *testing.T, sql string, tablet *cluster.Vttablet, db string) (*sqltypes.Result, error)

RunSQL is used to run a SQL statement on the given tablet

func SetupVttabletsAndVTOrcs added in v0.15.0

func SetupVttabletsAndVTOrcs(t *testing.T, clusterInfo *VTOrcClusterInfo, numReplicasReqCell1, numRdonlyReqCell1 int, orcExtraArgs []string, config cluster.VTOrcConfiguration, vtorcCount int, durability string)

SetupVttabletsAndVTOrcs is used to setup the vttablets and start the vtorcs

func ShardPrimaryTablet

func ShardPrimaryTablet(t *testing.T, clusterInfo *VTOrcClusterInfo, keyspace *cluster.Keyspace, shard *cluster.Shard) *cluster.Vttablet

ShardPrimaryTablet waits until a primary tablet has been elected for the given shard and returns it

func StartVTOrcs added in v0.15.0

func StartVTOrcs(t *testing.T, clusterInfo *VTOrcClusterInfo, orcExtraArgs []string, config cluster.VTOrcConfiguration, count int)

StartVTOrcs is used to start the vtorcs with the given extra arguments

func StartVttablet

func StartVttablet(t *testing.T, clusterInfo *VTOrcClusterInfo, cell string, isRdonly bool) *cluster.Vttablet

StartVttablet is used to start a vttablet from the given cell and type

func StopVTOrcs added in v0.15.0

func StopVTOrcs(t *testing.T, clusterInfo *VTOrcClusterInfo)

StopVTOrcs is used to stop the vtorcs

func VerifyWritesSucceed

func VerifyWritesSucceed(t *testing.T, clusterInfo *VTOrcClusterInfo, primary *cluster.Vttablet, replicas []*cluster.Vttablet, timeToWait time.Duration)

VerifyWritesSucceed inserts more data into the table vt_insert_test and checks that it is replicated too Call this function only after CheckReplication has been executed once, since that function creates the table that this function uses.

func WaitForReadOnlyValue added in v0.14.0

func WaitForReadOnlyValue(t *testing.T, curPrimary *cluster.Vttablet, expectValue int64) (match bool)

WaitForReadOnlyValue waits for the read_only global variable to reach the provided value

func WaitForReplicationToStop

func WaitForReplicationToStop(t *testing.T, vttablet *cluster.Vttablet) error

WaitForReplicationToStop waits for replication to stop on the given tablet

func WaitForSuccessfulRecoveryCount added in v0.15.0

func WaitForSuccessfulRecoveryCount(t *testing.T, vtorcInstance *cluster.VTOrcProcess, recoveryName string, countExpected int)

WaitForSuccessfulRecoveryCount waits until the given recovery name's count of successful runs matches the count expected

Types

type CellInfo

type CellInfo struct {
	CellName       string
	ReplicaTablets []*cluster.Vttablet
	RdonlyTablets  []*cluster.Vttablet
	// constants that should be set in TestMain
	NumReplicas int
	NumRdonly   int
	UIDBase     int
}

CellInfo stores the information regarding 1 cell including the tablets it contains

type VTOrcClusterInfo added in v0.15.0

type VTOrcClusterInfo struct {
	ClusterInstance     *cluster.LocalProcessCluster
	Ts                  *topo.Server
	CellInfos           []*CellInfo
	VtctldClientProcess *cluster.VtctldClientProcess
	// contains filtered or unexported fields
}

VTOrcClusterInfo stores the information for a cluster. This is supposed to be used only for VTOrc tests.

func CreateClusterAndStartTopo

func CreateClusterAndStartTopo(cellInfos []*CellInfo) (*VTOrcClusterInfo, error)

CreateClusterAndStartTopo starts the cluster and topology service

func SetupNewClusterSemiSync

func SetupNewClusterSemiSync(t *testing.T) *VTOrcClusterInfo

SetupNewClusterSemiSync is used to setup a new cluster with semi-sync set. It creates a cluster with 4 tablets, one of which is a Replica

Jump to

Keyboard shortcuts

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