Beispiel #1
0
        public virtual void TestLogsViewSingle()
        {
            Log.Info("HsLogsPage with params for single log and data limits");
            MockAppContext ctx = new MockAppContext(0, 1, 1, 1);
            IDictionary <string, string> @params = new Dictionary <string, string>();
            Configuration conf = new YarnConfiguration();

            conf.SetBoolean(YarnConfiguration.LogAggregationEnabled, true);
            @params["start"] = "-2048";
            @params["end"]   = "-1024";
            @params[YarnWebParams.ContainerLogType] = "syslog";
            @params[YarnWebParams.ContainerId]      = MRApp.NewContainerId(1, 1, 333, 1).ToString(
                );
            @params[YarnWebParams.NmNodename] = NodeId.NewInstance(MockJobs.NmHost, MockJobs.
                                                                   NmPort).ToString();
            @params[YarnWebParams.EntityString] = "container_10_0001_01_000001";
            @params[YarnWebParams.AppOwner]     = "owner";
            Injector injector = WebAppTests.TestPage <AppContext>(typeof(AggregatedLogsPage),
                                                                  ctx, @params, new _AbstractModule_201(conf));
            PrintWriter spyPw = WebAppTests.GetPrintWriter(injector);

            Org.Mockito.Mockito.Verify(spyPw).Write("Logs not available for container_10_0001_01_000001."
                                                    + " Aggregation may not be complete, " + "Check back later or try the nodemanager at "
                                                    + MockJobs.NmHost + ":" + MockJobs.NmPort);
        }
Beispiel #2
0
        public virtual void TestTasksView()
        {
            AppContext appContext = new MockAppContext(0, 1, 1, 1);
            IDictionary <string, string> @params = GetTaskParams(appContext);

            WebAppTests.TestPage <AppContext>(typeof(TasksPage), appContext, @params);
        }
Beispiel #3
0
        public virtual void TestJobCounterViewForKilledJob()
        {
            Log.Info("JobCounterViewForKilledJob");
            AppContext appContext = new MockAppContext(0, 1, 1, 1, true);
            IDictionary <string, string> @params = TestAMWebApp.GetJobParams(appContext);

            WebAppTests.TestPage <AppContext>(typeof(HsCountersPage), appContext, @params);
        }
Beispiel #4
0
        public virtual void TestAttemptsView()
        {
            Log.Info("HsAttemptsPage");
            AppContext appContext = new MockAppContext(0, 1, 1, 1);
            IDictionary <string, string> @params = TestAMWebApp.GetTaskParams(appContext);

            WebAppTests.TestPage <AppContext>(typeof(HsAttemptsPage), appContext, @params);
        }
Beispiel #5
0
        public virtual void TestTaskView()
        {
            AppContext appContext = new MockAppContext(0, 1, 1, 1);
            IDictionary <string, string> @params = GetTaskParams(appContext);

            Org.Apache.Hadoop.Mapreduce.V2.App.Webapp.App app = new Org.Apache.Hadoop.Mapreduce.V2.App.Webapp.App
                                                                    (appContext);
            app.SetJob(appContext.GetAllJobs().Values.GetEnumerator().Next());
            app.SetTask(app.GetJob().GetTasks().Values.GetEnumerator().Next());
            WebAppTests.TestPage <Org.Apache.Hadoop.Mapreduce.V2.App.Webapp.App>(typeof(TaskPage
                                                                                        ), app, @params);
        }
Beispiel #6
0
        public virtual void TestAttemptsWithJobView()
        {
            Log.Info("HsAttemptsPage with data");
            MockAppContext ctx = new MockAppContext(0, 1, 1, 1);
            JobId          id  = ctx.GetAllJobs().Keys.GetEnumerator().Next();
            IDictionary <string, string> @params = new Dictionary <string, string>();

            @params[AMParams.JobId]        = id.ToString();
            @params[AMParams.TaskType]     = "m";
            @params[AMParams.AttemptState] = "SUCCESSFUL";
            WebAppTests.TestPage <AppContext>(typeof(HsAttemptsPage), ctx, @params);
        }
