//test launch method with -D arguments
        /// <exception cref="System.Exception"/>
        public virtual void TestLaunchWithArguments()
        {
            ExitUtil.DisableSystemExit();
            ApplicationHistoryServer historyServer = null;

            try
            {
                // Not able to modify the config of this test case,
                // but others have been customized to avoid conflicts
                string[] args = new string[2];
                args[0]       = "-D" + YarnConfiguration.TimelineServiceLeveldbTtlIntervalMs + "=4000";
                args[1]       = "-D" + YarnConfiguration.TimelineServiceTtlMs + "=200";
                historyServer = ApplicationHistoryServer.LaunchAppHistoryServer(args);
                Configuration conf = historyServer.GetConfig();
                NUnit.Framework.Assert.AreEqual("4000", conf.Get(YarnConfiguration.TimelineServiceLeveldbTtlIntervalMs
                                                                 ));
                NUnit.Framework.Assert.AreEqual("200", conf.Get(YarnConfiguration.TimelineServiceTtlMs
                                                                ));
            }
            catch (ExitUtil.ExitException e)
            {
                NUnit.Framework.Assert.AreEqual(0, e.status);
                ExitUtil.ResetFirstExitException();
                NUnit.Framework.Assert.Fail();
            }
            finally
            {
                if (historyServer != null)
                {
                    historyServer.Stop();
                }
            }
        }
        // test launch method
        /// <exception cref="System.Exception"/>
        public virtual void TestLaunch()
        {
            ExitUtil.DisableSystemExit();
            ApplicationHistoryServer historyServer = null;

            try
            {
                // Not able to modify the config of this test case,
                // but others have been customized to avoid conflicts
                historyServer = ApplicationHistoryServer.LaunchAppHistoryServer(new string[0]);
            }
            catch (ExitUtil.ExitException e)
            {
                NUnit.Framework.Assert.AreEqual(0, e.status);
                ExitUtil.ResetFirstExitException();
                NUnit.Framework.Assert.Fail();
            }
            finally
            {
                if (historyServer != null)
                {
                    historyServer.Stop();
                }
            }
        }
Ejemplo n.º 3
0
        public virtual void Setup()
        {
            Logger rootLogger = LogManager.GetRootLogger();

            rootLogger.SetLevel(Level.Debug);
            ExitUtil.DisableSystemExit();
            conf = new YarnConfiguration();
            UserGroupInformation.SetConfiguration(conf);
            conf.Set(YarnConfiguration.RmStore, typeof(MemoryRMStateStore).FullName);
            conf.Set(YarnConfiguration.RmScheduler, typeof(FairScheduler).FullName);
        }
Ejemplo n.º 4
0
 // test launch method
 /// <exception cref="System.Exception"/>
 public virtual void TestLaunch()
 {
     ExitUtil.DisableSystemExit();
     try
     {
         historyServer = JobHistoryServer.LaunchJobHistoryServer(new string[0]);
     }
     catch (ExitUtil.ExitException e)
     {
         NUnit.Framework.Assert.AreEqual(0, e.status);
         ExitUtil.ResetFirstExitException();
         NUnit.Framework.Assert.Fail();
     }
 }
Ejemplo n.º 5
0
        public virtual void TestUncaughtExceptionHandlerWithError()
        {
            ExitUtil.DisableSystemExit();
            YarnUncaughtExceptionHandler spyErrorHandler = Org.Mockito.Mockito.Spy(exHandler);
            Error error = new Error("test-error");

            Sharpen.Thread errorThread = new Sharpen.Thread(new _Runnable_75(error));
            errorThread.SetUncaughtExceptionHandler(spyErrorHandler);
            NUnit.Framework.Assert.AreSame(spyErrorHandler, errorThread.GetUncaughtExceptionHandler
                                               ());
            errorThread.Start();
            errorThread.Join();
            Org.Mockito.Mockito.Verify(spyErrorHandler).UncaughtException(errorThread, error);
        }
Ejemplo n.º 6
0
        public virtual void SetUp()
        {
            ExitUtil.DisableSystemExit();
            string baseDir = PathUtils.GetTestDirName(GetType());

            hdfsDir = new FilePath(baseDir, "dfs/name");
            if (hdfsDir.Exists() && !FileUtil.FullyDelete(hdfsDir))
            {
                throw new IOException("Could not delete test directory '" + hdfsDir + "'");
            }
            Log.Info("hdfsdir is " + hdfsDir.GetAbsolutePath());
            // as some tests might change these values we reset them to defaults before
            // every test
            HdfsServerConstants.StartupOption.Format.SetForceFormat(false);
            HdfsServerConstants.StartupOption.Format.SetInteractiveFormat(true);
            config = new Configuration();
            config.Set(DFSConfigKeys.DfsNamenodeNameDirKey, hdfsDir.GetPath());
        }
