- Timestamp:
- 05/17/11 18:29:41 (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Services.Hive.Tests/DaoTests.cs
r6006 r6229 7 7 8 8 namespace HeuristicLab.Services.Hive.Tests { 9 using System.Collections.Generic; 9 10 using System.Threading; 10 11 using DT = HeuristicLab.Services.Hive.Common.DataTransfer; … … 83 84 Assert.IsTrue(Math.Abs((job1.StateLog[i].DateTime - job1loaded.StateLog[i].DateTime).TotalSeconds) < 1); 84 85 } 85 86 86 87 job1 = job1loaded; 87 88 … … 236 237 237 238 } 239 240 241 [TestMethod] 242 public void TestStatistics() { 243 IHiveDao dao = ServiceLocator.Instance.HiveDao; 244 245 var stats = new DT.Statistics(); 246 stats.TimeStamp = DateTime.Now; 247 var slaveStats = new List<DT.SlaveStatistics>(); 248 slaveStats.Add(new DT.SlaveStatistics() { Cores = 8, FreeCores = 3, Memory = 8000, FreeMemory = 3000, CpuUtilization = 0.8, SlaveId = Guid.NewGuid() }); 249 slaveStats.Add(new DT.SlaveStatistics() { Cores = 2, FreeCores = 0, Memory = 1024, FreeMemory = 100, CpuUtilization = 0.99, SlaveId = Guid.NewGuid() }); 250 slaveStats.Add(new DT.SlaveStatistics() { Cores = 4, FreeCores = 4, Memory = 3024, FreeMemory = 2300, CpuUtilization = 0.01, SlaveId = Guid.NewGuid() }); 251 stats.SlaveStatistics = slaveStats; 252 253 var userStats = new List<DT.UserStatistics>(); 254 userStats.Add(new DT.UserStatistics() { UsedCores = 15, ExecutionTime = TimeSpan.FromHours(123), UserId = Guid.NewGuid() }); 255 userStats.Add(new DT.UserStatistics() { UsedCores = 42, ExecutionTime = TimeSpan.FromHours(945), UserId = Guid.NewGuid() }); 256 stats.UserStatistics = userStats; 257 258 stats.Id = dao.AddStatistics(stats); 259 260 var statsLoaded = dao.GetStatistic(stats.Id); 261 Assert.AreEqual(stats.Id, statsLoaded.Id); 262 Assert.IsTrue(Math.Abs((stats.TimeStamp - statsLoaded.TimeStamp).TotalSeconds) < 1); 263 264 for (int i = 0; i < slaveStats.Count; i ++) { 265 Assert.AreEqual(slaveStats[i].Cores, statsLoaded.SlaveStatistics.Single(x => x.SlaveId == slaveStats[i].SlaveId).Cores); 266 Assert.AreEqual(slaveStats[i].FreeCores, statsLoaded.SlaveStatistics.Single(x => x.SlaveId == slaveStats[i].SlaveId).FreeCores); 267 Assert.AreEqual(slaveStats[i].Memory, statsLoaded.SlaveStatistics.Single(x => x.SlaveId == slaveStats[i].SlaveId).Memory); 268 Assert.AreEqual(slaveStats[i].FreeMemory, statsLoaded.SlaveStatistics.Single(x => x.SlaveId == slaveStats[i].SlaveId).FreeMemory); 269 Assert.AreEqual(slaveStats[i].CpuUtilization, statsLoaded.SlaveStatistics.Single(x => x.SlaveId == slaveStats[i].SlaveId).CpuUtilization); 270 } 271 272 for (int i = 0; i < userStats.Count; i++) { 273 Assert.AreEqual(userStats[i].ExecutionTime, statsLoaded.UserStatistics.Single(x => x.UserId == userStats[i].UserId).ExecutionTime); 274 Assert.AreEqual(userStats[i].UsedCores, statsLoaded.UserStatistics.Single(x => x.UserId == userStats[i].UserId).UsedCores); 275 } 276 277 dao.DeleteStatistics(stats.Id); 278 Assert.AreEqual(null, dao.GetStatistic(stats.Id)); 279 } 238 280 } 239 281 }
Note: See TracChangeset
for help on using the changeset viewer.