Documentation ¶
Index ¶
- func CreateSubTask(t *testing.T, gm *storage.TaskManager, taskID int64, step proto.Step, ...) int64
- func DeleteSubtasksByTaskID(ctx context.Context, mgr *storage.TaskManager, taskID int64) error
- func GetCommonCleanUpRoutine(ctrl *gomock.Controller) scheduler.CleanUpRoutine
- func GetCommonStepExecutor(ctrl *gomock.Controller, step proto.Step, ...) *mockexecute.MockStepExecutor
- func GetCommonTaskExecutorExt(ctrl *gomock.Controller, ...) *mock.MockExtension
- func GetMockBasicSchedulerExt(ctrl *gomock.Controller) scheduler.Extension
- func GetMockHATestSchedulerExt(ctrl *gomock.Controller) scheduler.Extension
- func GetMockRollbackSchedulerExt(ctrl *gomock.Controller) scheduler.Extension
- func GetMockSchedulerExt(ctrl *gomock.Controller, schedulerInfo SchedulerInfo) scheduler.Extension
- func GetOneTask(ctx context.Context, mgr *storage.TaskManager) (task *proto.Task, err error)
- func GetPlanErrSchedulerExt(ctrl *gomock.Controller, testContext *TestContext) scheduler.Extension
- func GetPlanNotRetryableErrSchedulerExt(ctrl *gomock.Controller) scheduler.Extension
- func GetStepTwoPlanNotRetryableErrSchedulerExt(ctrl *gomock.Controller) scheduler.Extension
- func GetSubtaskEndTime(ctx context.Context, mgr *storage.TaskManager, subtaskID int64) (time.Time, error)
- func GetSubtaskNodes(ctx context.Context, mgr *storage.TaskManager, taskID int64) ([]string, error)
- func GetSubtasksByTaskID(ctx context.Context, mgr *storage.TaskManager, taskID int64) ([]*proto.Subtask, error)
- func GetSubtasksFromHistory(ctx context.Context, mgr *storage.TaskManager) (int, error)
- func GetSubtasksFromHistoryByTaskID(ctx context.Context, mgr *storage.TaskManager, taskID int64) (int, error)
- func GetTaskEndTime(ctx context.Context, mgr *storage.TaskManager, taskID int64) (time.Time, error)
- func GetTasksFromHistory(ctx context.Context, mgr *storage.TaskManager) (int, error)
- func GetTasksFromHistoryInStates(ctx context.Context, mgr *storage.TaskManager, states ...any) (task []*proto.Task, err error)
- func InitTableTest(t *testing.T) (kv.Storage, *storage.TaskManager, context.Context)
- func InitTableTestWithCancel(t *testing.T) (*storage.TaskManager, context.Context, context.CancelFunc)
- func InitTaskExecutor(ctrl *gomock.Controller, ...)
- func InsertSubtask(t *testing.T, gm *storage.TaskManager, taskID int64, step proto.Step, ...) int64
- func IsTaskCancelling(ctx context.Context, mgr *storage.TaskManager, taskID int64) (bool, error)
- func PrintSubtaskInfo(ctx context.Context, mgr *storage.TaskManager, taskID int64)
- func ReduceCheckInterval(t testing.TB)
- func RegisterExampleTask(t testing.TB, schedulerExt scheduler.Extension, ...)
- func RegisterTaskTypeForRollback(t testing.TB, ctrl *gomock.Controller, schedulerExt scheduler.Extension, ...)
- func SubmitAndWaitTask(ctx context.Context, t testing.TB, taskKey string, targetScope string, ...) *proto.TaskBase
- func TransferSubTasks2History(ctx context.Context, mgr *storage.TaskManager, taskID int64) error
- func UpdateSubtaskExecID(ctx context.Context, mgr *storage.TaskManager, tidbID string, subtaskID int64) error
- func WaitTaskDone(ctx context.Context, t testing.TB, taskKey string) *proto.TaskBase
- func WaitTaskDoneOrPaused(ctx context.Context, t testing.TB, taskKey string) *proto.TaskBase
- type SchedulerInfo
- type StepInfo
- type TestContext
- type TestDXFContext
- func (c *TestDXFContext) AsyncChangeOwner()
- func (c *TestDXFContext) AsyncShutdown(id string)
- func (c *TestDXFContext) ChangeOwner()
- func (c *TestDXFContext) GetNodeIDByIdx(idx int) string
- func (c *TestDXFContext) GetRandNodeIDs(limit int) map[string]struct{}
- func (c *TestDXFContext) NodeCount() int
- func (c *TestDXFContext) ScaleIn(nodeNum int)
- func (c *TestDXFContext) ScaleInBy(id string)
- func (c *TestDXFContext) ScaleOut(nodeNum int)
- func (c *TestDXFContext) ScaleOutBy(id string, owner bool)
- func (c *TestDXFContext) WaitAsyncOperations()
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CreateSubTask ¶
func CreateSubTask(t *testing.T, gm *storage.TaskManager, taskID int64, step proto.Step, execID string, meta []byte, tp proto.TaskType, concurrency int) int64
CreateSubTask adds a new task to subtask table. used for testing.
func DeleteSubtasksByTaskID ¶
DeleteSubtasksByTaskID deletes the subtask of the given task ID.
func GetCommonCleanUpRoutine ¶
func GetCommonCleanUpRoutine(ctrl *gomock.Controller) scheduler.CleanUpRoutine
GetCommonCleanUpRoutine returns a common cleanup routine.
func GetCommonStepExecutor ¶
func GetCommonStepExecutor(ctrl *gomock.Controller, step proto.Step, runSubtaskFn func(ctx context.Context, subtask *proto.Subtask) error) *mockexecute.MockStepExecutor
GetCommonStepExecutor returns one mock subtaskExecutor.
func GetCommonTaskExecutorExt ¶
func GetCommonTaskExecutorExt(ctrl *gomock.Controller, getStepExecFn func(*proto.Task) (execute.StepExecutor, error)) *mock.MockExtension
GetCommonTaskExecutorExt returns a common task executor extension.
func GetMockBasicSchedulerExt ¶
func GetMockBasicSchedulerExt(ctrl *gomock.Controller) scheduler.Extension
GetMockBasicSchedulerExt returns mock scheduler.Extension with basic functionalities.
func GetMockHATestSchedulerExt ¶
func GetMockHATestSchedulerExt(ctrl *gomock.Controller) scheduler.Extension
GetMockHATestSchedulerExt returns mock scheduler.Extension for HA testing with multiple steps.
func GetMockRollbackSchedulerExt ¶
func GetMockRollbackSchedulerExt(ctrl *gomock.Controller) scheduler.Extension
GetMockRollbackSchedulerExt returns mock scheduler.Extension which will generate rollback subtasks.
func GetMockSchedulerExt ¶
func GetMockSchedulerExt(ctrl *gomock.Controller, schedulerInfo SchedulerInfo) scheduler.Extension
GetMockSchedulerExt returns mock scheduler.Extension with input stepInfos. the returned scheduler.Extension will go from StepInit -> each step in stepInfos -> StepDone.
func GetOneTask ¶
GetOneTask get a task from task table
func GetPlanErrSchedulerExt ¶
func GetPlanErrSchedulerExt(ctrl *gomock.Controller, testContext *TestContext) scheduler.Extension
GetPlanErrSchedulerExt returns mock scheduler.Extension which will generate error when planning.
func GetPlanNotRetryableErrSchedulerExt ¶
func GetPlanNotRetryableErrSchedulerExt(ctrl *gomock.Controller) scheduler.Extension
GetPlanNotRetryableErrSchedulerExt returns mock scheduler.Extension which will generate non retryable error when planning.
func GetStepTwoPlanNotRetryableErrSchedulerExt ¶
func GetStepTwoPlanNotRetryableErrSchedulerExt(ctrl *gomock.Controller) scheduler.Extension
GetStepTwoPlanNotRetryableErrSchedulerExt returns mock scheduler.Extension which will generate non retryable error when planning for step two.
func GetSubtaskEndTime ¶
func GetSubtaskEndTime(ctx context.Context, mgr *storage.TaskManager, subtaskID int64) (time.Time, error)
GetSubtaskEndTime gets subtask's endTime for test.
func GetSubtaskNodes ¶
GetSubtaskNodes gets nodes that are running or have run the task for test.
func GetSubtasksByTaskID ¶
func GetSubtasksByTaskID(ctx context.Context, mgr *storage.TaskManager, taskID int64) ([]*proto.Subtask, error)
GetSubtasksByTaskID gets subtasks by taskID for test.
func GetSubtasksFromHistory ¶
GetSubtasksFromHistory gets subtasks from history table for test.
func GetSubtasksFromHistoryByTaskID ¶
func GetSubtasksFromHistoryByTaskID(ctx context.Context, mgr *storage.TaskManager, taskID int64) (int, error)
GetSubtasksFromHistoryByTaskID gets subtasks by taskID from history table for test.
func GetTaskEndTime ¶
GetTaskEndTime gets task's endTime for test.
func GetTasksFromHistory ¶
GetTasksFromHistory gets tasks from history table for test.
func GetTasksFromHistoryInStates ¶
func GetTasksFromHistoryInStates(ctx context.Context, mgr *storage.TaskManager, states ...any) (task []*proto.Task, err error)
GetTasksFromHistoryInStates gets the tasks in history table in the states.
func InitTableTest ¶
InitTableTest inits needed components for table_test. it disables disttask and mock cpu count to 8.
func InitTableTestWithCancel ¶
func InitTableTestWithCancel(t *testing.T) (*storage.TaskManager, context.Context, context.CancelFunc)
InitTableTestWithCancel inits needed components with context.CancelFunc for table_test.
func InitTaskExecutor ¶
func InitTaskExecutor(ctrl *gomock.Controller, runSubtaskFn func(ctx context.Context, subtask *proto.Subtask) error)
InitTaskExecutor inits all mock components for TaskExecutor.
func InsertSubtask ¶
func InsertSubtask(t *testing.T, gm *storage.TaskManager, taskID int64, step proto.Step, execID string, meta []byte, state proto.SubtaskState, tp proto.TaskType, concurrency int) int64
InsertSubtask adds a new subtask of any state to subtask table.
func IsTaskCancelling ¶
IsTaskCancelling checks whether the task state is cancelling.
func PrintSubtaskInfo ¶
func PrintSubtaskInfo(ctx context.Context, mgr *storage.TaskManager, taskID int64)
PrintSubtaskInfo log the subtask info by taskKey for test.
func ReduceCheckInterval ¶
ReduceCheckInterval reduces the check interval for test.
func RegisterExampleTask ¶
func RegisterExampleTask( t testing.TB, schedulerExt scheduler.Extension, executorExt taskexecutor.Extension, mockCleanup scheduler.CleanUpRoutine, )
RegisterExampleTask register example task.
func RegisterTaskTypeForRollback ¶
func RegisterTaskTypeForRollback(t testing.TB, ctrl *gomock.Controller, schedulerExt scheduler.Extension, testContext *TestContext)
RegisterTaskTypeForRollback register rollback task meta.
func SubmitAndWaitTask ¶
func SubmitAndWaitTask(ctx context.Context, t testing.TB, taskKey string, targetScope string, concurrency int) *proto.TaskBase
SubmitAndWaitTask schedule one task.
func TransferSubTasks2History ¶
TransferSubTasks2History move subtasks from tidb_background_subtask to tidb_background_subtask_history.
func UpdateSubtaskExecID ¶
func UpdateSubtaskExecID(ctx context.Context, mgr *storage.TaskManager, tidbID string, subtaskID int64) error
UpdateSubtaskExecID updates the subtask's exec_id, used for testing now.
func WaitTaskDone ¶
WaitTaskDone wait task done.
Types ¶
type SchedulerInfo ¶
SchedulerInfo is used for mocking scheduler.Extension.
type StepInfo ¶
type StepInfo struct { Step proto.Step Err error ErrRepeatCount int64 SubtaskCnt int // contains filtered or unexported fields }
StepInfo is used for mocking scheduler.Extension.
type TestContext ¶
type TestContext struct { sync.RWMutex // for plan err handling tests. CallTime int // contains filtered or unexported fields }
TestContext defines shared variables for disttask tests.
func (*TestContext) CollectSubtask ¶
func (c *TestContext) CollectSubtask(subtask *proto.Subtask)
CollectSubtask collects subtask info
func (*TestContext) CollectedSubtaskCnt ¶
func (c *TestContext) CollectedSubtaskCnt(taskID int64, step proto.Step) int
CollectedSubtaskCnt returns the collected subtask count.
type TestDXFContext ¶
type TestDXFContext struct { T testing.TB Store kv.Storage Ctx context.Context TaskMgr *storage.TaskManager MockCtrl *gomock.Controller TestContext *TestContext Rand *rand.Rand // contains filtered or unexported fields }
TestDXFContext is the context for testing DXF.
func NewDXFContextWithRandomNodes ¶
func NewDXFContextWithRandomNodes(t testing.TB, minCnt, maxCnt int) *TestDXFContext
NewDXFContextWithRandomNodes creates a new TestDXFContext with random number of nodes in range [minCnt, maxCnt].
func NewTestDXFContext ¶
func NewTestDXFContext(t testing.TB, nodeNum int, cpuCount int, reduceCheckInterval bool) *TestDXFContext
NewTestDXFContext creates a new TestDXFContext.
func (*TestDXFContext) AsyncChangeOwner ¶
func (c *TestDXFContext) AsyncChangeOwner()
AsyncChangeOwner resigns all current owners and changes the owner of the cluster to random node asynchronously.
func (*TestDXFContext) AsyncShutdown ¶
func (c *TestDXFContext) AsyncShutdown(id string)
AsyncShutdown shutdown node asynchronously.
func (*TestDXFContext) ChangeOwner ¶
func (c *TestDXFContext) ChangeOwner()
ChangeOwner resigns all current owners and changes the owner of the cluster to random node.
func (*TestDXFContext) GetNodeIDByIdx ¶
func (c *TestDXFContext) GetNodeIDByIdx(idx int) string
GetNodeIDByIdx returns nodeID by idx in nodes.
func (*TestDXFContext) GetRandNodeIDs ¶
func (c *TestDXFContext) GetRandNodeIDs(limit int) map[string]struct{}
GetRandNodeIDs returns `limit` random node ids. if limit > len(nodes), return all nodes.
func (*TestDXFContext) NodeCount ¶
func (c *TestDXFContext) NodeCount() int
NodeCount returns the number of nodes.
func (*TestDXFContext) ScaleIn ¶
func (c *TestDXFContext) ScaleIn(nodeNum int)
ScaleIn scales in some last added tidb nodes, elect new owner if required.
func (*TestDXFContext) ScaleInBy ¶
func (c *TestDXFContext) ScaleInBy(id string)
ScaleInBy scales in a tidb node by id, elect new owner if required.
func (*TestDXFContext) ScaleOut ¶
func (c *TestDXFContext) ScaleOut(nodeNum int)
ScaleOut scales out a tidb node, and elect owner if required.
func (*TestDXFContext) ScaleOutBy ¶
func (c *TestDXFContext) ScaleOutBy(id string, owner bool)
ScaleOutBy scales out a tidb node by id, and set it as owner if required.
func (*TestDXFContext) WaitAsyncOperations ¶
func (c *TestDXFContext) WaitAsyncOperations()
WaitAsyncOperations waits all async operations to finish.