Exemple #1
0
        public async Task FahClientMessageAggregator_Client_v7_10_SlotID_0_UnitDataOnly()
        {
            // Arrange
            var settings = new ClientSettings {
                Name = "Client_v7_10"
            };
            var fahClient = CreateClient(settings);

            string filteredLogText = String.Join(Environment.NewLine, File.ReadLines(@"..\..\..\..\TestFiles\Client_v7_10\log.txt").Where(x => x.Length != 0).Take(82));

            using (var textReader = new StringReader(filteredLogText))
                using (var reader = new FahClientLogTextReader(textReader))
                {
                    await fahClient.Messages.Log.ReadAsync(reader);
                }

            var extractor = new FahClientJsonMessageExtractor();
            await fahClient.Messages.UpdateMessageAsync(
                extractor.Extract(new StringBuilder(
                                      File.ReadAllText(@"..\..\..\..\TestFiles\Client_v7_10\units.txt"))));

            await fahClient.Messages.UpdateMessageAsync(
                extractor.Extract(new StringBuilder(
                                      File.ReadAllText(@"..\..\..\..\TestFiles\Client_v7_10\info.txt"))));

            await fahClient.Messages.UpdateMessageAsync(
                extractor.Extract(new StringBuilder(
                                      File.ReadAllText(@"..\..\..\..\TestFiles\Client_v7_10\options.txt"))));

            await fahClient.Messages.UpdateMessageAsync(
                extractor.Extract(new StringBuilder(
                                      File.ReadAllText(@"..\..\..\..\TestFiles\Client_v7_10\slots.txt"))));

            await fahClient.Messages.UpdateMessageAsync(
                extractor.Extract(new StringBuilder(
                                      File.ReadAllText(@"..\..\..\..\TestFiles\Client_v7_10\slot-options1.txt"))));

            await fahClient.Messages.UpdateMessageAsync(
                extractor.Extract(new StringBuilder(
                                      File.ReadAllText(@"..\..\..\..\TestFiles\Client_v7_10\slot-options2.txt"))));

            var slotModel = new SlotModel(fahClient)
            {
                SlotID = 0
            };
            var aggregator = new FahClientMessageAggregator(fahClient, slotModel);

            // Act
            var result = aggregator.AggregateData();

            // Assert
            Assert.AreEqual(1, result.WorkUnits.Count);
            Assert.IsFalse(result.WorkUnits.Any(x => x.Value == null));

            #region Check Data Aggregator

            Assert.IsNotNull(result.WorkUnitQueue);
            Assert.AreEqual(1, result.CurrentUnitIndex);
            Assert.AreEqual(new DateTime(2012, 1, 11, 3, 24, 22), result.StartTime);
            Assert.AreEqual(null, result.Arguments);
            Assert.AreEqual(null, result.ClientVersion);
            Assert.AreEqual(null, result.UserID);
            Assert.AreEqual(0, result.MachineID);
            Assert.AreEqual(SlotStatus.Unknown, result.Status);
            Assert.IsNotNull(result.CurrentLogLines);
            Assert.IsTrue(result.WorkUnits.All(x => x.Value.LogLines == null));
            if (result.WorkUnits.ContainsKey(result.CurrentUnitIndex))
            {
                Assert.AreEqual(result.CurrentLogLines, LogLineEnumerable.Create(fahClient.Messages.Log.ClientRuns.Last()));
            }

            #endregion

            var unitInfoData = result.WorkUnits[result.CurrentUnitIndex];

            #region Check Unit Info Data Values
            Assert.AreEqual(DateTime.MinValue, unitInfoData.UnitRetrievalTime);
            Assert.AreEqual("harlam357", unitInfoData.FoldingID);
            Assert.AreEqual(32, unitInfoData.Team);
            Assert.AreEqual(new DateTime(2012, 1, 10, 23, 20, 27), unitInfoData.Assigned);
            Assert.AreEqual(new DateTime(2012, 1, 22, 16, 22, 51), unitInfoData.Timeout);
            Assert.AreEqual(TimeSpan.Zero, unitInfoData.UnitStartTimeStamp);
            Assert.AreEqual(DateTime.MinValue, unitInfoData.Finished);
            Assert.AreEqual(0, unitInfoData.CoreVersion);
            Assert.AreEqual(7610, unitInfoData.ProjectID);
            Assert.AreEqual(630, unitInfoData.ProjectRun);
            Assert.AreEqual(0, unitInfoData.ProjectClone);
            Assert.AreEqual(59, unitInfoData.ProjectGen);
            Assert.AreEqual(null, unitInfoData.ProteinName);
            Assert.AreEqual(null, unitInfoData.ProteinTag);
            Assert.AreEqual(WorkUnitResult.Unknown, unitInfoData.UnitResult);
            Assert.AreEqual(0, unitInfoData.FramesObserved);
            Assert.IsNull(unitInfoData.CurrentFrame);
            Assert.AreEqual("A4", unitInfoData.CoreID);
            #endregion
        }
