예제 #1
0
        public virtual void TestNotificationOnLastRetryUnregistrationFailure()
        {
            HttpServer2 server = StartHttpServer();
            MRApp       app    = Org.Mockito.Mockito.Spy(new TestJobEndNotifier.MRAppWithCustomContainerAllocator
                                                             (this, 2, 2, false, this.GetType().FullName, true, 2, false));

            // Currently, we will have isLastRetry always equals to false at beginning
            // of MRAppMaster, except staging area exists or commit already started at
            // the beginning.
            // Now manually set isLastRetry to true and this should reset to false when
            // unregister failed.
            app.isLastAMRetry = 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.WaitForState(job, JobState.Running);
            app.GetContext().GetEventHandler().Handle(new JobEvent(app.GetJobId(), JobEventType
                                                                   .JobAmReboot));
            app.WaitForInternalState(job, JobStateInternal.Reboot);
            // Now shutdown. User should see FAILED state.
            // Unregistration fails: isLastAMRetry is recalculated, this is
            ///reboot will stop service internally, we don't need to shutdown twice
            app.WaitForServiceToStop(10000);
            NUnit.Framework.Assert.IsFalse(app.IsLastAMRetry());
            // Since it's not last retry, JobEndServlet didn't called
            NUnit.Framework.Assert.AreEqual(0, TestJobEndNotifier.JobEndServlet.calledTimes);
            NUnit.Framework.Assert.IsNull(TestJobEndNotifier.JobEndServlet.requestUri);
            NUnit.Framework.Assert.IsNull(TestJobEndNotifier.JobEndServlet.foundJobState);
            server.Stop();
        }