private int VerifyContainerLog(int containerNum, IList <string> expectedContent, bool count, string expectedWord) { FilePath logFolder = new FilePath(yarnCluster.GetNodeManager(0).GetConfig().Get(YarnConfiguration .NmLogDirs, YarnConfiguration.DefaultNmLogDirs)); FilePath[] listOfFiles = logFolder.ListFiles(); int currentContainerLogFileIndex = -1; for (int i = listOfFiles.Length - 1; i >= 0; i--) { if (listOfFiles[i].ListFiles().Length == containerNum + 1) { currentContainerLogFileIndex = i; break; } } NUnit.Framework.Assert.IsTrue(currentContainerLogFileIndex != -1); FilePath[] containerFiles = listOfFiles[currentContainerLogFileIndex].ListFiles(); int numOfWords = 0; for (int i_1 = 0; i_1 < containerFiles.Length; i_1++) { foreach (FilePath output in containerFiles[i_1].ListFiles()) { if (output.GetName().Trim().Contains("stdout")) { BufferedReader br = null; IList <string> stdOutContent = new AList <string>(); try { string sCurrentLine; br = new BufferedReader(new FileReader(output)); int numOfline = 0; while ((sCurrentLine = br.ReadLine()) != null) { if (count) { if (sCurrentLine.Contains(expectedWord)) { numOfWords++; } } else { if (output.GetName().Trim().Equals("stdout")) { if (!Shell.Windows) { NUnit.Framework.Assert.AreEqual("The current is" + sCurrentLine, expectedContent[ numOfline], sCurrentLine.Trim()); numOfline++; } else { stdOutContent.AddItem(sCurrentLine.Trim()); } } } } /* By executing bat script using cmd /c, * it will output all contents from bat script first * It is hard for us to do check line by line * Simply check whether output from bat file contains * all the expected messages */ if (Shell.Windows && !count && output.GetName().Trim().Equals("stdout")) { NUnit.Framework.Assert.IsTrue(stdOutContent.ContainsAll(expectedContent)); } } catch (IOException e) { Sharpen.Runtime.PrintStackTrace(e); } finally { try { if (br != null) { br.Close(); } } catch (IOException ex) { Sharpen.Runtime.PrintStackTrace(ex); } } } } } return(numOfWords); }