Exemple #2
0
        public async Task FahClientMessageAggregator_Client_v7_11_SlotID_0()
        {
            // Arrange
            var settings = new ClientSettings {
                Name = "Client_v7_11"
            };
            var fahClient = CreateClient(settings);

            using (var textReader = new StreamReader(@"..\..\..\..\TestFiles\Client_v7_11\log.txt"))
                using (var reader = new FahClientLogTextReader(textReader))
                {
                    await fahClient.Messages.Log.ReadAsync(reader);
                }

            var extractor = new FahClientJsonMessageExtractor();
            await fahClient.Messages.UpdateMessageAsync(
                extractor.Extract(new StringBuilder(
                                      File.ReadAllText(@"..\..\..\..\TestFiles\Client_v7_11\units.txt"))));

            await fahClient.Messages.UpdateMessageAsync(
                extractor.Extract(new StringBuilder(
                                      File.ReadAllText(@"..\..\..\..\TestFiles\Client_v7_11\info.txt"))));

            await fahClient.Messages.UpdateMessageAsync(
                extractor.Extract(new StringBuilder(
                                      File.ReadAllText(@"..\..\..\..\TestFiles\Client_v7_11\options.txt"))));

            await fahClient.Messages.UpdateMessageAsync(
                extractor.Extract(new StringBuilder(
                                      File.ReadAllText(@"..\..\..\..\TestFiles\Client_v7_11\slots.txt"))));

            await fahClient.Messages.UpdateMessageAsync(
                extractor.Extract(new StringBuilder(
                                      File.ReadAllText(@"..\..\..\..\TestFiles\Client_v7_11\slot-options1.txt"))));

            var slotModel = new SlotModel(fahClient)
            {
                SlotID = 0
            };
            var aggregator = new FahClientMessageAggregator(fahClient, slotModel);

            // Act
            var result = aggregator.AggregateData();

            // Assert
            Assert.AreEqual(1, result.WorkUnits.Count);
            Assert.IsFalse(result.WorkUnits.Any(x => x.Value == null));

            #region Check Data Aggregator

            Assert.IsNotNull(result.WorkUnitQueue);
            Assert.AreEqual(1, result.CurrentUnitIndex);
            Assert.AreEqual(new DateTime(2012, 2, 18, 6, 33, 41), result.StartTime);
            Assert.AreEqual(null, result.Arguments);
            Assert.AreEqual(null, result.ClientVersion);
            Assert.AreEqual(null, result.UserID);
            Assert.AreEqual(0, result.MachineID);
            Assert.AreEqual(SlotStatus.Unknown, result.Status);
            Assert.IsNotNull(result.CurrentLogLines);
            Assert.IsFalse(result.WorkUnits.Any(x => x.Value.LogLines == null));
            if (result.WorkUnits.ContainsKey(result.CurrentUnitIndex))
            {
                Assert.AreEqual(result.CurrentLogLines, result.WorkUnits[result.CurrentUnitIndex].LogLines);
            }

            #endregion

            var unitInfoData = result.WorkUnits[result.CurrentUnitIndex];

            #region Check Unit Info Data Values
            Assert.AreEqual(DateTime.MinValue, unitInfoData.UnitRetrievalTime);
            Assert.AreEqual("harlam357", unitInfoData.FoldingID);
            Assert.AreEqual(32, unitInfoData.Team);
            Assert.AreEqual(new DateTime(2012, 2, 17, 21, 48, 22), unitInfoData.Assigned);
            Assert.AreEqual(new DateTime(2012, 2, 29, 14, 50, 46), unitInfoData.Timeout);
            Assert.AreEqual(new TimeSpan(6, 34, 38), unitInfoData.UnitStartTimeStamp);
            Assert.AreEqual(DateTime.MinValue, unitInfoData.Finished);
            Assert.AreEqual(2.27f, unitInfoData.CoreVersion);
            Assert.AreEqual(7610, unitInfoData.ProjectID);
            Assert.AreEqual(192, unitInfoData.ProjectRun);
            Assert.AreEqual(0, unitInfoData.ProjectClone);
            Assert.AreEqual(58, unitInfoData.ProjectGen);
            Assert.AreEqual(null, unitInfoData.ProteinName);
            Assert.AreEqual(null, unitInfoData.ProteinTag);
            Assert.AreEqual(WorkUnitResult.Unknown, unitInfoData.UnitResult);
            Assert.AreEqual(3, unitInfoData.FramesObserved);
            Assert.AreEqual(95, unitInfoData.CurrentFrame.ID);
            Assert.AreEqual(1900000, unitInfoData.CurrentFrame.RawFramesComplete);
            Assert.AreEqual(2000000, unitInfoData.CurrentFrame.RawFramesTotal);
            Assert.AreEqual(new TimeSpan(6, 46, 16), unitInfoData.CurrentFrame.TimeStamp);
            Assert.AreEqual(new TimeSpan(0, 4, 50), unitInfoData.CurrentFrame.Duration);
            Assert.AreEqual("A4", unitInfoData.CoreID);
            #endregion
        }
