コード例 #1
0
        public virtual void TestKillJob()
        {
            JobControl    jobControl = new JobControl("Test");
            ControlledJob job        = CreateFailedControlledJob(jobControl);

            job.KillJob();
            // Verify that killJob() was called on the mock Job
            Org.Mockito.Mockito.Verify(job.GetJob()).KillJob();
        }
コード例 #2
0
        /// <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();
        }