Support pausing jobs #104313
@ -116,6 +116,7 @@ func TestTaskStatusChangeQueuedToFailed(t *testing.T) {
|
||||
mocks.expectBroadcastTaskChange(task, api.TaskStatusQueued, api.TaskStatusFailed)
|
||||
mocks.expectSaveJobWithStatus(t, task.Job, api.JobStatusActive)
|
||||
mocks.persist.EXPECT().CountTasksOfJobInStatus(ctx, task.Job, api.TaskStatusFailed).Return(1, 100, nil) // 1 out of 100 failed.
|
||||
mocks.persist.EXPECT().CountTasksOfJobInStatus(ctx, task.Job, api.TaskStatusActive).Return(0, 100, nil) // 0 out of 100 active.
|
||||
mocks.expectBroadcastJobChange(task.Job, api.JobStatusQueued, api.JobStatusActive)
|
||||
|
||||
require.NoError(t, sm.TaskStatusChange(ctx, task, api.TaskStatusFailed))
|
||||
@ -188,8 +189,10 @@ func TestTaskStatusChangeCancelSingleTask(t *testing.T) {
|
||||
mocks.expectWriteTaskLogTimestamped(t, task, "task changed status active -> canceled")
|
||||
mocks.expectBroadcastTaskChange(task, api.TaskStatusActive, api.TaskStatusCanceled)
|
||||
mocks.persist.EXPECT().CountTasksOfJobInStatus(ctx, job,
|
||||
api.TaskStatusActive, api.TaskStatusQueued, api.TaskStatusSoftFailed).
|
||||
api.TaskStatusActive, api.TaskStatusQueued, api.TaskStatusSoftFailed, api.TaskStatusPaused).
|
||||
Return(1, 2, nil)
|
||||
mocks.persist.EXPECT().CountTasksOfJobInStatus(ctx, job,
|
||||
api.TaskStatusActive).Return(0, 2, nil)
|
||||
require.NoError(t, sm.TaskStatusChange(ctx, task, api.TaskStatusCanceled))
|
||||
|
||||
// T2: queued > cancelled --> J: cancel-requested > canceled
|
||||
@ -197,7 +200,7 @@ func TestTaskStatusChangeCancelSingleTask(t *testing.T) {
|
||||
mocks.expectWriteTaskLogTimestamped(t, task2, "task changed status queued -> canceled")
|
||||
mocks.expectBroadcastTaskChange(task2, api.TaskStatusQueued, api.TaskStatusCanceled)
|
||||
mocks.persist.EXPECT().CountTasksOfJobInStatus(ctx, job,
|
||||
api.TaskStatusActive, api.TaskStatusQueued, api.TaskStatusSoftFailed).
|
||||
api.TaskStatusActive, api.TaskStatusQueued, api.TaskStatusSoftFailed, api.TaskStatusPaused).
|
||||
Return(0, 2, nil)
|
||||
mocks.expectSaveJobWithStatus(t, job, api.JobStatusCanceled)
|
||||
mocks.expectBroadcastJobChange(task.Job, api.JobStatusCancelRequested, api.JobStatusCanceled)
|
||||
|
Loading…
Reference in New Issue
Block a user