Beispiel #7
0
        public virtual void TestLogsView1()
        {
            Log.Info("HsLogsPage");
            Injector injector = WebAppTests.TestPage <AppContext>(typeof(AggregatedLogsPage),
                                                                  new MockAppContext(0, 1, 1, 1));
            PrintWriter spyPw = WebAppTests.GetPrintWriter(injector);

            Org.Mockito.Mockito.Verify(spyPw).Write("Cannot get container logs without a ContainerId"
                                                    );
            Org.Mockito.Mockito.Verify(spyPw).Write("Cannot get container logs without a NodeId"
                                                    );
            Org.Mockito.Mockito.Verify(spyPw).Write("Cannot get container logs without an app owner"
                                                    );
        }
Beispiel #8
0
        public virtual void TestUsual()
        {
            Injector    injector = WebAppTests.TestPage(typeof(TestHtmlPage.TestView));
            PrintWriter @out     = injector.GetInstance <PrintWriter>();

            // Verify the HTML page has correct meta tags in the header
            Org.Mockito.Mockito.Verify(@out).Write(" http-equiv=\"X-UA-Compatible\"");
            Org.Mockito.Mockito.Verify(@out).Write(" content=\"IE=8\"");
            Org.Mockito.Mockito.Verify(@out).Write(" http-equiv=\"Content-type\"");
            Org.Mockito.Mockito.Verify(@out).Write(string.Format(" content=\"%s\"", MimeType.
                                                                 Html));
            Org.Mockito.Mockito.Verify(@out).Write("test");
            Org.Mockito.Mockito.Verify(@out).Write(" id=\"testid\"");
            Org.Mockito.Mockito.Verify(@out).Write("test note");
        }
Beispiel #9
0
        public virtual void TestSingleCounterView()
        {
            AppContext appContext = new MockAppContext(0, 1, 1, 1);

            Org.Apache.Hadoop.Mapreduce.V2.App.Job.Job job = appContext.GetAllJobs().Values.GetEnumerator
                                                                 ().Next();
            // add a failed task to the job without any counters
            Task failedTask = MockJobs.NewTask(job.GetID(), 2, 1, true);
            IDictionary <TaskId, Task> tasks = job.GetTasks();

            tasks[failedTask.GetID()] = failedTask;
            IDictionary <string, string> @params = GetJobParams(appContext);

            @params[AMParams.CounterGroup] = "org.apache.hadoop.mapreduce.FileSystemCounter";
            @params[AMParams.CounterName]  = "HDFS_WRITE_OPS";
            WebAppTests.TestPage <AppContext>(typeof(SingleCounterPage), appContext, @params);
        }
Beispiel #10
0
        public virtual void TestSingleTaskCounterView()
        {
            AppContext appContext = new MockAppContext(0, 1, 1, 2);
            IDictionary <string, string> @params = GetTaskParams(appContext);

            @params[AMParams.CounterGroup] = "org.apache.hadoop.mapreduce.FileSystemCounter";
            @params[AMParams.CounterName]  = "HDFS_WRITE_OPS";
            // remove counters from one task attempt
            // to test handling of missing counters
            TaskId taskID = MRApps.ToTaskID(@params[AMParams.TaskId]);

            Org.Apache.Hadoop.Mapreduce.V2.App.Job.Job job = appContext.GetJob(taskID.GetJobId
                                                                                   ());
            Task        task    = job.GetTask(taskID);
            TaskAttempt attempt = task.GetAttempts().Values.GetEnumerator().Next();

            attempt.GetReport().SetCounters(null);
            WebAppTests.TestPage <AppContext>(typeof(SingleCounterPage), appContext, @params);
        }
Beispiel #11
0
        public virtual void TestLogsView2()
        {
            Log.Info("HsLogsPage with data");
            MockAppContext ctx = new MockAppContext(0, 1, 1, 1);
            IDictionary <string, string> @params = new Dictionary <string, string>();

            @params[YarnWebParams.ContainerId] = MRApp.NewContainerId(1, 1, 333, 1).ToString(
                );
            @params[YarnWebParams.NmNodename] = NodeId.NewInstance(MockJobs.NmHost, MockJobs.
                                                                   NmPort).ToString();
            @params[YarnWebParams.EntityString] = "container_10_0001_01_000001";
            @params[YarnWebParams.AppOwner]     = "owner";
            Injector injector = WebAppTests.TestPage <AppContext>(typeof(AggregatedLogsPage),
                                                                  ctx, @params);
            PrintWriter spyPw = WebAppTests.GetPrintWriter(injector);

            Org.Mockito.Mockito.Verify(spyPw).Write("Aggregation is not enabled. Try the nodemanager at "
                                                    + MockJobs.NmHost + ":" + MockJobs.NmPort);
        }