Ejemplo n.º 7
0
        /// <summary>test start form console command without options</summary>
        private void StartStop()
        {
            ByteArrayOutputStream data  = new ByteArrayOutputStream();
            TextWriter            error = System.Console.Error;

            Runtime.SetErr(new TextWriter(data));
            ExitUtil.DisableSystemExit();
            try
            {
                CLI.Main(new string[0]);
                Fail(" CLI.main should call System.exit");
            }
            catch (ExitUtil.ExitException e)
            {
                ExitUtil.ResetFirstExitException();
                NUnit.Framework.Assert.AreEqual(-1, e.status);
            }
            catch (Exception)
            {
            }
            finally
            {
                Runtime.SetErr(error);
            }
            // in console should be written help text
            string s = Sharpen.Runtime.GetStringForBytes(data.ToByteArray());

            NUnit.Framework.Assert.IsTrue(s.Contains("-submit"));
            NUnit.Framework.Assert.IsTrue(s.Contains("-status"));
            NUnit.Framework.Assert.IsTrue(s.Contains("-kill"));
            NUnit.Framework.Assert.IsTrue(s.Contains("-set-priority"));
            NUnit.Framework.Assert.IsTrue(s.Contains("-events"));
            NUnit.Framework.Assert.IsTrue(s.Contains("-history"));
            NUnit.Framework.Assert.IsTrue(s.Contains("-list"));
            NUnit.Framework.Assert.IsTrue(s.Contains("-list-active-trackers"));
            NUnit.Framework.Assert.IsTrue(s.Contains("-list-blacklisted-trackers"));
            NUnit.Framework.Assert.IsTrue(s.Contains("-list-attempt-ids"));
            NUnit.Framework.Assert.IsTrue(s.Contains("-kill-task"));
            NUnit.Framework.Assert.IsTrue(s.Contains("-fail-task"));
            NUnit.Framework.Assert.IsTrue(s.Contains("-logs"));
        }
