示例#1
0
        public virtual void TestPrintJobQueueInfo()
        {
            JobQueueClient queueClient = new JobQueueClient();
            JobQueueInfo   parent      = new JobQueueInfo();
            JobQueueInfo   child       = new JobQueueInfo();
            JobQueueInfo   grandChild  = new JobQueueInfo();

            child.AddChild(grandChild);
            parent.AddChild(child);
            grandChild.SetQueueName("GrandChildQueue");
            ByteArrayOutputStream bbos   = new ByteArrayOutputStream();
            PrintWriter           writer = new PrintWriter(bbos);

            queueClient.PrintJobQueueInfo(parent, writer);
            NUnit.Framework.Assert.IsTrue("printJobQueueInfo did not print grandchild's name"
                                          , bbos.ToString().Contains("GrandChildQueue"));
        }
示例#2
0
        /// <summary>test run from command line JobQueueClient</summary>
        /// <exception cref="System.Exception"/>
        public virtual void TestJobQueueClient()
        {
            MiniMRClientCluster mr      = null;
            FileSystem          fileSys = null;
            TextWriter          oldOut  = System.Console.Out;

            try
            {
                mr = CreateMiniClusterWithCapacityScheduler();
                JobConf job = new JobConf(mr.GetConfig());
                fileSys = FileSystem.Get(job);
                fileSys.Delete(testDir, true);
                FSDataOutputStream @out = fileSys.Create(inFile, true);
                @out.WriteBytes("This is a test file");
                @out.Close();
                FileInputFormat.SetInputPaths(job, inFile);
                FileOutputFormat.SetOutputPath(job, outDir);
                job.SetInputFormat(typeof(TextInputFormat));
                job.SetOutputFormat(typeof(TextOutputFormat));
                job.SetMapperClass(typeof(IdentityMapper));
                job.SetReducerClass(typeof(IdentityReducer));
                job.SetNumReduceTasks(0);
                JobClient client = new JobClient(mr.GetConfig());
                client.SubmitJob(job);
                JobQueueClient        jobClient = new JobQueueClient(job);
                ByteArrayOutputStream bytes     = new ByteArrayOutputStream();
                Runtime.SetOut(new TextWriter(bytes));
                string[] arg = new string[] { "-list" };
                jobClient.Run(arg);
                NUnit.Framework.Assert.IsTrue(bytes.ToString().Contains("Queue Name : default"));
                NUnit.Framework.Assert.IsTrue(bytes.ToString().Contains("Queue State : running"));
                bytes = new ByteArrayOutputStream();
                Runtime.SetOut(new TextWriter(bytes));
                string[] arg1 = new string[] { "-showacls" };
                jobClient.Run(arg1);
                NUnit.Framework.Assert.IsTrue(bytes.ToString().Contains("Queue acls for user :"******"root  ADMINISTER_QUEUE,SUBMIT_APPLICATIONS"
                                                                        ));
                NUnit.Framework.Assert.IsTrue(bytes.ToString().Contains("default  ADMINISTER_QUEUE,SUBMIT_APPLICATIONS"
                                                                        ));
                // test for info and default queue
                bytes = new ByteArrayOutputStream();
                Runtime.SetOut(new TextWriter(bytes));
                string[] arg2 = new string[] { "-info", "default" };
                jobClient.Run(arg2);
                NUnit.Framework.Assert.IsTrue(bytes.ToString().Contains("Queue Name : default"));
                NUnit.Framework.Assert.IsTrue(bytes.ToString().Contains("Queue State : running"));
                NUnit.Framework.Assert.IsTrue(bytes.ToString().Contains("Scheduling Info"));
                // test for info , default queue and jobs
                bytes = new ByteArrayOutputStream();
                Runtime.SetOut(new TextWriter(bytes));
                string[] arg3 = new string[] { "-info", "default", "-showJobs" };
                jobClient.Run(arg3);
                NUnit.Framework.Assert.IsTrue(bytes.ToString().Contains("Queue Name : default"));
                NUnit.Framework.Assert.IsTrue(bytes.ToString().Contains("Queue State : running"));
                NUnit.Framework.Assert.IsTrue(bytes.ToString().Contains("Scheduling Info"));
                NUnit.Framework.Assert.IsTrue(bytes.ToString().Contains("job_1"));
                string[] arg4 = new string[] {  };
                jobClient.Run(arg4);
            }
            finally
            {
                Runtime.SetOut(oldOut);
                if (fileSys != null)
                {
                    fileSys.Delete(testDir, true);
                }
                if (mr != null)
                {
                    mr.Stop();
                }
            }
        }