- Timestamp:
- 09/08/11 13:41:25 (13 years ago)
- Location:
- branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Services.Hive.Tests
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Services.Hive.Tests/DaoTests.cs
r6717 r6721 51 51 he.Id = dao.AddHiveExperiment(he); 52 52 53 DT. Job job1 = new DT.Job();54 job1.State = DT. JobState.Offline;55 job1.StateLog.Add(new DT.StateLog { State = DT. JobState.Offline, DateTime = DateTime.Now });53 DT.Task job1 = new DT.Task(); 54 job1.State = DT.TaskState.Offline; 55 job1.StateLog.Add(new DT.StateLog { State = DT.TaskState.Offline, DateTime = DateTime.Now }); 56 56 job1.Command = DT.Command.Pause; 57 57 job1.HiveExperimentId = he.Id; 58 58 job1.IsPrivileged = true; 59 59 60 DT. JobData jobData1 = new DT.JobData();60 DT.TaskData jobData1 = new DT.TaskData(); 61 61 jobData1.Data = new byte[] { 0, 1, 2, 3, 4, 5 }; 62 62 jobData1.LastUpdate = DateTime.Now; … … 81 81 82 82 job1.Id = dao.AddJob(job1); 83 jobData1. JobId = job1.Id;83 jobData1.TaskId = job1.Id; 84 84 dao.AddJobData(jobData1); 85 85 86 DT. Jobjob1loaded = dao.GetJob(job1.Id);86 DT.Task job1loaded = dao.GetJob(job1.Id); 87 87 Assert.AreEqual(job1.Id, job1loaded.Id); 88 88 Assert.AreEqual(job1.CoresNeeded, job1loaded.CoresNeeded); … … 96 96 Assert.IsTrue(Math.Abs((job1loaded.LastJobDataUpdate - jobData1.LastUpdate).TotalSeconds) < 1); 97 97 for (int i = 0; i < job1.StateLog.Count; i++) { 98 Assert.AreEqual(job1.Id, job1loaded.StateLog[i]. JobId);98 Assert.AreEqual(job1.Id, job1loaded.StateLog[i].TaskId); 99 99 Assert.AreEqual(job1.StateLog[i].State, job1loaded.StateLog[i].State); 100 100 Assert.AreEqual(job1.StateLog[i].SlaveId, job1loaded.StateLog[i].SlaveId); … … 107 107 108 108 // test jobstates 109 job1.StateLog.Add(new DT.StateLog { State = DT. JobState.Transferring, DateTime = DateTime.Now }); Thread.Sleep(10);110 job1.StateLog.Add(new DT.StateLog { State = DT. JobState.Calculating, DateTime = DateTime.Now }); Thread.Sleep(10);111 job1.StateLog.Add(new DT.StateLog { State = DT. JobState.Transferring, DateTime = DateTime.Now }); Thread.Sleep(10);112 job1.StateLog.Add(new DT.StateLog { State = DT. JobState.Finished, DateTime = DateTime.Now }); Thread.Sleep(10);109 job1.StateLog.Add(new DT.StateLog { State = DT.TaskState.Transferring, DateTime = DateTime.Now }); Thread.Sleep(10); 110 job1.StateLog.Add(new DT.StateLog { State = DT.TaskState.Calculating, DateTime = DateTime.Now }); Thread.Sleep(10); 111 job1.StateLog.Add(new DT.StateLog { State = DT.TaskState.Transferring, DateTime = DateTime.Now }); Thread.Sleep(10); 112 job1.StateLog.Add(new DT.StateLog { State = DT.TaskState.Finished, DateTime = DateTime.Now }); Thread.Sleep(10); 113 113 dao.UpdateJob(job1); 114 114 115 115 job1loaded = dao.GetJob(job1.Id); 116 116 for (int i = 0; i < job1.StateLog.Count; i++) { 117 Assert.AreEqual(job1.Id, job1loaded.StateLog[i]. JobId);117 Assert.AreEqual(job1.Id, job1loaded.StateLog[i].TaskId); 118 118 Assert.AreEqual(job1.StateLog[i].State, job1loaded.StateLog[i].State); 119 119 Assert.AreEqual(job1.StateLog[i].SlaveId, job1loaded.StateLog[i].SlaveId); … … 123 123 } 124 124 125 DT. JobData jobData1Loaded = dao.GetJobData(job1.Id);126 Assert.AreEqual(jobData1. JobId, jobData1Loaded.JobId);125 DT.TaskData jobData1Loaded = dao.GetJobData(job1.Id); 126 Assert.AreEqual(jobData1.TaskId, jobData1Loaded.TaskId); 127 127 Assert.IsTrue(Math.Abs((jobData1.LastUpdate - jobData1Loaded.LastUpdate).TotalSeconds) < 1); 128 128 Assert.IsTrue(jobData1.Data.SequenceEqual(jobData1Loaded.Data)); … … 222 222 he.Id = dao.AddHiveExperiment(he); 223 223 224 DT. Job job = new DT.Job();225 job.State = DT. JobState.Offline;226 job.StateLog.Add(new DT.StateLog { State = DT. JobState.Offline, DateTime = DateTime.Now });224 DT.Task job = new DT.Task(); 225 job.State = DT.TaskState.Offline; 226 job.StateLog.Add(new DT.StateLog { State = DT.TaskState.Offline, DateTime = DateTime.Now }); 227 227 job.HiveExperimentId = he.Id; 228 228 job.Id = dao.AddJob(job); … … 242 242 //Assert.AreEqual(he.DateCreated, heLoaded.DateCreated); 243 243 244 DT. JobjobLoaded = dao.GetJob(job.Id);244 DT.Task jobLoaded = dao.GetJob(job.Id); 245 245 Assert.AreEqual(job.Id, jobLoaded.Id); 246 246 Assert.AreEqual(job.State, jobLoaded.State); -
branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Services.Hive.Tests/Mocks/MockUserManager.cs
r6463 r6721 1 using System; 1 #region License Information 2 /* HeuristicLab 3 * Copyright (C) 2002-2011 Heuristic and Evolutionary Algorithms Laboratory (HEAL) 4 * 5 * This file is part of HeuristicLab. 6 * 7 * HeuristicLab is free software: you can redistribute it and/or modify 8 * it under the terms of the GNU General Public License as published by 9 * the Free Software Foundation, either version 3 of the License, or 10 * (at your option) any later version. 11 * 12 * HeuristicLab is distributed in the hope that it will be useful, 13 * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 * GNU General Public License for more details. 16 * 17 * You should have received a copy of the GNU General Public License 18 * along with HeuristicLab. If not, see <http://www.gnu.org/licenses/>. 19 */ 20 #endregion 21 22 using System; 2 23 using System.Web.Security; 3 24 … … 16 37 get { return null; /* todo */ } 17 38 } 18 39 19 40 public MembershipUser GetUserByName(string username) { 20 41 return null; // todo -
branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Services.Hive.Tests/ServiceTests.cs
r6717 r6721 52 52 53 53 // create job 54 DT. Job job = new DT.Job() { CoresNeeded = 1, MemoryNeeded = 0, Priority = 0 };55 job.State = DT. JobState.Offline;56 job.StateLog.Add(new DT.StateLog { State = DT. JobState.Offline, DateTime = DateTime.Now });57 58 DT. JobData jobData = new DT.JobData() {54 DT.Task job = new DT.Task() { CoresNeeded = 1, MemoryNeeded = 0, Priority = 0 }; 55 job.State = DT.TaskState.Offline; 56 job.StateLog.Add(new DT.StateLog { State = DT.TaskState.Offline, DateTime = DateTime.Now }); 57 58 DT.TaskData jobData = new DT.TaskData() { 59 59 //Data = PersistenceUtil.Serialize(new MockJob(500, true)) 60 60 Data = new byte[10000] … … 105 105 106 106 // test job 107 DT. JobjobLoaded = service.GetJob(job.Id);107 DT.Task jobLoaded = service.GetJob(job.Id); 108 108 Assert.AreEqual(job.Id, jobLoaded.Id); 109 109 Assert.AreEqual(job.CoresNeeded, jobLoaded.CoresNeeded); 110 110 Assert.AreEqual(job.MemoryNeeded, jobLoaded.MemoryNeeded); 111 111 Assert.AreEqual(job.Priority, jobLoaded.Priority); 112 Assert.AreEqual(DT. JobState.Waiting, jobLoaded.State);112 Assert.AreEqual(DT.TaskState.Waiting, jobLoaded.State); 113 113 Assert.IsTrue(job.PluginsNeededIds.SequenceEqual(jobLoaded.PluginsNeededIds)); 114 114 Assert.AreEqual(job.HiveExperimentId, jobLoaded.HiveExperimentId); 115 115 116 DT. JobData jobDataLoaded = service.GetJobData(job.Id);117 Assert.AreEqual(job.Id, jobDataLoaded. JobId);116 DT.TaskData jobDataLoaded = service.GetJobData(job.Id); 117 Assert.AreEqual(job.Id, jobDataLoaded.TaskId); 118 118 Assert.IsTrue(jobData.Data.SequenceEqual(jobDataLoaded.Data)); 119 119 … … 128 128 Assert.AreEqual(1, actions.Count); 129 129 Assert.AreEqual(MessageContainer.MessageType.CalculateJob, actions[0].Message); 130 Assert.AreEqual(job.Id, actions[0]. JobId);130 Assert.AreEqual(job.Id, actions[0].TaskId); 131 131 132 132 jobLoaded = service.GetJob(job.Id); 133 Assert.AreEqual( JobState.Transferring, jobLoaded.State);133 Assert.AreEqual(TaskState.Transferring, jobLoaded.State); 134 134 135 135 // slave is responsible for updating state to 'Calculating' 136 service.UpdateJobState(jobLoaded.Id, DT. JobState.Calculating, slave.Id, null, null);136 service.UpdateJobState(jobLoaded.Id, DT.TaskState.Calculating, slave.Id, null, null); 137 137 138 138 // send progress … … 144 144 // the job should be in state 'Calculating' now 145 145 jobLoaded = service.GetJob(job.Id); 146 Assert.AreEqual( JobState.Calculating, jobLoaded.State);146 Assert.AreEqual(TaskState.Calculating, jobLoaded.State); 147 147 Assert.AreEqual(new TimeSpan(1, 5, 10, 20, 30), jobLoaded.ExecutionTime); 148 148 … … 153 153 154 154 // set it to finished 155 service.UpdateJobState(jobLoaded.Id, DT. JobState.Finished, slave.Id, null, null);155 service.UpdateJobState(jobLoaded.Id, DT.TaskState.Finished, slave.Id, null, null); 156 156 157 157 // test if the job is returned for the resource (it should not be) … … 160 160 161 161 // set job waiting again 162 service.UpdateJobState(job.Id, DT. JobState.Waiting, null, null, string.Empty);162 service.UpdateJobState(job.Id, DT.TaskState.Waiting, null, null, string.Empty); 163 163 164 164 // get job again … … 166 166 Assert.AreEqual(1, actions.Count); 167 167 Assert.AreEqual(MessageContainer.MessageType.CalculateJob, actions[0].Message); 168 Assert.AreEqual(job.Id, actions[0]. JobId);168 Assert.AreEqual(job.Id, actions[0].TaskId); 169 169 170 170 // create downtime which should make slave unavailable for calculation … … 176 176 Assert.AreEqual(1, actions.Count); 177 177 Assert.AreEqual(MessageContainer.MessageType.PauseAll, actions[0].Message); 178 Assert.AreEqual(Guid.Empty, actions[0]. JobId);178 Assert.AreEqual(Guid.Empty, actions[0].TaskId); 179 179 180 180 service.DeleteDowntime(downtimeId); … … 190 190 Assert.AreEqual(1, actions.Count); 191 191 Assert.AreEqual(MessageContainer.MessageType.AbortJob, actions[0].Message); 192 Assert.AreEqual(job.Id, actions[0]. JobId);192 Assert.AreEqual(job.Id, actions[0].TaskId); 193 193 194 194 // delete slave … … 204 204 205 205 // create parent job 206 DT. Job parentJob = new DT.Job() {206 DT.Task parentJob = new DT.Task() { 207 207 CoresNeeded = 1, 208 208 MemoryNeeded = 0, … … 211 211 FinishWhenChildJobsFinished = true 212 212 }; 213 parentJob.State = DT. JobState.Offline;214 parentJob.StateLog.Add(new DT.StateLog { State = DT. JobState.Offline, DateTime = DateTime.Now });215 216 DT. JobData parentJobData = new DT.JobData() { Data = new byte[0] };213 parentJob.State = DT.TaskState.Offline; 214 parentJob.StateLog.Add(new DT.StateLog { State = DT.TaskState.Offline, DateTime = DateTime.Now }); 215 216 DT.TaskData parentJobData = new DT.TaskData() { Data = new byte[0] }; 217 217 218 218 // create child job 219 DT. Job childJob = new DT.Job() {219 DT.Task childJob = new DT.Task() { 220 220 CoresNeeded = 1, 221 221 MemoryNeeded = 0, 222 222 Priority = 0 223 223 }; 224 childJob.State = DT. JobState.Offline;225 childJob.StateLog.Add(new DT.StateLog { State = DT. JobState.Offline, DateTime = DateTime.Now });226 227 DT. JobData childJobData = new DT.JobData() { Data = new byte[1000] };224 childJob.State = DT.TaskState.Offline; 225 childJob.StateLog.Add(new DT.StateLog { State = DT.TaskState.Offline, DateTime = DateTime.Now }); 226 227 DT.TaskData childJobData = new DT.TaskData() { Data = new byte[1000] }; 228 228 229 229 // create slave … … 250 250 childJob.HiveExperimentId = experiment.Id; 251 251 childJob.Id = service.AddChildJob(parentJob.Id, childJob, childJobData); 252 childJob.Parent JobId = parentJob.Id;252 childJob.ParentTaskId = parentJob.Id; 253 253 254 254 // test child job 255 255 var childJobLoaded = service.GetJob(childJob.Id); 256 Assert.AreEqual(childJob.Parent JobId, childJobLoaded.ParentJobId);256 Assert.AreEqual(childJob.ParentTaskId, childJobLoaded.ParentTaskId); 257 257 Assert.AreEqual(childJob.HiveExperimentId, childJobLoaded.HiveExperimentId); 258 Assert.AreEqual(DT. JobState.Waiting, childJobLoaded.State);258 Assert.AreEqual(DT.TaskState.Waiting, childJobLoaded.State); 259 259 Assert.AreEqual(false, childJobLoaded.FinishWhenChildJobsFinished); 260 260 Assert.AreEqual(false, childJobLoaded.IsParentJob); … … 263 263 var parentJobLoaded = service.GetJob(parentJob.Id); 264 264 Assert.AreEqual(parentJob.HiveExperimentId, parentJobLoaded.HiveExperimentId); 265 Assert.AreEqual( JobState.Waiting, parentJobLoaded.State);265 Assert.AreEqual(TaskState.Waiting, parentJobLoaded.State); 266 266 Assert.AreEqual(true, parentJobLoaded.FinishWhenChildJobsFinished); 267 267 Assert.AreEqual(true, parentJobLoaded.IsParentJob); … … 271 271 Assert.AreEqual(1, actions.Count); // only the child job should be assigned 272 272 Assert.AreEqual(MessageContainer.MessageType.CalculateJob, actions[0].Message); 273 Assert.AreEqual(childJob.Id, actions[0]. JobId);273 Assert.AreEqual(childJob.Id, actions[0].TaskId); 274 274 275 275 // lifecycle - let it process one server-heartbeat; the parent job must NOT be set to finished … … 277 277 278 278 parentJobLoaded = service.GetJob(parentJob.Id); 279 Assert.AreEqual( JobState.Waiting, parentJobLoaded.State);279 Assert.AreEqual(TaskState.Waiting, parentJobLoaded.State); 280 280 281 281 // set child job to finished 282 childJobLoaded = service.UpdateJobState(childJobLoaded.Id, DT. JobState.Finished, slave.Id, null, null);282 childJobLoaded = service.UpdateJobState(childJobLoaded.Id, DT.TaskState.Finished, slave.Id, null, null); 283 283 284 284 // lifecycle - let it process one server-heartbeat; this should set the parent job to finished … … 287 287 // test if parent job is finished 288 288 parentJobLoaded = service.GetJob(parentJob.Id); 289 Assert.AreEqual( JobState.Finished, parentJobLoaded.State);289 Assert.AreEqual(TaskState.Finished, parentJobLoaded.State); 290 290 291 291 // delete experiment
Note: See TracChangeset
for help on using the changeset viewer.