Beispiel #12
0
        public virtual void TestLogsViewBadStartEnd()
        {
            Log.Info("HsLogsPage with bad start/end params");
            MockAppContext ctx = new MockAppContext(0, 1, 1, 1);
            IDictionary <string, string> @params = new Dictionary <string, string>();

            @params["start"] = "foo";
            @params["end"]   = "bar";
            @params[YarnWebParams.ContainerId] = MRApp.NewContainerId(1, 1, 333, 1).ToString(
                );
            @params[YarnWebParams.NmNodename] = NodeId.NewInstance(MockJobs.NmHost, MockJobs.
                                                                   NmPort).ToString();
            @params[YarnWebParams.EntityString] = "container_10_0001_01_000001";
            @params[YarnWebParams.AppOwner]     = "owner";
            Injector injector = WebAppTests.TestPage <AppContext>(typeof(AggregatedLogsPage),
                                                                  ctx, @params);
            PrintWriter spyPw = WebAppTests.GetPrintWriter(injector);

            Org.Mockito.Mockito.Verify(spyPw).Write("Invalid log start value: foo");
            Org.Mockito.Mockito.Verify(spyPw).Write("Invalid log end value: bar");
        }
Beispiel #13
0
 public virtual void TestShortPage()
 {
     WebAppTests.TestPage(typeof(TestHtmlBlock.ShortPage));
 }
Beispiel #14
0
 public virtual void TestErrorPage()
 {
     Injector injector = WebAppTests.TestPage(typeof(ErrorPage));
 }
Beispiel #15
0
 public virtual void TestAppView()
 {
     WebAppTests.TestPage <AppContext>(typeof(AppView), new MockAppContext(0, 1, 1, 1));
 }
Beispiel #16
0
 public virtual void TestConfView()
 {
     WebAppTests.TestPage <AppContext>(typeof(JobConfPage), new MockAppContext(0, 1, 1,
                                                                               1));
 }
Beispiel #17
0
 public virtual void TestShort()
 {
     WebAppTests.TestPage(typeof(TestHtmlPage.ShortView));
 }
Beispiel #18
0
 public virtual void ShouldNotThrow()
 {
     WebAppTests.TestPage(typeof(TwoColumnCssLayout));
 }
