utils

package
v0.15.9 Latest Latest
Warning

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

Go to latest
Published: Jul 31, 2024 License: Apache-2.0 Imports: 24 Imported by: 0

Documentation

Index

Constants

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

Variables

This section is empty.

Functions

func AddSemiSyncKeyspace

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 CheckHeartbeatInterval

func CheckHeartbeatInterval(t *testing.T, replica *cluster.Vttablet, heartbeatInterval float64, timeToWait time.Duration)

CheckHeartbeatInterval is used to check that the replica has the given heartbeat interval set in its MySQL instance

func CheckMetricExists

func CheckMetricExists(t *testing.T, vtorcInstance *cluster.VTOrcProcess, metricName string)

CheckMetricExists checks whether the given metric exists or not in /metrics.

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 CheckTabletUptoDate

func CheckTabletUptoDate(t *testing.T, clusterInfo *VTOrcClusterInfo, tablet *cluster.Vttablet)

CheckTabletUptoDate verifies that the tablet has all the writes so far

func CheckVarExists

func CheckVarExists(t *testing.T, vtorcInstance *cluster.VTOrcProcess, metricName string)

CheckVarExists checks whether the given metric exists or not in /debug/vars.

func DisableGlobalRecoveries

func DisableGlobalRecoveries(t *testing.T, vtorc *cluster.VTOrcProcess)

DisableGlobalRecoveries disables global recoveries for the given VTOrc.

func EnableGlobalRecoveries

func EnableGlobalRecoveries(t *testing.T, vtorc *cluster.VTOrcProcess)

EnableGlobalRecoveries enables global recoveries for the given VTOrc.

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, err error)

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

func MakeAPICallRetry

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 PrintVTOrcLogsOnFailure

func PrintVTOrcLogsOnFailure(t *testing.T, clusterInstance *cluster.LocalProcessCluster)

PrintVTOrcLogsOnFailure prints the VTOrc logs on failure of the test. This function is supposed to be called as the first defer command from the vtorc tests.

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 RunSQLs

func RunSQLs(t *testing.T, sqls []string, tablet *cluster.Vttablet, db string) error

RunSQLs is used to run a list of SQL statements on the given tablet

func SemiSyncExtensionLoaded

func SemiSyncExtensionLoaded(t *testing.T, tablet *cluster.Vttablet) (mysql.SemiSyncType, error)

SemiSyncExtensionLoaded is used to check which semisync extension is loaded.

func SetupVttabletsAndVTOrcs

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

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

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 WaitForDetectedProblems

func WaitForDetectedProblems(t *testing.T, vtorcInstance *cluster.VTOrcProcess, code, alias, ks, shard string, expect int)

WaitForDetectedProblems waits until the given analysis code, alias, keyspace and shard count matches the count expected.

func WaitForInstancePollSecondsExceededCount

func WaitForInstancePollSecondsExceededCount(t *testing.T, vtorcInstance *cluster.VTOrcProcess, keyName string, minCountExpected float64, enforceEquality bool)

WaitForInstancePollSecondsExceededCount waits for 30 seconds and then queries api/aggregated-discovery-metrics. It expects to find minimum occurrence or exact count of `keyName` provided.

func WaitForReadOnlyValue

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 WaitForSuccessfulERSCount

func WaitForSuccessfulERSCount(t *testing.T, vtorcInstance *cluster.VTOrcProcess, keyspace, shard string, countExpected int)

WaitForSuccessfulERSCount waits until the given keyspace-shard's count of successful ers runs matches the count expected.

func WaitForSuccessfulPRSCount

func WaitForSuccessfulPRSCount(t *testing.T, vtorcInstance *cluster.VTOrcProcess, keyspace, shard string, countExpected int)

WaitForSuccessfulPRSCount waits until the given keyspace-shard's count of successful prs runs matches the count expected.

func WaitForSuccessfulRecoveryCount

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

func WaitForTabletType

func WaitForTabletType(t *testing.T, tablet *cluster.Vttablet, expectedTabletType string)

WaitForTabletType waits for the tablet to reach a certain type.

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