Ejemplo n.º 8
0
        public virtual void TestSubmitter()
        {
            JobConf conf = new JobConf();

            FilePath[] psw = CleanTokenPasswordFile();
            Runtime.SetProperty("test.build.data", "target/tmp/build/TEST_SUBMITTER_MAPPER/data"
                                );
            conf.Set("hadoop.log.dir", "target/tmp");
            // prepare configuration
            Submitter.SetIsJavaMapper(conf, false);
            Submitter.SetIsJavaReducer(conf, false);
            Submitter.SetKeepCommandFile(conf, false);
            Submitter.SetIsJavaRecordReader(conf, false);
            Submitter.SetIsJavaRecordWriter(conf, false);
            PipesPartitioner <IntWritable, Text> partitioner = new PipesPartitioner <IntWritable
                                                                                     , Text>();

            partitioner.Configure(conf);
            Submitter.SetJavaPartitioner(conf, partitioner.GetType());
            NUnit.Framework.Assert.AreEqual(typeof(PipesPartitioner), (Submitter.GetJavaPartitioner
                                                                           (conf)));
            // test going to call main method with System.exit(). Change Security
            SecurityManager securityManager = Runtime.GetSecurityManager();
            // store System.out
            TextWriter            oldps = System.Console.Out;
            ByteArrayOutputStream @out  = new ByteArrayOutputStream();

            ExitUtil.DisableSystemExit();
            // test without parameters
            try
            {
                Runtime.SetOut(new TextWriter(@out));
                Submitter.Main(new string[0]);
                NUnit.Framework.Assert.Fail();
            }
            catch (ExitUtil.ExitException)
            {
                // System.exit prohibited! output message test
                NUnit.Framework.Assert.IsTrue(@out.ToString().Contains(string.Empty));
                NUnit.Framework.Assert.IsTrue(@out.ToString().Contains("bin/hadoop pipes"));
                NUnit.Framework.Assert.IsTrue(@out.ToString().Contains("[-input <path>] // Input directory"
                                                                       ));
                NUnit.Framework.Assert.IsTrue(@out.ToString().Contains("[-output <path>] // Output directory"
                                                                       ));
                NUnit.Framework.Assert.IsTrue(@out.ToString().Contains("[-jar <jar file> // jar filename"
                                                                       ));
                NUnit.Framework.Assert.IsTrue(@out.ToString().Contains("[-inputformat <class>] // InputFormat class"
                                                                       ));
                NUnit.Framework.Assert.IsTrue(@out.ToString().Contains("[-map <class>] // Java Map class"
                                                                       ));
                NUnit.Framework.Assert.IsTrue(@out.ToString().Contains("[-partitioner <class>] // Java Partitioner"
                                                                       ));
                NUnit.Framework.Assert.IsTrue(@out.ToString().Contains("[-reduce <class>] // Java Reduce class"
                                                                       ));
                NUnit.Framework.Assert.IsTrue(@out.ToString().Contains("[-writer <class>] // Java RecordWriter"
                                                                       ));
                NUnit.Framework.Assert.IsTrue(@out.ToString().Contains("[-program <executable>] // executable URI"
                                                                       ));
                NUnit.Framework.Assert.IsTrue(@out.ToString().Contains("[-reduces <num>] // number of reduces"
                                                                       ));
                NUnit.Framework.Assert.IsTrue(@out.ToString().Contains("[-lazyOutput <true/false>] // createOutputLazily"
                                                                       ));
                NUnit.Framework.Assert.IsTrue(@out.ToString().Contains("-conf <configuration file>     specify an application configuration file"
                                                                       ));
                NUnit.Framework.Assert.IsTrue(@out.ToString().Contains("-D <property=value>            use value for given property"
                                                                       ));
                NUnit.Framework.Assert.IsTrue(@out.ToString().Contains("-fs <local|namenode:port>      specify a namenode"
                                                                       ));
                NUnit.Framework.Assert.IsTrue(@out.ToString().Contains("-jt <local|resourcemanager:port>    specify a ResourceManager"
                                                                       ));
                NUnit.Framework.Assert.IsTrue(@out.ToString().Contains("-files <comma separated list of files>    specify comma separated files to be copied to the map reduce cluster"
                                                                       ));
                NUnit.Framework.Assert.IsTrue(@out.ToString().Contains("-libjars <comma separated list of jars>    specify comma separated jar files to include in the classpath."
                                                                       ));
                NUnit.Framework.Assert.IsTrue(@out.ToString().Contains("-archives <comma separated list of archives>    specify comma separated archives to be unarchived on the compute machines."
                                                                       ));
            }
            finally
            {
                Runtime.SetOut(oldps);
                // restore
                Runtime.SetSecurityManager(securityManager);
                if (psw != null)
                {
                    // remove password files
                    foreach (FilePath file in psw)
                    {
                        file.DeleteOnExit();
                    }
                }
            }
            // test call Submitter form command line
            try
            {
                FilePath fCommand = GetFileCommand(null);
                string[] args     = new string[22];
                FilePath input    = new FilePath(workSpace + FilePath.separator + "input");
                if (!input.Exists())
                {
                    NUnit.Framework.Assert.IsTrue(input.CreateNewFile());
                }
                FilePath outPut = new FilePath(workSpace + FilePath.separator + "output");
                FileUtil.FullyDelete(outPut);
                args[0] = "-input";
                args[1] = input.GetAbsolutePath();
                // "input";
                args[2] = "-output";
                args[3] = outPut.GetAbsolutePath();
                // "output";
                args[4]  = "-inputformat";
                args[5]  = "org.apache.hadoop.mapred.TextInputFormat";
                args[6]  = "-map";
                args[7]  = "org.apache.hadoop.mapred.lib.IdentityMapper";
                args[8]  = "-partitioner";
                args[9]  = "org.apache.hadoop.mapred.pipes.PipesPartitioner";
                args[10] = "-reduce";
                args[11] = "org.apache.hadoop.mapred.lib.IdentityReducer";
                args[12] = "-writer";
                args[13] = "org.apache.hadoop.mapred.TextOutputFormat";
                args[14] = "-program";
                args[15] = fCommand.GetAbsolutePath();
                // "program";
                args[16] = "-reduces";
                args[17] = "2";
                args[18] = "-lazyOutput";
                args[19] = "lazyOutput";
                args[20] = "-jobconf";
                args[21] = "mapreduce.pipes.isjavarecordwriter=false,mapreduce.pipes.isjavarecordreader=false";
                Submitter.Main(args);
                NUnit.Framework.Assert.Fail();
            }
            catch (ExitUtil.ExitException e)
            {
                // status should be 0
                NUnit.Framework.Assert.AreEqual(e.status, 0);
            }
            finally
            {
                Runtime.SetOut(oldps);
                Runtime.SetSecurityManager(securityManager);
            }
        }
Ejemplo n.º 9
0
 public static void Before()
 {
     ExitUtil.DisableSystemExit();
     Options[1] = InvalidOption;
 }