public virtual void TestKillSuccessfulTask() { Log.Info("--- START: testKillSuccesfulTask ---"); mockTask = CreateMockTask(TaskType.Map); TaskId taskId = GetNewTaskID(); ScheduleTaskAttempt(taskId); LaunchTaskAttempt(GetLastAttempt().GetAttemptId()); CommitTaskAttempt(GetLastAttempt().GetAttemptId()); mockTask.Handle(new TaskTAttemptEvent(GetLastAttempt().GetAttemptId(), TaskEventType .TAttemptSucceeded)); AssertTaskSucceededState(); mockTask.Handle(new TaskEvent(taskId, TaskEventType.TKill)); AssertTaskSucceededState(); }
public virtual void TestSpeculativeMapFailedFetchFailure() { // Setup a scenario where speculative task wins, first attempt succeeds mockTask = CreateMockTask(TaskType.Map); RunSpeculativeTaskAttemptSucceeds(TaskEventType.TAttemptFailed); NUnit.Framework.Assert.AreEqual(2, taskAttempts.Count); // speculative attempt retroactively fails from fetch failures mockTask.Handle(new TaskTAttemptEvent(taskAttempts[1].GetAttemptId(), TaskEventType .TAttemptFailed)); AssertTaskScheduledState(); NUnit.Framework.Assert.AreEqual(3, taskAttempts.Count); }
public virtual void TestCountersWithSpeculation() { mockTask = new _MockTaskImpl_715(jobId, partition, dispatcher.GetEventHandler(), remoteJobConfFile, conf, taskAttemptListener, jobToken, credentials, clock, startCount , metrics, appContext, TaskType.Map); TaskId taskId = GetNewTaskID(); ScheduleTaskAttempt(taskId); LaunchTaskAttempt(GetLastAttempt().GetAttemptId()); UpdateLastAttemptState(TaskAttemptState.Running); TestTaskImpl.MockTaskAttemptImpl baseAttempt = GetLastAttempt(); // add a speculative attempt mockTask.Handle(new TaskTAttemptEvent(GetLastAttempt().GetAttemptId(), TaskEventType .TAddSpecAttempt)); LaunchTaskAttempt(GetLastAttempt().GetAttemptId()); UpdateLastAttemptState(TaskAttemptState.Running); TestTaskImpl.MockTaskAttemptImpl specAttempt = GetLastAttempt(); NUnit.Framework.Assert.AreEqual(2, taskAttempts.Count); Counters specAttemptCounters = new Counters(); Counter cpuCounter = specAttemptCounters.FindCounter(TaskCounter.CpuMilliseconds); cpuCounter.SetValue(1000); specAttempt.SetCounters(specAttemptCounters); // have the spec attempt succeed but second attempt at 1.0 progress as well CommitTaskAttempt(specAttempt.GetAttemptId()); specAttempt.SetProgress(1.0f); specAttempt.SetState(TaskAttemptState.Succeeded); mockTask.Handle(new TaskTAttemptEvent(specAttempt.GetAttemptId(), TaskEventType.TAttemptSucceeded )); NUnit.Framework.Assert.AreEqual(TaskState.Succeeded, mockTask.GetState()); baseAttempt.SetProgress(1.0f); Counters taskCounters = mockTask.GetCounters(); NUnit.Framework.Assert.AreEqual("wrong counters for task", specAttemptCounters, taskCounters ); }
public virtual void TestFailureDuringTaskAttemptCommit() { mockTask = CreateMockTask(TaskType.Map); TaskId taskId = GetNewTaskID(); ScheduleTaskAttempt(taskId); LaunchTaskAttempt(GetLastAttempt().GetAttemptId()); UpdateLastAttemptState(TaskAttemptState.CommitPending); CommitTaskAttempt(GetLastAttempt().GetAttemptId()); // During the task attempt commit there is an exception which causes // the attempt to fail UpdateLastAttemptState(TaskAttemptState.Failed); FailRunningTaskAttempt(GetLastAttempt().GetAttemptId()); NUnit.Framework.Assert.AreEqual(2, taskAttempts.Count); UpdateLastAttemptState(TaskAttemptState.Succeeded); CommitTaskAttempt(GetLastAttempt().GetAttemptId()); mockTask.Handle(new TaskTAttemptEvent(GetLastAttempt().GetAttemptId(), TaskEventType .TAttemptSucceeded)); NUnit.Framework.Assert.IsFalse("First attempt should not commit", mockTask.CanCommit (taskAttempts[0].GetAttemptId())); NUnit.Framework.Assert.IsTrue("Second attempt should commit", mockTask.CanCommit( GetLastAttempt().GetAttemptId())); AssertTaskSucceededState(); }
public virtual void TestFailedTransitions() { mockTask = new _MockTaskImpl_648(jobId, partition, dispatcher.GetEventHandler(), remoteJobConfFile, conf, taskAttemptListener, jobToken, credentials, clock, startCount , metrics, appContext, TaskType.Map); TaskId taskId = GetNewTaskID(); ScheduleTaskAttempt(taskId); LaunchTaskAttempt(GetLastAttempt().GetAttemptId()); // add three more speculative attempts mockTask.Handle(new TaskTAttemptEvent(GetLastAttempt().GetAttemptId(), TaskEventType .TAddSpecAttempt)); LaunchTaskAttempt(GetLastAttempt().GetAttemptId()); mockTask.Handle(new TaskTAttemptEvent(GetLastAttempt().GetAttemptId(), TaskEventType .TAddSpecAttempt)); LaunchTaskAttempt(GetLastAttempt().GetAttemptId()); mockTask.Handle(new TaskTAttemptEvent(GetLastAttempt().GetAttemptId(), TaskEventType .TAddSpecAttempt)); LaunchTaskAttempt(GetLastAttempt().GetAttemptId()); NUnit.Framework.Assert.AreEqual(4, taskAttempts.Count); // have the first attempt fail, verify task failed due to no retries TestTaskImpl.MockTaskAttemptImpl taskAttempt = taskAttempts[0]; taskAttempt.SetState(TaskAttemptState.Failed); mockTask.Handle(new TaskTAttemptEvent(taskAttempt.GetAttemptId(), TaskEventType.TAttemptFailed )); NUnit.Framework.Assert.AreEqual(TaskState.Failed, mockTask.GetState()); // verify task can no longer be killed mockTask.Handle(new TaskEvent(taskId, TaskEventType.TKill)); NUnit.Framework.Assert.AreEqual(TaskState.Failed, mockTask.GetState()); // verify speculative doesn't launch new tasks mockTask.Handle(new TaskTAttemptEvent(GetLastAttempt().GetAttemptId(), TaskEventType .TAddSpecAttempt)); mockTask.Handle(new TaskTAttemptEvent(GetLastAttempt().GetAttemptId(), TaskEventType .TAttemptLaunched)); NUnit.Framework.Assert.AreEqual(TaskState.Failed, mockTask.GetState()); NUnit.Framework.Assert.AreEqual(4, taskAttempts.Count); // verify attempt events from active tasks don't knock task out of FAILED taskAttempt = taskAttempts[1]; taskAttempt.SetState(TaskAttemptState.CommitPending); mockTask.Handle(new TaskTAttemptEvent(taskAttempt.GetAttemptId(), TaskEventType.TAttemptCommitPending )); NUnit.Framework.Assert.AreEqual(TaskState.Failed, mockTask.GetState()); taskAttempt.SetState(TaskAttemptState.Failed); mockTask.Handle(new TaskTAttemptEvent(taskAttempt.GetAttemptId(), TaskEventType.TAttemptFailed )); NUnit.Framework.Assert.AreEqual(TaskState.Failed, mockTask.GetState()); taskAttempt = taskAttempts[2]; taskAttempt.SetState(TaskAttemptState.Succeeded); mockTask.Handle(new TaskTAttemptEvent(taskAttempt.GetAttemptId(), TaskEventType.TAttemptSucceeded )); NUnit.Framework.Assert.AreEqual(TaskState.Failed, mockTask.GetState()); taskAttempt = taskAttempts[3]; taskAttempt.SetState(TaskAttemptState.Killed); mockTask.Handle(new TaskTAttemptEvent(taskAttempt.GetAttemptId(), TaskEventType.TAttemptKilled )); NUnit.Framework.Assert.AreEqual(TaskState.Failed, mockTask.GetState()); }