Beispiel #19
0
 public virtual void TestAboutView()
 {
     Log.Info("HsAboutPage");
     WebAppTests.TestPage <AppContext>(typeof(HsAboutPage), new MockAppContext(0, 1, 1,
                                                                               1));
 }
        /// <exception cref="System.IO.IOException"/>
        public virtual void TestContainerLogPageAccess()
        {
            // SecureIOUtils require Native IO to be enabled. This test will run
            // only if it is enabled.
            Assume.AssumeTrue(NativeIO.IsAvailable());
            string   user         = "******" + Runtime.CurrentTimeMillis();
            FilePath absLogDir    = null;
            FilePath appDir       = null;
            FilePath containerDir = null;
            FilePath syslog       = null;

            try
            {
                // target log directory
                absLogDir = new FilePath("target", typeof(TestContainerLogsPage).Name + "LogDir")
                            .GetAbsoluteFile();
                absLogDir.Mkdir();
                Configuration conf = new Configuration();
                conf.Set(YarnConfiguration.NmLogDirs, absLogDir.ToURI().ToString());
                conf.Set(CommonConfigurationKeysPublic.HadoopSecurityAuthentication, "kerberos");
                UserGroupInformation.SetConfiguration(conf);
                NodeHealthCheckerService healthChecker = new NodeHealthCheckerService();
                healthChecker.Init(conf);
                LocalDirsHandlerService dirsHandler = healthChecker.GetDiskHandler();
                // Add an application and the corresponding containers
                RecordFactory recordFactory    = RecordFactoryProvider.GetRecordFactory(conf);
                long          clusterTimeStamp = 1234;
                ApplicationId appId            = BuilderUtils.NewApplicationId(recordFactory, clusterTimeStamp
                                                                               , 1);
                Org.Apache.Hadoop.Yarn.Server.Nodemanager.Containermanager.Application.Application
                    app = Org.Mockito.Mockito.Mock <Org.Apache.Hadoop.Yarn.Server.Nodemanager.Containermanager.Application.Application
                                                    >();
                Org.Mockito.Mockito.When(app.GetAppId()).ThenReturn(appId);
                // Making sure that application returns a random user. This is required
                // for SecureIOUtils' file owner check.
                Org.Mockito.Mockito.When(app.GetUser()).ThenReturn(user);
                ApplicationAttemptId appAttemptId = BuilderUtils.NewApplicationAttemptId(appId, 1
                                                                                         );
                ContainerId container1 = BuilderUtils.NewContainerId(recordFactory, appId, appAttemptId
                                                                     , 0);
                // Testing secure read access for log files
                // Creating application and container directory and syslog file.
                appDir = new FilePath(absLogDir, appId.ToString());
                appDir.Mkdir();
                containerDir = new FilePath(appDir, container1.ToString());
                containerDir.Mkdir();
                syslog = new FilePath(containerDir, "syslog");
                syslog.CreateNewFile();
                BufferedOutputStream @out = new BufferedOutputStream(new FileOutputStream(syslog)
                                                                     );
                @out.Write(Sharpen.Runtime.GetBytesForString("Log file Content"));
                @out.Close();
                Context context = Org.Mockito.Mockito.Mock <Context>();
                ConcurrentMap <ApplicationId, Org.Apache.Hadoop.Yarn.Server.Nodemanager.Containermanager.Application.Application
                               > appMap = new ConcurrentHashMap <ApplicationId, Org.Apache.Hadoop.Yarn.Server.Nodemanager.Containermanager.Application.Application
                                                                 >();
                appMap[appId] = app;
                Org.Mockito.Mockito.When(context.GetApplications()).ThenReturn(appMap);
                ConcurrentHashMap <ContainerId, Org.Apache.Hadoop.Yarn.Server.Nodemanager.Containermanager.Container.Container
                                   > containers = new ConcurrentHashMap <ContainerId, Org.Apache.Hadoop.Yarn.Server.Nodemanager.Containermanager.Container.Container
                                                                         >();
                Org.Mockito.Mockito.When(context.GetContainers()).ThenReturn(containers);
                Org.Mockito.Mockito.When(context.GetLocalDirsHandler()).ThenReturn(dirsHandler);
                MockContainer container = new MockContainer(appAttemptId, new AsyncDispatcher(),
                                                            conf, user, appId, 1);
                container.SetState(ContainerState.Running);
                context.GetContainers()[container1] = container;
                ContainerLogsPage.ContainersLogsBlock cLogsBlock = new ContainerLogsPage.ContainersLogsBlock
                                                                       (context);
                IDictionary <string, string> @params = new Dictionary <string, string>();
                @params[YarnWebParams.ContainerId]      = container1.ToString();
                @params[YarnWebParams.ContainerLogType] = "syslog";
                Injector injector = WebAppTests.TestPage <ContainerLogsPage.ContainersLogsBlock>(typeof(
                                                                                                     ContainerLogsPage), cLogsBlock, @params, (Module[])null);
                PrintWriter spyPw = WebAppTests.GetPrintWriter(injector);
                Org.Mockito.Mockito.Verify(spyPw).Write("Exception reading log file. Application submitted by '"
                                                        + user + "' doesn't own requested log file : syslog");
            }
            finally
            {
                if (syslog != null)
                {
                    syslog.Delete();
                }
                if (containerDir != null)
                {
                    containerDir.Delete();
                }
                if (appDir != null)
                {
                    appDir.Delete();
                }
                if (absLogDir != null)
                {
                    absLogDir.Delete();
                }
            }
        }
Beispiel #21
0
 public virtual void TestSingleCounterView()
 {
     Log.Info("HsSingleCounterPage");
     WebAppTests.TestPage <AppContext>(typeof(HsSingleCounterPage), new MockAppContext(
                                           0, 1, 1, 1));
 }