Exemple #3
0
        public void FahClient_UpdateWorkUnitBenchmarkAndRepository()
        {
            // Arrange
            var benchmarkService       = new ProteinBenchmarkService(new ProteinBenchmarkDataContainer());
            var mockWorkUnitRepository = new Mock <IWorkUnitRepository>();
            var fahClient = new FahClient(null, new InMemoryPreferencesProvider(), benchmarkService, null, mockWorkUnitRepository.Object);

            var workUnit = new WorkUnit();

            workUnit.ProjectID    = 2669;
            workUnit.ProjectRun   = 1;
            workUnit.ProjectClone = 2;
            workUnit.ProjectGen   = 3;
            workUnit.Finished     = new DateTime(2010, 1, 1);
            workUnit.QueueIndex   = 0;
            var settings = new ClientSettings {
                Name = "Owner", Server = "Path", Port = ClientSettings.NoPort
            };
            var currentWorkUnit = new WorkUnitModel(new SlotModel(new NullClient {
                Settings = settings
            }), workUnit);
            var slotIdentifier = currentWorkUnit.SlotModel.SlotIdentifier;

            var workUnitCopy = workUnit.Copy();

            workUnitCopy.FramesObserved = 4;
            var frames = new Dictionary <int, LogLineFrameData>()
                         .With(new LogLineFrameData {
                Duration = TimeSpan.FromMinutes(0), ID = 0
            },
                               new LogLineFrameData {
                Duration = TimeSpan.FromMinutes(5), ID = 1
            },
                               new LogLineFrameData {
                Duration = TimeSpan.FromMinutes(5), ID = 2
            },
                               new LogLineFrameData {
                Duration = TimeSpan.FromMinutes(5), ID = 3
            });

            workUnitCopy.Frames     = frames;
            workUnitCopy.UnitResult = WorkUnitResult.FinishedUnit;

            var parsedUnits = new[] { new WorkUnitModel(new SlotModel(new NullClient {
                    Settings = settings
                }), workUnitCopy) };

            mockWorkUnitRepository.SetupGet(x => x.Connected).Returns(true);

            var benchmarkIdentifier = new ProteinBenchmarkIdentifier(2669);

            // Assert (pre-condition)
            Assert.IsFalse(benchmarkService.DataContainer.Data.Any(x => x.SlotIdentifier.Equals(slotIdentifier)));
            Assert.IsFalse(benchmarkService.GetBenchmarkProjects(slotIdentifier).Contains(2669));
            Assert.IsNull(benchmarkService.GetBenchmark(slotIdentifier, benchmarkIdentifier));

            // Act
            fahClient.UpdateWorkUnitBenchmarkAndRepository(currentWorkUnit, parsedUnits);

            // Assert
            Assert.IsTrue(benchmarkService.DataContainer.Data.Any(x => x.SlotIdentifier.Equals(slotIdentifier)));
            Assert.IsTrue(benchmarkService.GetBenchmarkProjects(slotIdentifier).Contains(2669));
            Assert.AreEqual(TimeSpan.FromMinutes(5), benchmarkService.GetBenchmark(slotIdentifier, benchmarkIdentifier).AverageFrameTime);

            mockWorkUnitRepository.Verify(x => x.Insert(It.IsAny <WorkUnitModel>()), Times.Once);
        }