Esempio n. 1
0
        /// <summary>test TaskAttemptID</summary>
        /// <exception cref="System.IO.IOException"/>
        public virtual void TestTaskLog()
        {
            // test TaskLog
            Runtime.SetProperty(YarnConfiguration.YarnAppContainerLogDir, "testString");
            NUnit.Framework.Assert.AreEqual(TaskLog.GetMRv2LogDir(), "testString");
            TaskAttemptID taid = Org.Mockito.Mockito.Mock <TaskAttemptID>();
            JobID         jid  = new JobID("job", 1);

            Org.Mockito.Mockito.When(((JobID)taid.GetJobID())).ThenReturn(jid);
            Org.Mockito.Mockito.When(taid.ToString()).ThenReturn("JobId");
            FilePath f = TaskLog.GetTaskLogFile(taid, true, TaskLog.LogName.Stdout);

            NUnit.Framework.Assert.IsTrue(f.GetAbsolutePath().EndsWith("testString" + FilePath
                                                                       .separatorChar + "stdout"));
            // test getRealTaskLogFileLocation
            FilePath indexFile = TaskLog.GetIndexFile(taid, true);

            if (!indexFile.GetParentFile().Exists())
            {
                indexFile.GetParentFile().Mkdirs();
            }
            indexFile.Delete();
            indexFile.CreateNewFile();
            TaskLog.SyncLogs("location", taid, true);
            NUnit.Framework.Assert.IsTrue(indexFile.GetAbsolutePath().EndsWith("userlogs" + FilePath
                                                                               .separatorChar + "job_job_0001" + FilePath.separatorChar + "JobId.cleanup" + FilePath
                                                                               .separatorChar + "log.index"));
            f = TaskLog.GetRealTaskLogFileLocation(taid, true, TaskLog.LogName.Debugout);
            if (f != null)
            {
                NUnit.Framework.Assert.IsTrue(f.GetAbsolutePath().EndsWith("location" + FilePath.
                                                                           separatorChar + "debugout"));
                FileUtils.CopyFile(indexFile, f);
            }
            // test obtainLogDirOwner
            NUnit.Framework.Assert.IsTrue(TaskLog.ObtainLogDirOwner(taid).Length > 0);
            // test TaskLog.Reader
            NUnit.Framework.Assert.IsTrue(ReadTaskLog(TaskLog.LogName.Debugout, taid, true).Length
                                          > 0);
        }
Esempio n. 2
0
 public void Run()
 {
     TaskLog.SyncLogs();
 }