utils

package
v0.13.2 Latest Latest
Warning

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

Go to latest
Published: Jul 26, 2022 License: Apache-2.0 Imports: 25 Imported by: 0

Documentation

Index

Constants

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

Variables

This section is empty.

Functions

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, 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 MakeAPICallUntilRegistered

func MakeAPICallUntilRegistered(t *testing.T, url string) (status int, response string)

MakeAPICallUntilRegistered is used to make an API call and retry if we see a 500 - no successor promoted output. This happens when some other recovery had previously run and the API recovery was unable to be registered due to active timeout period.

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 SetupVttabletsAndVtorc

func SetupVttabletsAndVtorc(t *testing.T, clusterInfo *VtOrcClusterInfo, numReplicasReqCell1, numRdonlyReqCell1 int, orcExtraArgs []string, configFileName string)

SetupVttabletsAndVtorc is used to setup the vttablets and start the orchestrator

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 StartVtorc

func StartVtorc(t *testing.T, clusterInfo *VtOrcClusterInfo, orcExtraArgs []string, configFileName string)

StartVtorc is used to start the orchestrator 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 StopVtorc

func StopVtorc(t *testing.T, clusterInfo *VtOrcClusterInfo)

StopVtorc is used to stop the orchestrator

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 WaitForReplicationToStop

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

WaitForReplicationToStop waits for replication to stop on the given tablet

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

type VtOrcClusterInfo struct {
	ClusterInstance *cluster.LocalProcessCluster
	Ts              *topo.Server
	CellInfos       []*CellInfo
	// 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