scheduleTaskAttempt(taskId);
launchTaskAttempt(mockTask.getLastAttempt().getID());
updateAttemptState(mockTask.getLastAttempt(), TaskAttemptState.RUNNING);
// Add a speculative task attempt that succeeds
mockTask.handle(new TaskEventTAUpdate(mockTask.getLastAttempt().getID(),
TaskEventType.T_ADD_SPEC_ATTEMPT));
launchTaskAttempt(mockTask.getLastAttempt().getID());
updateAttemptState(mockTask.getLastAttempt(), TaskAttemptState.RUNNING);
assertTrue("Second attempt should commit",
mockTask.canCommit(mockTask.getAttemptList().get(1).getID()));
assertFalse("First attempt should not commit",
mockTask.canCommit(mockTask.getAttemptList().get(0).getID()));
// During the task attempt commit there is an exception which causes
// the second attempt to fail
updateAttemptState(mockTask.getLastAttempt(), TaskAttemptState.FAILED);
failRunningTaskAttempt(mockTask.getLastAttempt().getID());
assertEquals(2, mockTask.getAttemptList().size());
assertFalse("Second attempt should not commit",
mockTask.canCommit(mockTask.getAttemptList().get(1).getID()));
assertTrue("First attempt should commit",
mockTask.canCommit(mockTask.getAttemptList().get(0).getID()));
updateAttemptState(mockTask.getAttemptList().get(0), TaskAttemptState.SUCCEEDED);
mockTask.handle(new TaskEventTAUpdate(mockTask.getAttemptList().get(0).getID(),
TaskEventType.T_ATTEMPT_SUCCEEDED));
assertTaskSucceededState();
}