Exemplo n.º 1
0
// Run will run the test suite using the provided client and
// the provided tablet. Tablet's vt address needs to be configured so
// the client will connect to a server backed by our RPCAgent (returned
// by NewFakeRPCAgent)
func Run(t *testing.T, client tmclient.TabletManagerClient, tablet *topodatapb.Tablet, fakeAgent tabletmanager.RPCAgent) {
	ctx := context.Background()

	// Test RPC specific methods of the interface.
	agentRPCTestDialExpiredContext(ctx, t, client, tablet)
	agentRPCTestRPCTimeout(ctx, t, client, tablet, fakeAgent.(*fakeRPCAgent))

	// Various read-only methods
	agentRPCTestPing(ctx, t, client, tablet)
	agentRPCTestGetSchema(ctx, t, client, tablet)
	agentRPCTestGetPermissions(ctx, t, client, tablet)

	// Various read-write methods
	agentRPCTestSetReadOnly(ctx, t, client, tablet)
	agentRPCTestChangeType(ctx, t, client, tablet)
	agentRPCTestSleep(ctx, t, client, tablet)
	agentRPCTestExecuteHook(ctx, t, client, tablet)
	agentRPCTestRefreshState(ctx, t, client, tablet)
	agentRPCTestRunHealthCheck(ctx, t, client, tablet)
	agentRPCTestIgnoreHealthError(ctx, t, client, tablet)
	agentRPCTestReloadSchema(ctx, t, client, tablet)
	agentRPCTestPreflightSchema(ctx, t, client, tablet)
	agentRPCTestApplySchema(ctx, t, client, tablet)
	agentRPCTestExecuteFetch(ctx, t, client, tablet)

	// Replication related methods
	agentRPCTestSlaveStatus(ctx, t, client, tablet)
	agentRPCTestMasterPosition(ctx, t, client, tablet)
	agentRPCTestStopSlave(ctx, t, client, tablet)
	agentRPCTestStopSlaveMinimum(ctx, t, client, tablet)
	agentRPCTestStartSlave(ctx, t, client, tablet)
	agentRPCTestTabletExternallyReparented(ctx, t, client, tablet)
	agentRPCTestGetSlaves(ctx, t, client, tablet)
	agentRPCTestWaitBlpPosition(ctx, t, client, tablet)
	agentRPCTestStopBlp(ctx, t, client, tablet)
	agentRPCTestStartBlp(ctx, t, client, tablet)
	agentRPCTestRunBlpUntil(ctx, t, client, tablet)

	// Reparenting related functions
	agentRPCTestResetReplication(ctx, t, client, tablet)
	agentRPCTestInitMaster(ctx, t, client, tablet)
	agentRPCTestPopulateReparentJournal(ctx, t, client, tablet)
	agentRPCTestInitSlave(ctx, t, client, tablet)
	agentRPCTestDemoteMaster(ctx, t, client, tablet)
	agentRPCTestPromoteSlaveWhenCaughtUp(ctx, t, client, tablet)
	agentRPCTestSlaveWasPromoted(ctx, t, client, tablet)
	agentRPCTestSetMaster(ctx, t, client, tablet)
	agentRPCTestSlaveWasRestarted(ctx, t, client, tablet)
	agentRPCTestStopReplicationAndGetStatus(ctx, t, client, tablet)
	agentRPCTestPromoteSlave(ctx, t, client, tablet)

	// Backup / restore related methods
	agentRPCTestBackup(ctx, t, client, tablet)
	agentRPCTestRestoreFromBackup(ctx, t, client, tablet)

	//
	// Tests panic handling everywhere now
	//
	fakeAgent.(*fakeRPCAgent).panics = true

	// Various read-only methods
	agentRPCTestPingPanic(ctx, t, client, tablet)
	agentRPCTestGetSchemaPanic(ctx, t, client, tablet)
	agentRPCTestGetPermissionsPanic(ctx, t, client, tablet)

	// Various read-write methods
	agentRPCTestSetReadOnlyPanic(ctx, t, client, tablet)
	agentRPCTestChangeTypePanic(ctx, t, client, tablet)
	agentRPCTestSleepPanic(ctx, t, client, tablet)
	agentRPCTestExecuteHookPanic(ctx, t, client, tablet)
	agentRPCTestRefreshStatePanic(ctx, t, client, tablet)
	agentRPCTestRunHealthCheckPanic(ctx, t, client, tablet)
	agentRPCTestReloadSchemaPanic(ctx, t, client, tablet)
	agentRPCTestPreflightSchemaPanic(ctx, t, client, tablet)
	agentRPCTestApplySchemaPanic(ctx, t, client, tablet)
	agentRPCTestExecuteFetchPanic(ctx, t, client, tablet)

	// Replication related methods
	agentRPCTestSlaveStatusPanic(ctx, t, client, tablet)
	agentRPCTestMasterPositionPanic(ctx, t, client, tablet)
	agentRPCTestStopSlavePanic(ctx, t, client, tablet)
	agentRPCTestStopSlaveMinimumPanic(ctx, t, client, tablet)
	agentRPCTestStartSlavePanic(ctx, t, client, tablet)
	agentRPCTestTabletExternallyReparentedPanic(ctx, t, client, tablet)
	agentRPCTestGetSlavesPanic(ctx, t, client, tablet)
	agentRPCTestWaitBlpPositionPanic(ctx, t, client, tablet)
	agentRPCTestStopBlpPanic(ctx, t, client, tablet)
	agentRPCTestStartBlpPanic(ctx, t, client, tablet)
	agentRPCTestRunBlpUntilPanic(ctx, t, client, tablet)

	// Reparenting related functions
	agentRPCTestResetReplicationPanic(ctx, t, client, tablet)
	agentRPCTestInitMasterPanic(ctx, t, client, tablet)
	agentRPCTestPopulateReparentJournalPanic(ctx, t, client, tablet)
	agentRPCTestInitSlavePanic(ctx, t, client, tablet)
	agentRPCTestDemoteMasterPanic(ctx, t, client, tablet)
	agentRPCTestPromoteSlaveWhenCaughtUpPanic(ctx, t, client, tablet)
	agentRPCTestSlaveWasPromotedPanic(ctx, t, client, tablet)
	agentRPCTestSetMasterPanic(ctx, t, client, tablet)
	agentRPCTestSlaveWasRestartedPanic(ctx, t, client, tablet)
	agentRPCTestStopReplicationAndGetStatusPanic(ctx, t, client, tablet)
	agentRPCTestPromoteSlavePanic(ctx, t, client, tablet)

	// Backup / restore related methods
	agentRPCTestBackupPanic(ctx, t, client, tablet)
	agentRPCTestRestoreFromBackupPanic(ctx, t, client, tablet)

	client.Close()
}