public void FahClientLog_Read_Client_v7_INTERRUPTED_Test() { // Act var fahLog = FahClientLog.Read(TestDataReader.ReadStream("Client_v7_INTERRUPTED_log.txt")); // Assert Assert.AreEqual(1, fahLog.ClientRuns.Count); var clientRun = fahLog.ClientRuns.First(); Assert.AreEqual(2, clientRun.SlotRuns.Count); var slotRun0 = clientRun.SlotRuns[0]; Assert.AreEqual(5, slotRun0.UnitRuns.Count); var interruptedUnitRun = slotRun0.UnitRuns[1]; Assert.AreEqual(84, interruptedUnitRun.Data.FramesObserved); var interruptedFrames = interruptedUnitRun.Data.Frames; Assert.AreNotEqual(TimeSpan.Zero, interruptedFrames[16].Duration); Assert.AreEqual(TimeSpan.Zero, interruptedFrames[17].Duration); Assert.AreNotEqual(TimeSpan.Zero, interruptedFrames[18].Duration); }
public void FahClientLog_Read_ThrowsWhenFahLogReaderIsNull_Test() { Assert.Throws <ArgumentNullException>(() => { FahLog log = new FahClientLog(); log.Read(null); }); }
public void LogLineEnumerable_FromFahLog_Test() { // Arrange var fahLog = FahClientLog.Read(TestDataReader.ReadStream("Client_v7_16_log.txt")); // Act var enumerable = LogLineEnumerable.Create(fahLog); // Assert Assert.AreEqual(34346, enumerable.Count()); }
/// <summary> /// Reads the log file from the given path and returns a new <see cref="FahClientLog"/> object. /// </summary> /// <param name="stream">A stream containing the log file text.</param> /// <returns>A new <see cref="FahClientLog"/> object.</returns> public static FahClientLog Read(Stream stream) { using (var textReader = new StreamReader(stream)) using (var reader = new FahClientLogTextReader(textReader)) { var log = new FahClientLog(); log.Read(reader); return(log); } }
public void LogLineEnumerable_FromFahLog_Test() { // Arrange var fahLog = FahClientLog.Read("..\\..\\..\\TestFiles\\Client_v7_16\\log.txt"); // Act var enumerable = LogLineEnumerable.Create(fahLog); // Assert Assert.AreEqual(34346, enumerable.Count()); }
public void LogLineEnumerable_FromUnitRun_Test() { // Arrange var fahLog = FahClientLog.Read(TestDataReader.ReadStream("Client_v7_16_log.txt")); var unitRun = fahLog.ClientRuns.Last().SlotRuns[0].UnitRuns.Last(); // Act var enumerable = LogLineEnumerable.Create(unitRun); // Assert Assert.AreEqual(150, enumerable.Count()); }
public void LogLineEnumerable_FromUnitRun_Test() { // Arrange var fahLog = FahClientLog.Read("..\\..\\..\\TestFiles\\Client_v7_16\\log.txt"); var unitRun = fahLog.ClientRuns.Last().SlotRuns[0].UnitRuns.Last(); // Act var enumerable = LogLineEnumerable.Create(unitRun); // Assert Assert.AreEqual(150, enumerable.Count()); }
public void FahClientLog_Read_FromPath_Test() { using (var artifacts = new ArtifactFolder()) { var path = artifacts.GetRandomFilePath(); using (var stream = File.OpenWrite(path)) { TestDataReader.ReadStream("Client_v7_10_log.txt").CopyTo(stream); } var log = FahClientLog.Read(path); Assert.IsTrue(log.ClientRuns.Count > 0); } }
public void FahClientLog_Clear_Test() { // Arrange var log = new FahClientLog(); using (var textReader = new StreamReader(TestDataReader.ReadStream("Client_v7_10_log.txt"))) using (var reader = new FahClientLogTextReader(textReader)) { log.Read(reader); } Assert.IsTrue(log.ClientRuns.Count > 0); // Act log.Clear(); // Assert Assert.AreEqual(0, log.ClientRuns.Count); }
public void FahClientLog_Read_Client_v7_fr_FR_Test() { // Act var fahLog = FahClientLog.Read(TestDataReader.ReadStream("Client_v7_fr-FR_log.txt")); // Assert Assert.AreEqual(1, fahLog.ClientRuns.Count); var clientRun = fahLog.ClientRuns.First(); Assert.AreEqual(2, clientRun.SlotRuns.Count); var slotRun0 = clientRun.SlotRuns[0]; Assert.AreEqual(1, slotRun0.UnitRuns.Count); var slotRun1 = clientRun.SlotRuns[1]; Assert.AreEqual(1, slotRun1.UnitRuns.Count); }
public void FahClientLog_Read_Client_v7_Using_OpenCL_Test() { // Act var fahLog = FahClientLog.Read(TestDataReader.ReadStream("Client_v7_OpenCL_log.txt")); // Assert Assert.AreEqual(1, fahLog.ClientRuns.Count); var clientRun = fahLog.ClientRuns.First(); Assert.AreEqual(1, clientRun.SlotRuns.Count); var slotRun0 = clientRun.SlotRuns[0]; var unitRun0 = slotRun0.UnitRuns[0]; var platformLine = unitRun0.LogLines[80]; Assert.AreEqual("OpenCL", platformLine.Data.ToString()); Assert.AreEqual("OpenCL", unitRun0.Data.Platform); }
public void FahClientLog_Read_Client_v7_CORE_RESTART_Test() { // Act var fahLog = FahClientLog.Read(TestDataReader.ReadStream("Client_v7_CORE_RESTART_log.txt")); // Assert Assert.AreEqual(1, fahLog.ClientRuns.Count); var clientRun = fahLog.ClientRuns.First(); Assert.AreEqual(1, clientRun.SlotRuns.Count); var slotRun = clientRun.SlotRuns[0]; Assert.AreEqual(3, slotRun.UnitRuns.Count); var unitRun = slotRun.UnitRuns[0]; Assert.AreEqual(66, unitRun.Data.Frames.Count); Assert.AreEqual(66, unitRun.Data.FramesObserved); Assert.AreEqual(WorkUnitResult.FINISHED_UNIT, unitRun.Data.WorkUnitResult); }
public void FahClientLog_DefineCustomLogLineTypeAndParseData_Test() { // Arrange var log = new FahClientLog(); using (var textReader = new StreamReader("..\\..\\..\\TestFiles\\Client_v7_10\\log.txt")) using (var reader = new CustomFahClientLogTextReader(textReader)) { // Act log.Read(reader); } var lines = LogLineEnumerable.Create(log).Where(x => x.LineType == CustomLogLineType.ConnectingTo).ToList(); foreach (var logLine in lines) { System.Diagnostics.Debug.WriteLine(logLine.Data); } // Assert Assert.IsTrue(lines.Count > 0); }
public void FahClientLog_Read_Client_v7_BAD_FRAME_CHECKSUM_Test() { // Act var fahLog = FahClientLog.Read(TestDataReader.ReadStream("Client_v7_BAD_FRAME_CHECKSUM_log.txt")); // Assert Assert.AreEqual(1, fahLog.ClientRuns.Count); var clientRun = fahLog.ClientRuns.First(); Assert.AreEqual(1, clientRun.SlotRuns.Count); var slotRun = clientRun.SlotRuns[1]; Assert.AreEqual(2, slotRun.UnitRuns.Count); Assert.AreEqual(1, slotRun.Data.FailedUnits); var unitRun = slotRun.UnitRuns[0]; Assert.AreEqual(0, unitRun.Data.Frames.Count); Assert.AreEqual(0, unitRun.Data.FramesObserved); Assert.AreEqual(WorkUnitResult.BAD_FRAME_CHECKSUM, unitRun.Data.WorkUnitResult); }
public void FahClientLog_Read_Client_v7_16_Test() { var log = new FahClientLog(); var stream = TestDataReader.ReadStream("Client_v7_16_log.txt"); var readTask = Task.Run(() => { log.Read(new FahClientLogTextReader(new StreamReader(stream))); Thread.Sleep(100); }); var runDataTask = Task.Run(() => { int i = 0; while (i++ < 20) { var clientRun = log.ClientRuns.FirstOrDefault(); var clientRunData = clientRun?.Data; Console.WriteLine("StartTime: " + clientRunData?.StartTime); if (clientRun != null) { var slotKeys = clientRun.SlotRuns.Keys.ToList(); foreach (var slotKey in slotKeys) { var slotRun = clientRun.SlotRuns[slotKey]; var slotRunData = slotRun.Data; Console.WriteLine("CompletedUnits: " + slotRunData.CompletedUnits); Console.WriteLine("FailedUnits: " + slotRunData.FailedUnits); var unitRun = slotRun.UnitRuns.LastOrDefault(); var unitRunData = unitRun?.Data; Console.WriteLine("ProjectID: " + unitRunData?.ProjectID); } } Thread.Sleep(10); } }); Task.WaitAll(readTask, runDataTask); }