// run a job which gets stuck in mapper and kill it. /// <exception cref="System.Exception"/> private void TestKilledJob(string fileName, Type output, string[] exclude) { Path outDir = GetNewOutputDir(); Job job = MapReduceTestUtil.CreateKillJob(conf, outDir, inDir); job.SetOutputFormatClass(output); job.Submit(); // wait for the setup to be completed while (job.SetupProgress() != 1.0f) { UtilsForTests.WaitFor(100); } job.KillJob(); // kill the job NUnit.Framework.Assert.IsFalse("Job did not get kill", job.WaitForCompletion(true )); if (fileName != null) { Path testFile = new Path(outDir, fileName); NUnit.Framework.Assert.IsTrue("File " + testFile + " missing for job " + job.GetJobID (), fs.Exists(testFile)); } // check if the files from the missing set exists foreach (string ex in exclude) { Path file = new Path(outDir, ex); NUnit.Framework.Assert.IsFalse("File " + file + " should not be present for killed job " + job.GetJobID(), fs.Exists(file)); } }
/// <exception cref="System.Exception"/> public virtual void TestJobControlWithKillJob() { Log.Info("Starting testJobControlWithKillJob"); Configuration conf = CreateJobConf(); CleanupData(conf); Job job1 = MapReduceTestUtil.CreateKillJob(conf, outdir_1, indir); JobControl theControl = CreateDependencies(conf, job1); while (cjob1.GetJobState() != ControlledJob.State.Running) { try { Sharpen.Thread.Sleep(100); } catch (Exception) { break; } } // verify adding dependingJo to RUNNING job fails. NUnit.Framework.Assert.IsFalse(cjob1.AddDependingJob(cjob2)); // suspend jobcontrol and resume it again theControl.Suspend(); NUnit.Framework.Assert.IsTrue(theControl.GetThreadState() == JobControl.ThreadState .Suspended); theControl.Resume(); // kill the first job. cjob1.KillJob(); // wait till all the jobs complete WaitTillAllFinished(theControl); NUnit.Framework.Assert.IsTrue(cjob1.GetJobState() == ControlledJob.State.Failed); NUnit.Framework.Assert.IsTrue(cjob2.GetJobState() == ControlledJob.State.Success); NUnit.Framework.Assert.IsTrue(cjob3.GetJobState() == ControlledJob.State.DependentFailed ); NUnit.Framework.Assert.IsTrue(cjob4.GetJobState() == ControlledJob.State.DependentFailed ); theControl.Stop(); }