- Timestamp:
- 09/12/11 18:04:25 (13 years ago)
- Location:
- branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Services.Hive.Tests
- Files:
-
- 4 edited
- 1 moved
Legend:
- Unmodified
- Added
- Removed
-
branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Services.Hive.Tests/DaoTests.cs
r6723 r6743 49 49 he.OwnerUserId = Guid.NewGuid(); 50 50 he.ResourceNames = "HEAL"; 51 he.Id = dao.Add HiveExperiment(he);51 he.Id = dao.AddJob(he); 52 52 53 53 DT.Task job1 = new DT.Task(); … … 80 80 job1.PluginsNeededIds.Add(plugin1.Id); 81 81 82 job1.Id = dao.Add Job(job1);82 job1.Id = dao.AddTask(job1); 83 83 jobData1.TaskId = job1.Id; 84 dao.Add JobData(jobData1);85 86 DT.Task job1loaded = dao.Get Job(job1.Id);84 dao.AddTaskData(jobData1); 85 86 DT.Task job1loaded = dao.GetTask(job1.Id); 87 87 Assert.AreEqual(job1.Id, job1loaded.Id); 88 88 Assert.AreEqual(job1.CoresNeeded, job1loaded.CoresNeeded); … … 94 94 Assert.AreEqual(job1.JobId, job1loaded.JobId); 95 95 Assert.AreEqual(job1.IsPrivileged, job1loaded.IsPrivileged); 96 Assert.IsTrue(Math.Abs((job1loaded.Last JobDataUpdate - jobData1.LastUpdate).TotalSeconds) < 1);96 Assert.IsTrue(Math.Abs((job1loaded.LastTaskDataUpdate - jobData1.LastUpdate).TotalSeconds) < 1); 97 97 for (int i = 0; i < job1.StateLog.Count; i++) { 98 98 Assert.AreEqual(job1.Id, job1loaded.StateLog[i].TaskId); … … 111 111 job1.StateLog.Add(new DT.StateLog { State = DT.TaskState.Transferring, DateTime = DateTime.Now }); Thread.Sleep(10); 112 112 job1.StateLog.Add(new DT.StateLog { State = DT.TaskState.Finished, DateTime = DateTime.Now }); Thread.Sleep(10); 113 dao.Update Job(job1);114 115 job1loaded = dao.Get Job(job1.Id);113 dao.UpdateTask(job1); 114 115 job1loaded = dao.GetTask(job1.Id); 116 116 for (int i = 0; i < job1.StateLog.Count; i++) { 117 117 Assert.AreEqual(job1.Id, job1loaded.StateLog[i].TaskId); … … 123 123 } 124 124 125 DT.TaskData jobData1Loaded = dao.Get JobData(job1.Id);125 DT.TaskData jobData1Loaded = dao.GetTaskData(job1.Id); 126 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)); 129 129 130 dao.Delete HiveExperiment(he.Id);131 132 Assert.AreEqual(null, dao.Get Job(job1.Id));133 Assert.AreEqual(null, dao.Get JobData(job1.Id));134 Assert.AreEqual(null, dao.Get HiveExperiment(he.Id));130 dao.DeleteJob(he.Id); 131 132 Assert.AreEqual(null, dao.GetTask(job1.Id)); 133 Assert.AreEqual(null, dao.GetTaskData(job1.Id)); 134 Assert.AreEqual(null, dao.GetJob(he.Id)); 135 135 136 136 dao.DeletePlugin(plugin1.Id); … … 220 220 he.OwnerUserId = Guid.NewGuid(); 221 221 he.ResourceNames = "HEAL"; 222 he.Id = dao.Add HiveExperiment(he);222 he.Id = dao.AddJob(he); 223 223 224 224 DT.Task job = new DT.Task(); … … 226 226 job.StateLog.Add(new DT.StateLog { State = DT.TaskState.Offline, DateTime = DateTime.Now }); 227 227 job.JobId = he.Id; 228 job.Id = dao.Add Job(job);228 job.Id = dao.AddTask(job); 229 229 230 230 DT.JobPermission perm = new DT.JobPermission(); … … 233 233 perm.GrantedUserId = Guid.NewGuid(); 234 234 perm.Permission = DT.Permission.Full; 235 dao.Add HiveExperimentPermission(perm);236 237 DT.Job heLoaded = dao.Get HiveExperiment(he.Id);235 dao.AddJobPermission(perm); 236 237 DT.Job heLoaded = dao.GetJob(he.Id); 238 238 Assert.AreEqual(he.Id, heLoaded.Id); 239 239 Assert.AreEqual(he.Name, heLoaded.Name); 240 240 Assert.AreEqual(he.ResourceNames, heLoaded.ResourceNames); 241 //Assert.AreEqual( he.LastAccessed, heLoaded.LastAccessed);242 //Assert.AreEqual( he.DateCreated, heLoaded.DateCreated);243 244 DT.Task jobLoaded = dao.Get Job(job.Id);241 //Assert.AreEqual(job.LastAccessed, heLoaded.LastAccessed); 242 //Assert.AreEqual(job.DateCreated, heLoaded.DateCreated); 243 244 DT.Task jobLoaded = dao.GetTask(job.Id); 245 245 Assert.AreEqual(job.Id, jobLoaded.Id); 246 246 Assert.AreEqual(job.State, jobLoaded.State); 247 247 Assert.AreEqual(job.JobId, jobLoaded.JobId); 248 248 249 DT.JobPermission permLoaded = dao.Get HiveExperimentPermission(he.Id, perm.GrantedUserId);249 DT.JobPermission permLoaded = dao.GetJobPermission(he.Id, perm.GrantedUserId); 250 250 Assert.AreEqual(perm.JobId, permLoaded.JobId); 251 251 Assert.AreEqual(perm.GrantedUserId, permLoaded.GrantedUserId); … … 253 253 Assert.AreEqual(perm.Permission, permLoaded.Permission); 254 254 255 dao.Delete HiveExperiment(he.Id);256 Assert.AreEqual(null, dao.Get HiveExperiment(he.Id));257 Assert.AreEqual(null, dao.Get Job(job.Id));258 Assert.AreEqual(null, dao.Get HiveExperimentPermission(perm.JobId, perm.GrantedUserId));255 dao.DeleteJob(he.Id); 256 Assert.AreEqual(null, dao.GetJob(he.Id)); 257 Assert.AreEqual(null, dao.GetTask(job.Id)); 258 Assert.AreEqual(null, dao.GetJobPermission(perm.JobId, perm.GrantedUserId)); 259 259 260 260 } -
branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Services.Hive.Tests/HeuristicLab.Services.Hive.Tests-3.3.csproj
r6717 r6743 85 85 <SubType>Designer</SubType> 86 86 </None> 87 <Shadow Include="Test References\HeuristicLab.Services.Hive-3. 4.accessor" />87 <Shadow Include="Test References\HeuristicLab.Services.Hive-3.3.accessor" /> 88 88 </ItemGroup> 89 89 <ItemGroup /> -
branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Services.Hive.Tests/Mocks/MockAuthorizationManager.cs
r6717 r6743 28 28 } 29 29 30 public void AuthorizeFor Job(Guid jobId, DataTransfer.Permission requiredPermission) {30 public void AuthorizeForTask(Guid jobId, DataTransfer.Permission requiredPermission) { 31 31 // ok. 32 32 } 33 33 34 public void AuthorizeFor Experiment(Guid experimentId, DataTransfer.Permission requiredPermission) {34 public void AuthorizeForJob(Guid experimentId, DataTransfer.Permission requiredPermission) { 35 35 // ok. 36 36 } -
branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Services.Hive.Tests/ServiceTests.cs
r6725 r6743 98 98 99 99 // add hive experiment 100 experiment.Id = service.Add HiveExperiment(experiment);100 experiment.Id = service.AddJob(experiment); 101 101 102 102 // add task 103 103 job.JobId = experiment.Id; 104 job.Id = service.Add Job(job, jobData, new List<Guid> { slave.Id });104 job.Id = service.AddTask(job, jobData, new List<Guid> { slave.Id }); 105 105 106 106 // test task 107 DT.Task jobLoaded = service.Get Job(job.Id);107 DT.Task jobLoaded = service.GetTask(job.Id); 108 108 Assert.AreEqual(job.Id, jobLoaded.Id); 109 109 Assert.AreEqual(job.CoresNeeded, jobLoaded.CoresNeeded); … … 114 114 Assert.AreEqual(job.JobId, jobLoaded.JobId); 115 115 116 DT.TaskData jobDataLoaded = service.Get JobData(job.Id);116 DT.TaskData jobDataLoaded = service.GetTaskData(job.Id); 117 117 Assert.AreEqual(job.Id, jobDataLoaded.TaskId); 118 118 Assert.IsTrue(jobData.Data.SequenceEqual(jobDataLoaded.Data)); 119 119 120 120 // test hive experiment 121 DT.Job experimentLoaded = service.Get HiveExperiment(experiment.Id);121 DT.Job experimentLoaded = service.GetJob(experiment.Id); 122 122 Assert.AreEqual(experiment.Id, experimentLoaded.Id); 123 123 Assert.AreEqual(experiment.Name, experimentLoaded.Name); … … 130 130 Assert.AreEqual(job.Id, actions[0].TaskId); 131 131 132 jobLoaded = service.Get Job(job.Id);132 jobLoaded = service.GetTask(job.Id); 133 133 Assert.AreEqual(TaskState.Transferring, jobLoaded.State); 134 134 135 135 // slave is responsible for updating state to 'Calculating' 136 service.Update JobState(jobLoaded.Id, DT.TaskState.Calculating, slave.Id, null, null);136 service.UpdateTaskState(jobLoaded.Id, DT.TaskState.Calculating, slave.Id, null, null); 137 137 138 138 // send progress … … 143 143 144 144 // the task should be in state 'Calculating' now 145 jobLoaded = service.Get Job(job.Id);145 jobLoaded = service.GetTask(job.Id); 146 146 Assert.AreEqual(TaskState.Calculating, jobLoaded.State); 147 147 Assert.AreEqual(new TimeSpan(1, 5, 10, 20, 30), jobLoaded.ExecutionTime); 148 148 149 149 // test if the task is returned for the resource 150 var jobsBySlave = service.Get JobsByResourceId(slave.Id);150 var jobsBySlave = service.GetTasksByResourceId(slave.Id); 151 151 Assert.AreEqual(1, jobsBySlave.Count()); 152 152 Assert.AreEqual(job.Id, jobsBySlave.Single().Id); 153 153 154 154 // set it to finished 155 service.Update JobState(jobLoaded.Id, DT.TaskState.Finished, slave.Id, null, null);155 service.UpdateTaskState(jobLoaded.Id, DT.TaskState.Finished, slave.Id, null, null); 156 156 157 157 // test if the task is returned for the resource (it should not be) 158 var jobsBySlave2 = service.Get JobsByResourceId(slave.Id);158 var jobsBySlave2 = service.GetTasksByResourceId(slave.Id); 159 159 Assert.AreEqual(0, jobsBySlave2.Count()); 160 160 161 161 // set task waiting again 162 service.Update JobState(job.Id, DT.TaskState.Waiting, null, null, string.Empty);162 service.UpdateTaskState(job.Id, DT.TaskState.Waiting, null, null, string.Empty); 163 163 164 164 // get task again … … 181 181 182 182 // delete 183 service.Delete HiveExperiment(experiment.Id);184 Assert.AreEqual(null, service.Get HiveExperiment(experiment.Id));185 Assert.AreEqual(null, service.Get Job(job.Id));186 Assert.AreEqual(null, service.Get JobData(job.Id));183 service.DeleteJob(experiment.Id); 184 Assert.AreEqual(null, service.GetJob(experiment.Id)); 185 Assert.AreEqual(null, service.GetTask(job.Id)); 186 Assert.AreEqual(null, service.GetTaskData(job.Id)); 187 187 188 188 // send another heartbeat with the deleted task; the server should command the abortion of the task … … 241 241 242 242 // add hive experiment 243 experiment.Id = service.Add HiveExperiment(experiment);243 experiment.Id = service.AddJob(experiment); 244 244 245 245 // add parent task 246 246 parentJob.JobId = experiment.Id; 247 parentJob.Id = service.Add Job(parentJob, parentJobData, new List<Guid> { slave.Id });247 parentJob.Id = service.AddTask(parentJob, parentJobData, new List<Guid> { slave.Id }); 248 248 249 249 // add child task 250 250 childJob.JobId = experiment.Id; 251 childJob.Id = service.AddChild Job(parentJob.Id, childJob, childJobData);251 childJob.Id = service.AddChildTask(parentJob.Id, childJob, childJobData); 252 252 childJob.ParentTaskId = parentJob.Id; 253 253 254 254 // test child task 255 var childJobLoaded = service.Get Job(childJob.Id);255 var childJobLoaded = service.GetTask(childJob.Id); 256 256 Assert.AreEqual(childJob.ParentTaskId, childJobLoaded.ParentTaskId); 257 257 Assert.AreEqual(childJob.JobId, childJobLoaded.JobId); … … 261 261 262 262 // test parent task 263 var parentJobLoaded = service.Get Job(parentJob.Id);263 var parentJobLoaded = service.GetTask(parentJob.Id); 264 264 Assert.AreEqual(parentJob.JobId, parentJobLoaded.JobId); 265 265 Assert.AreEqual(TaskState.Waiting, parentJobLoaded.State); … … 276 276 service.TriggerEventManager(true); 277 277 278 parentJobLoaded = service.Get Job(parentJob.Id);278 parentJobLoaded = service.GetTask(parentJob.Id); 279 279 Assert.AreEqual(TaskState.Waiting, parentJobLoaded.State); 280 280 281 281 // set child task to finished 282 childJobLoaded = service.Update JobState(childJobLoaded.Id, DT.TaskState.Finished, slave.Id, null, null);282 childJobLoaded = service.UpdateTaskState(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 task to finished … … 286 286 287 287 // test if parent task is finished 288 parentJobLoaded = service.Get Job(parentJob.Id);288 parentJobLoaded = service.GetTask(parentJob.Id); 289 289 Assert.AreEqual(TaskState.Finished, parentJobLoaded.State); 290 290 291 291 // delete experiment 292 service.Delete HiveExperiment(experiment.Id);293 Assert.AreEqual(null, service.Get Job(parentJob.Id));294 Assert.AreEqual(null, service.Get Job(childJob.Id));292 service.DeleteJob(experiment.Id); 293 Assert.AreEqual(null, service.GetTask(parentJob.Id)); 294 Assert.AreEqual(null, service.GetTask(childJob.Id)); 295 295 296 296 service.DeleteSlave(slave.Id); … … 305 305 // create hive experiment 306 306 DT.Job e1 = new DT.Job() { Name = "TestExperiment", Description = "" }; 307 e1.Id = service.Add HiveExperiment(e1);308 309 var e1loaded = service.Get HiveExperiment(e1.Id);307 e1.Id = service.AddJob(e1); 308 309 var e1loaded = service.GetJob(e1.Id); 310 310 Assert.AreEqual(Permission.Full, e1loaded.Permission); 311 var allExp = service.Get HiveExperiments();311 var allExp = service.GetJobs(); 312 312 Assert.AreEqual(1, allExp.Count(x => x.Id == e1.Id)); 313 313 … … 315 315 mockServiceLocator.SetCurrentUserId(MockUserManager.MockUserId2); 316 316 try { 317 e1loaded = service.Get HiveExperiment(e1.Id);317 e1loaded = service.GetJob(e1.Id); 318 318 Assert.Fail("Access should not be possible"); 319 319 } 320 320 catch { /* ok, cool */ } 321 allExp = service.Get HiveExperiments();321 allExp = service.GetJobs(); 322 322 Assert.AreEqual(0, allExp.Count(x => x.Id == e1.Id)); 323 323 … … 335 335 // back to user2 336 336 mockServiceLocator.SetCurrentUserId(MockUserManager.MockUserId2); 337 e1loaded = service.Get HiveExperiment(e1.Id);337 e1loaded = service.GetJob(e1.Id); 338 338 Assert.AreEqual(Permission.Read, e1loaded.Permission); 339 allExp = service.Get HiveExperiments();339 allExp = service.GetJobs(); 340 340 Assert.AreEqual(1, allExp.Count(x => x.Id == e1.Id)); 341 341 … … 353 353 // back to user2 354 354 mockServiceLocator.SetCurrentUserId(MockUserManager.MockUserId2); 355 e1loaded = service.Get HiveExperiment(e1.Id);355 e1loaded = service.GetJob(e1.Id); 356 356 Assert.AreEqual(Permission.Full, e1loaded.Permission); 357 allExp = service.Get HiveExperiments();357 allExp = service.GetJobs(); 358 358 Assert.AreEqual(1, allExp.Count(x => x.Id == e1.Id)); 359 359 … … 368 368 mockServiceLocator.SetCurrentUserId(MockUserManager.MockUserId2); 369 369 try { 370 e1loaded = service.Get HiveExperiment(e1.Id);370 e1loaded = service.GetJob(e1.Id); 371 371 Assert.Fail("Access should not be possible"); 372 372 } 373 373 catch { /* ok, cool */ } 374 allExp = service.Get HiveExperiments();374 allExp = service.GetJobs(); 375 375 Assert.AreEqual(0, allExp.Count(x => x.Id == e1.Id)); 376 376 377 377 // back to user1 378 378 mockServiceLocator.SetCurrentUserId(MockUserManager.MockUserId1); 379 service.Delete HiveExperiment(e1.Id);379 service.DeleteJob(e1.Id); 380 380 } 381 381 }
Note: See TracChangeset
for help on using the changeset viewer.