public void Test_EmptyJob() { var agentId = Guid.NewGuid(); var agentFriendlyName = "TestAgent1"; var jobDescription = new JobDescription { Id = Guid.NewGuid(), FriendlyName = "P.PRO TEST JOB", CommandArray = new [] { new JobCommandDescription { PrepareCommand = "", RunCommand = "", CleanUpCommand = "", } } }; var jobInstance = new JobInstance { AgentId = agentId, CurrentState = JobInstance.State.NotYetStarted, Id = Guid.NewGuid(), JobDescriptionId = jobDescription.Id }; var restProxy = new RestProxy("http://localhost:26679/testing/"); restProxy.Create(jobDescription).Wait(); restProxy.Create(jobInstance).Wait(); new Daemon(agentId, agentFriendlyName, restProxy).Run(1); Thread.Sleep(1000); var jobInstanceAfter = restProxy.Get<JobInstance>(jobInstance.Id).Result; Assert.AreEqual(jobInstance.JobDescriptionId, jobInstanceAfter.JobDescriptionId); Assert.AreEqual(jobInstance.ResultDestination, jobInstanceAfter.ResultDestination); Assert.AreEqual(jobInstance.AgentId, jobInstanceAfter.AgentId); Assert.AreEqual(JobInstance.State.Finished, jobInstanceAfter.CurrentState); }
private static bool AgentMatchesJobRequirements(Agent agent, JobDescription jobDescription) { var match = jobDescription.AgentMatch ?? new Dictionary<string, string>(); foreach (var matching in match) { switch (matching.Key) { case Constants.FriendlyName: if (agent.FriendlyName != matching.Value) return false; break; case Constants.Id: { Guid matchId; if (!Guid.TryParse(matching.Key, out matchId)) return false; if (agent.Id != matchId) return false; } break; default: if (agent.MachineDescription[matching.Key] != matching.Value) return false; break; } } return true; }