public virtual void TestMRTimelineEventHandling() { Configuration conf = new YarnConfiguration(); conf.SetBoolean(YarnConfiguration.TimelineServiceEnabled, true); conf.SetBoolean(MRJobConfig.MapreduceJobEmitTimelineData, true); MiniMRYarnCluster cluster = null; try { cluster = new MiniMRYarnCluster(typeof(TestJobHistoryEventHandler).Name, 1); cluster.Init(conf); cluster.Start(); conf.Set(YarnConfiguration.TimelineServiceWebappAddress, MiniYARNCluster.GetHostname () + ":" + cluster.GetApplicationHistoryServer().GetPort()); TimelineStore ts = cluster.GetApplicationHistoryServer().GetTimelineStore(); Path inDir = new Path("input"); Path outDir = new Path("output"); RunningJob job = UtilsForTests.RunJobSucceed(new JobConf(conf), inDir, outDir); NUnit.Framework.Assert.AreEqual(JobStatus.Succeeded, job.GetJobStatus().GetState( ).GetValue()); TimelineEntities entities = ts.GetEntities("MAPREDUCE_JOB", null, null, null, null , null, null, null, null, null); NUnit.Framework.Assert.AreEqual(1, entities.GetEntities().Count); TimelineEntity tEntity = entities.GetEntities()[0]; NUnit.Framework.Assert.AreEqual(job.GetID().ToString(), tEntity.GetEntityId()); NUnit.Framework.Assert.AreEqual("MAPREDUCE_JOB", tEntity.GetEntityType()); NUnit.Framework.Assert.AreEqual(EventType.AmStarted.ToString(), tEntity.GetEvents ()[tEntity.GetEvents().Count - 1].GetEventType()); NUnit.Framework.Assert.AreEqual(EventType.JobFinished.ToString(), tEntity.GetEvents ()[0].GetEventType()); job = UtilsForTests.RunJobFail(new JobConf(conf), inDir, outDir); NUnit.Framework.Assert.AreEqual(JobStatus.Failed, job.GetJobStatus().GetState().GetValue ()); entities = ts.GetEntities("MAPREDUCE_JOB", null, null, null, null, null, null, null , null, null); NUnit.Framework.Assert.AreEqual(2, entities.GetEntities().Count); tEntity = entities.GetEntities()[0]; NUnit.Framework.Assert.AreEqual(job.GetID().ToString(), tEntity.GetEntityId()); NUnit.Framework.Assert.AreEqual("MAPREDUCE_JOB", tEntity.GetEntityType()); NUnit.Framework.Assert.AreEqual(EventType.AmStarted.ToString(), tEntity.GetEvents ()[tEntity.GetEvents().Count - 1].GetEventType()); NUnit.Framework.Assert.AreEqual(EventType.JobFailed.ToString(), tEntity.GetEvents ()[0].GetEventType()); } finally { if (cluster != null) { cluster.Stop(); } } }
/// <exception cref="System.Exception"/> public virtual void TestMR() { System.Console.Out.WriteLine(LaunchWordCount(this.CreateJobConf(), "a b c d e f g h" , 1, 1)); bool keepTrying = true; for (int tries = 0; tries < 30 && keepTrying; tries++) { Sharpen.Thread.Sleep(50); keepTrying = !(NotificationTestCase.NotificationServlet.counter == 2); } NUnit.Framework.Assert.AreEqual(2, NotificationTestCase.NotificationServlet.counter ); NUnit.Framework.Assert.AreEqual(0, NotificationTestCase.NotificationServlet.failureCounter ); Path inDir = new Path("notificationjob/input"); Path outDir = new Path("notificationjob/output"); // Hack for local FS that does not have the concept of a 'mounting point' if (IsLocalFS()) { string localPathRoot = Runtime.GetProperty("test.build.data", "/tmp").ToString(). Replace(' ', '+'); inDir = new Path(localPathRoot, inDir); outDir = new Path(localPathRoot, outDir); } // run a job with KILLED status System.Console.Out.WriteLine(UtilsForTests.RunJobKill(this.CreateJobConf(), inDir , outDir).GetID()); keepTrying = true; for (int tries_1 = 0; tries_1 < 30 && keepTrying; tries_1++) { Sharpen.Thread.Sleep(50); keepTrying = !(NotificationTestCase.NotificationServlet.counter == 4); } NUnit.Framework.Assert.AreEqual(4, NotificationTestCase.NotificationServlet.counter ); NUnit.Framework.Assert.AreEqual(0, NotificationTestCase.NotificationServlet.failureCounter ); // run a job with FAILED status System.Console.Out.WriteLine(UtilsForTests.RunJobFail(this.CreateJobConf(), inDir , outDir).GetID()); keepTrying = true; for (int tries_2 = 0; tries_2 < 30 && keepTrying; tries_2++) { Sharpen.Thread.Sleep(50); keepTrying = !(NotificationTestCase.NotificationServlet.counter == 6); } NUnit.Framework.Assert.AreEqual(6, NotificationTestCase.NotificationServlet.counter ); NUnit.Framework.Assert.AreEqual(0, NotificationTestCase.NotificationServlet.failureCounter ); }