Support pausing jobs #104313
@ -76,6 +76,7 @@ func TestTaskStatusChangeActiveToCompleted(t *testing.T) {
|
|||||||
mocks.expectWriteTaskLogTimestamped(t, task, "task changed status active -> completed")
|
mocks.expectWriteTaskLogTimestamped(t, task, "task changed status active -> completed")
|
||||||
mocks.expectBroadcastTaskChange(task, api.TaskStatusActive, api.TaskStatusCompleted)
|
mocks.expectBroadcastTaskChange(task, api.TaskStatusActive, api.TaskStatusCompleted)
|
||||||
mocks.persist.EXPECT().CountTasksOfJobInStatus(ctx, task.Job, api.TaskStatusCompleted).Return(1, 3, nil) // 1 of 3 complete.
|
mocks.persist.EXPECT().CountTasksOfJobInStatus(ctx, task.Job, api.TaskStatusCompleted).Return(1, 3, nil) // 1 of 3 complete.
|
||||||
|
mocks.persist.EXPECT().CountTasksOfJobInStatus(ctx, task.Job, api.TaskStatusActive).Return(2, 3, nil) // 2 of 3 active.
|
||||||
require.NoError(t, sm.TaskStatusChange(ctx, task, api.TaskStatusCompleted))
|
require.NoError(t, sm.TaskStatusChange(ctx, task, api.TaskStatusCompleted))
|
||||||
|
|
||||||
// Second task hickup: T: active > soft-failed --> J: active > active
|
// Second task hickup: T: active > soft-failed --> J: active > active
|
||||||
@ -89,6 +90,7 @@ func TestTaskStatusChangeActiveToCompleted(t *testing.T) {
|
|||||||
mocks.expectWriteTaskLogTimestamped(t, task2, "task changed status soft-failed -> completed")
|
mocks.expectWriteTaskLogTimestamped(t, task2, "task changed status soft-failed -> completed")
|
||||||
mocks.expectBroadcastTaskChange(task2, api.TaskStatusSoftFailed, api.TaskStatusCompleted)
|
mocks.expectBroadcastTaskChange(task2, api.TaskStatusSoftFailed, api.TaskStatusCompleted)
|
||||||
mocks.persist.EXPECT().CountTasksOfJobInStatus(ctx, task.Job, api.TaskStatusCompleted).Return(2, 3, nil) // 2 of 3 complete.
|
mocks.persist.EXPECT().CountTasksOfJobInStatus(ctx, task.Job, api.TaskStatusCompleted).Return(2, 3, nil) // 2 of 3 complete.
|
||||||
|
mocks.persist.EXPECT().CountTasksOfJobInStatus(ctx, task.Job, api.TaskStatusActive).Return(1, 3, nil) // 1 of 3 active.
|
||||||
require.NoError(t, sm.TaskStatusChange(ctx, task2, api.TaskStatusCompleted))
|
require.NoError(t, sm.TaskStatusChange(ctx, task2, api.TaskStatusCompleted))
|
||||||
|
|
||||||
// Third task completing: T: active > completed --> J: active > completed
|
// Third task completing: T: active > completed --> J: active > completed
|
||||||
@ -96,6 +98,7 @@ func TestTaskStatusChangeActiveToCompleted(t *testing.T) {
|
|||||||
mocks.expectWriteTaskLogTimestamped(t, task3, "task changed status active -> completed")
|
mocks.expectWriteTaskLogTimestamped(t, task3, "task changed status active -> completed")
|
||||||
mocks.expectBroadcastTaskChange(task3, api.TaskStatusActive, api.TaskStatusCompleted)
|
mocks.expectBroadcastTaskChange(task3, api.TaskStatusActive, api.TaskStatusCompleted)
|
||||||
mocks.persist.EXPECT().CountTasksOfJobInStatus(ctx, task.Job, api.TaskStatusCompleted).Return(3, 3, nil) // 3 of 3 complete.
|
mocks.persist.EXPECT().CountTasksOfJobInStatus(ctx, task.Job, api.TaskStatusCompleted).Return(3, 3, nil) // 3 of 3 complete.
|
||||||
|
mocks.persist.EXPECT().CountTasksOfJobInStatus(ctx, task.Job, api.TaskStatusActive).Return(0, 3, nil) // 0 of 3 active.
|
||||||
mocks.expectSaveJobWithStatus(t, task.Job, api.JobStatusCompleted)
|
mocks.expectSaveJobWithStatus(t, task.Job, api.JobStatusCompleted)
|
||||||
mocks.expectBroadcastJobChange(task.Job, api.JobStatusActive, api.JobStatusCompleted)
|
mocks.expectBroadcastJobChange(task.Job, api.JobStatusActive, api.JobStatusCompleted)
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user