示例#1
0
 /// <summary>Simple test some methods of JobHistory</summary>
 /// <exception cref="System.Exception"/>
 public virtual void TestJobHistoryMethods()
 {
     Log.Info("STARTING testJobHistoryMethods");
     try
     {
         Configuration configuration = new Configuration();
         configuration.SetClass(CommonConfigurationKeysPublic.NetTopologyNodeSwitchMappingImplKey
                                , typeof(TestJobHistoryParsing.MyResolver), typeof(DNSToSwitchMapping));
         RackResolver.Init(configuration);
         MRApp app = new TestJobHistoryEvents.MRAppWithHistory(1, 1, true, this.GetType().
                                                               FullName, true);
         app.Submit(configuration);
         Org.Apache.Hadoop.Mapreduce.V2.App.Job.Job job = app.GetContext().GetAllJobs().Values
                                                          .GetEnumerator().Next();
         app.WaitForState(job, JobState.Succeeded);
         JobHistory jobHistory = new JobHistory();
         jobHistory.Init(configuration);
         // Method getAllJobs
         NUnit.Framework.Assert.AreEqual(1, jobHistory.GetAllJobs().Count);
         // and with ApplicationId
         NUnit.Framework.Assert.AreEqual(1, jobHistory.GetAllJobs(app.GetAppID()).Count);
         JobsInfo jobsinfo = jobHistory.GetPartialJobs(0L, 10L, null, "default", 0L, Runtime
                                                       .CurrentTimeMillis() + 1, 0L, Runtime.CurrentTimeMillis() + 1, JobState.Succeeded
                                                       );
         NUnit.Framework.Assert.AreEqual(1, jobsinfo.GetJobs().Count);
         NUnit.Framework.Assert.IsNotNull(jobHistory.GetApplicationAttemptId());
         // test Application Id
         NUnit.Framework.Assert.AreEqual("application_0_0000", jobHistory.GetApplicationID
                                             ().ToString());
         NUnit.Framework.Assert.AreEqual("Job History Server", jobHistory.GetApplicationName
                                             ());
         // method does not work
         NUnit.Framework.Assert.IsNull(jobHistory.GetEventHandler());
         // method does not work
         NUnit.Framework.Assert.IsNull(jobHistory.GetClock());
         // method does not work
         NUnit.Framework.Assert.IsNull(jobHistory.GetClusterInfo());
     }
     finally
     {
         Log.Info("FINISHED testJobHistoryMethods");
     }
 }