Ejemplo n.º 1
0
        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*"));
        }
Ejemplo n.º 2
0
        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);
        }