private Org.Apache.Hadoop.Mapreduce.V2.App.Job.Job GetJob() { Org.Apache.Hadoop.Mapreduce.V2.App.Job.Job job = Org.Mockito.Mockito.Mock <Org.Apache.Hadoop.Mapreduce.V2.App.Job.Job >(); JobId jobId = new JobIdPBImpl(); ApplicationId appId = ApplicationIdPBImpl.NewInstance(Runtime.CurrentTimeMillis() , 4); jobId.SetAppId(appId); jobId.SetId(1); Org.Mockito.Mockito.When(job.GetID()).ThenReturn(jobId); JobReport report = Org.Mockito.Mockito.Mock <JobReport>(); Org.Mockito.Mockito.When(report.GetStartTime()).ThenReturn(100010L); Org.Mockito.Mockito.When(report.GetFinishTime()).ThenReturn(100015L); Org.Mockito.Mockito.When(job.GetReport()).ThenReturn(report); Org.Mockito.Mockito.When(job.GetName()).ThenReturn("JobName"); Org.Mockito.Mockito.When(job.GetUserName()).ThenReturn("UserName"); Org.Mockito.Mockito.When(job.GetQueueName()).ThenReturn("QueueName"); Org.Mockito.Mockito.When(job.GetState()).ThenReturn(JobState.Succeeded); Org.Mockito.Mockito.When(job.GetTotalMaps()).ThenReturn(3); Org.Mockito.Mockito.When(job.GetCompletedMaps()).ThenReturn(2); Org.Mockito.Mockito.When(job.GetTotalReduces()).ThenReturn(2); Org.Mockito.Mockito.When(job.GetCompletedReduces()).ThenReturn(1); Org.Mockito.Mockito.When(job.GetCompletedReduces()).ThenReturn(1); return(job); }
public virtual void TestTasksBlock() { ApplicationId appId = ApplicationIdPBImpl.NewInstance(0, 1); JobId jobId = new JobIdPBImpl(); jobId.SetId(0); jobId.SetAppId(appId); TaskId taskId = new TaskIdPBImpl(); taskId.SetId(0); taskId.SetTaskType(TaskType.Map); taskId.SetJobId(jobId); Task task = Org.Mockito.Mockito.Mock <Task>(); Org.Mockito.Mockito.When(task.GetID()).ThenReturn(taskId); TaskReport report = Org.Mockito.Mockito.Mock <TaskReport>(); Org.Mockito.Mockito.When(report.GetProgress()).ThenReturn(0.7f); Org.Mockito.Mockito.When(report.GetTaskState()).ThenReturn(TaskState.Succeeded); Org.Mockito.Mockito.When(report.GetStartTime()).ThenReturn(100001L); Org.Mockito.Mockito.When(report.GetFinishTime()).ThenReturn(100011L); Org.Mockito.Mockito.When(report.GetStatus()).ThenReturn("Dummy Status \n*"); Org.Mockito.Mockito.When(task.GetReport()).ThenReturn(report); Org.Mockito.Mockito.When(task.GetType()).ThenReturn(TaskType.Map); IDictionary <TaskId, Task> tasks = new Dictionary <TaskId, Task>(); tasks[taskId] = task; AppContext ctx = Org.Mockito.Mockito.Mock <AppContext>(); Org.Apache.Hadoop.Mapreduce.V2.App.Job.Job job = Org.Mockito.Mockito.Mock <Org.Apache.Hadoop.Mapreduce.V2.App.Job.Job >(); Org.Mockito.Mockito.When(job.GetTasks()).ThenReturn(tasks); Org.Apache.Hadoop.Mapreduce.V2.App.Webapp.App app = new Org.Apache.Hadoop.Mapreduce.V2.App.Webapp.App (ctx); app.SetJob(job); TasksBlockForTest taskBlock = new TasksBlockForTest(app); taskBlock.AddParameter(AMParams.TaskType, "m"); PrintWriter pWriter = new PrintWriter(data); HtmlBlock.Block html = new BlockForTest(new TestBlocks.HtmlBlockForTest(this), pWriter , 0, false); taskBlock.Render(html); pWriter.Flush(); NUnit.Framework.Assert.IsTrue(data.ToString().Contains("task_0_0001_m_000000")); NUnit.Framework.Assert.IsTrue(data.ToString().Contains("70.00")); NUnit.Framework.Assert.IsTrue(data.ToString().Contains("SUCCEEDED")); NUnit.Framework.Assert.IsTrue(data.ToString().Contains("100001")); NUnit.Framework.Assert.IsTrue(data.ToString().Contains("100011")); NUnit.Framework.Assert.IsFalse(data.ToString().Contains("Dummy Status \n*")); NUnit.Framework.Assert.IsTrue(data.ToString().Contains("Dummy Status \\n*")); }
/// <summary>Simple test PartialJob</summary> /// <exception cref="System.Exception"/> public virtual void TestPartialJob() { JobId jobId = new JobIdPBImpl(); jobId.SetId(0); JobIndexInfo jii = new JobIndexInfo(0L, Runtime.CurrentTimeMillis(), "user", "jobName" , jobId, 3, 2, "JobStatus"); PartialJob test = new PartialJob(jii, jobId); NUnit.Framework.Assert.AreEqual(1.0f, test.GetProgress(), 0.001); NUnit.Framework.Assert.IsNull(test.GetAllCounters()); NUnit.Framework.Assert.IsNull(test.GetTasks()); NUnit.Framework.Assert.IsNull(test.GetTasks(TaskType.Map)); NUnit.Framework.Assert.IsNull(test.GetTask(new TaskIdPBImpl())); NUnit.Framework.Assert.IsNull(test.GetTaskAttemptCompletionEvents(0, 100)); NUnit.Framework.Assert.IsNull(test.GetMapAttemptCompletionEvents(0, 100)); NUnit.Framework.Assert.IsTrue(test.CheckAccess(UserGroupInformation.GetCurrentUser (), null)); NUnit.Framework.Assert.IsNull(test.GetAMInfos()); }
private Task GetTask(long timestamp) { JobId jobId = new JobIdPBImpl(); jobId.SetId(0); jobId.SetAppId(ApplicationIdPBImpl.NewInstance(timestamp, 1)); TaskId taskId = new TaskIdPBImpl(); taskId.SetId(0); taskId.SetTaskType(TaskType.Reduce); taskId.SetJobId(jobId); Task task = Org.Mockito.Mockito.Mock <Task>(); Org.Mockito.Mockito.When(task.GetID()).ThenReturn(taskId); TaskReport report = Org.Mockito.Mockito.Mock <TaskReport>(); Org.Mockito.Mockito.When(report.GetProgress()).ThenReturn(0.7f); Org.Mockito.Mockito.When(report.GetTaskState()).ThenReturn(TaskState.Succeeded); Org.Mockito.Mockito.When(report.GetStartTime()).ThenReturn(100001L); Org.Mockito.Mockito.When(report.GetFinishTime()).ThenReturn(100011L); Org.Mockito.Mockito.When(task.GetReport()).ThenReturn(report); Org.Mockito.Mockito.When(task.GetType()).ThenReturn(TaskType.Reduce); return(task); }