예제 #1
0
        // run a job for which all the attempts simply fail.
        /// <exception cref="System.IO.IOException"/>
        private void TestFailedJob(string fileName, Type committer, string[] exclude)
        {
            JobConf jc     = mr.CreateJobConf();
            Path    outDir = GetNewOutputDir();

            ConfigureJob(jc, "fail job with abort()", 1, 0, outDir);
            jc.SetMaxMapAttempts(1);
            // set the job to fail
            jc.SetMapperClass(typeof(UtilsForTests.FailMapper));
            jc.SetOutputCommitter(committer);
            JobClient  jobClient = new JobClient(jc);
            RunningJob job       = jobClient.SubmitJob(jc);
            JobID      id        = job.GetID();

            job.WaitForCompletion();
            NUnit.Framework.Assert.AreEqual("Job did not fail", JobStatus.Failed, job.GetJobState
                                                ());
            if (fileName != null)
            {
                Path testFile = new Path(outDir, fileName);
                NUnit.Framework.Assert.IsTrue("File " + testFile + " missing for failed job " + id
                                              , fileSys.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 failed job "
                                               + id, fileSys.Exists(file));
            }
        }
예제 #2
0
        // runs a sample job as a user (ugi)
        /// <exception cref="System.Exception"/>
        internal virtual void RunJobAsUser(JobConf job, UserGroupInformation ugi)
        {
            RunningJob rj = ugi.DoAs(new _PrivilegedExceptionAction_66(job));

            rj.WaitForCompletion();
            NUnit.Framework.Assert.AreEqual("SUCCEEDED", JobStatus.GetJobRunState(rj.GetJobState
                                                                                      ()));
        }
예제 #3
0
        /// <exception cref="System.IO.IOException"/>
        public virtual void TestCommitFail()
        {
            Path    inDir   = new Path(rootDir, "./input");
            Path    outDir  = new Path(rootDir, "./output");
            JobConf jobConf = CreateJobConf();

            jobConf.SetMaxMapAttempts(1);
            jobConf.SetOutputCommitter(typeof(TestTaskCommit.CommitterWithCommitFail));
            RunningJob rJob = UtilsForTests.RunJob(jobConf, inDir, outDir, 1, 0);

            rJob.WaitForCompletion();
            NUnit.Framework.Assert.AreEqual(JobStatus.Failed, rJob.GetJobState());
        }
예제 #4
0
        // Run a job that will be killed and wait until it completes
        /// <exception cref="System.IO.IOException"/>
        public static RunningJob RunJobKill(JobConf conf, Path inDir, Path outDir)
        {
            conf.SetJobName("test-job-kill");
            conf.SetMapperClass(typeof(UtilsForTests.KillMapper));
            conf.SetReducerClass(typeof(IdentityReducer));
            RunningJob job        = UtilsForTests.RunJob(conf, inDir, outDir);
            long       sleepCount = 0;

            while (job.GetJobState() != JobStatus.Running)
            {
                try
                {
                    if (sleepCount > 300)
                    {
                        // 30 seconds
                        throw new IOException("Job didn't finish in 30 seconds");
                    }
                    Sharpen.Thread.Sleep(100);
                    sleepCount++;
                }
                catch (Exception)
                {
                    break;
                }
            }
            job.KillJob();
            sleepCount = 0;
            while (job.CleanupProgress() == 0.0f)
            {
                try
                {
                    if (sleepCount > 2000)
                    {
                        // 20 seconds
                        throw new IOException("Job cleanup didn't start in 20 seconds");
                    }
                    Sharpen.Thread.Sleep(10);
                    sleepCount++;
                }
                catch (Exception)
                {
                    break;
                }
            }
            return(job);
        }
예제 #5
0
        // run a job which gets stuck in mapper and kill it.
        /// <exception cref="System.IO.IOException"/>
        private void TestKilledJob(string fileName, Type committer, string[] exclude)
        {
            JobConf jc     = mr.CreateJobConf();
            Path    outDir = GetNewOutputDir();

            ConfigureJob(jc, "kill job with abort()", 1, 0, outDir);
            // set the job to wait for long
            jc.SetMapperClass(typeof(UtilsForTests.KillMapper));
            jc.SetOutputCommitter(committer);
            JobClient  jobClient = new JobClient(jc);
            RunningJob job       = jobClient.SubmitJob(jc);
            JobID      id        = job.GetID();
            Counters   counters  = job.GetCounters();

            // wait for the map to be launched
            while (true)
            {
                if (counters.GetCounter(JobCounter.TotalLaunchedMaps) == 1)
                {
                    break;
                }
                Log.Info("Waiting for a map task to be launched");
                UtilsForTests.WaitFor(100);
                counters = job.GetCounters();
            }
            job.KillJob();
            // kill the job
            job.WaitForCompletion();
            // wait for the job to complete
            NUnit.Framework.Assert.AreEqual("Job was not killed", JobStatus.Killed, job.GetJobState
                                                ());
            if (fileName != null)
            {
                Path testFile = new Path(outDir, fileName);
                NUnit.Framework.Assert.IsTrue("File " + testFile + " missing for job " + id, fileSys
                                              .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 "
                                               + id, fileSys.Exists(file));
            }
        }
예제 #6
0
        //Starts the job in a thread. It also starts the taskKill/tasktrackerKill
        //threads.
        /// <exception cref="System.Exception"/>
        private void RunTest(JobClient jc, Configuration conf, string jobClass, string[]
                             args, ReliabilityTest.KillTaskThread killTaskThread, ReliabilityTest.KillTrackerThread
                             killTrackerThread)
        {
            Sharpen.Thread t = new _Thread_202(this, conf, jobClass, args, "Job Test");
            t.SetDaemon(true);
            t.Start();
            JobStatus[] jobs;
            //get the job ID. This is the job that we just submitted
            while ((jobs = jc.JobsToComplete()).Length == 0)
            {
                Log.Info("Waiting for the job " + jobClass + " to start");
                Sharpen.Thread.Sleep(1000);
            }
            JobID      jobId = ((JobID)jobs[jobs.Length - 1].GetJobID());
            RunningJob rJob  = jc.GetJob(jobId);

            if (rJob.IsComplete())
            {
                Log.Error("The last job returned by the querying JobTracker is complete :" + rJob
                          .GetJobID() + " .Exiting the test");
                System.Environment.Exit(-1);
            }
            while (rJob.GetJobState() == JobStatus.Prep)
            {
                Log.Info("JobID : " + jobId + " not started RUNNING yet");
                Sharpen.Thread.Sleep(1000);
                rJob = jc.GetJob(jobId);
            }
            if (killTaskThread != null)
            {
                killTaskThread.SetRunningJob(rJob);
                killTaskThread.Start();
                killTaskThread.Join();
                Log.Info("DONE WITH THE TASK KILL/FAIL TESTS");
            }
            if (killTrackerThread != null)
            {
                killTrackerThread.SetRunningJob(rJob);
                killTrackerThread.Start();
                killTrackerThread.Join();
                Log.Info("DONE WITH THE TESTS TO DO WITH LOST TASKTRACKERS");
            }
            t.Join();
        }