public virtual void TestAbsentNotificationOnNotLastRetryUnregistrationFailure() { HttpServer2 server = StartHttpServer(); MRApp app = Org.Mockito.Mockito.Spy(new TestJobEndNotifier.MRAppWithCustomContainerAllocator (this, 2, 2, false, this.GetType().FullName, true, 1, false)); Org.Mockito.Mockito.DoNothing().When(app).Sysexit(); JobConf conf = new JobConf(); conf.Set(JobContext.MrJobEndNotificationUrl, TestJobEndNotifier.JobEndServlet.baseUrl + "jobend?jobid=$jobId&status=$jobStatus"); JobImpl job = (JobImpl)app.Submit(conf); app.WaitForState(job, JobState.Running); app.GetContext().GetEventHandler().Handle(new JobEvent(app.GetJobId(), JobEventType .JobAmReboot)); app.WaitForInternalState(job, JobStateInternal.Reboot); // Now shutdown. // Unregistration fails: isLastAMRetry is recalculated, this is not app.ShutDownJob(); // Not the last AM attempt. So user should that the job is still running. app.WaitForState(job, JobState.Running); NUnit.Framework.Assert.IsFalse(app.IsLastAMRetry()); NUnit.Framework.Assert.AreEqual(0, TestJobEndNotifier.JobEndServlet.calledTimes); NUnit.Framework.Assert.IsNull(TestJobEndNotifier.JobEndServlet.requestUri); NUnit.Framework.Assert.IsNull(TestJobEndNotifier.JobEndServlet.foundJobState); server.Stop(); }
public virtual void TestNotificationOnLastRetryNormalShutdown() { HttpServer2 server = StartHttpServer(); // Act like it is the second attempt. Default max attempts is 2 MRApp app = Org.Mockito.Mockito.Spy(new TestJobEndNotifier.MRAppWithCustomContainerAllocator (this, 2, 2, true, this.GetType().FullName, true, 2, true)); Org.Mockito.Mockito.DoNothing().When(app).Sysexit(); JobConf conf = new JobConf(); conf.Set(JobContext.MrJobEndNotificationUrl, TestJobEndNotifier.JobEndServlet.baseUrl + "jobend?jobid=$jobId&status=$jobStatus"); JobImpl job = (JobImpl)app.Submit(conf); app.WaitForInternalState(job, JobStateInternal.Succeeded); // Unregistration succeeds: successfullyUnregistered is set app.ShutDownJob(); NUnit.Framework.Assert.IsTrue(app.IsLastAMRetry()); NUnit.Framework.Assert.AreEqual(1, TestJobEndNotifier.JobEndServlet.calledTimes); NUnit.Framework.Assert.AreEqual("jobid=" + job.GetID() + "&status=SUCCEEDED", TestJobEndNotifier.JobEndServlet .requestUri.GetQuery()); NUnit.Framework.Assert.AreEqual(JobState.Succeeded.ToString(), TestJobEndNotifier.JobEndServlet .foundJobState); server.Stop(); }