public void ShouldBeAbleToRunJobWithSpecifiedStepNumber() { string name = MethodBase.GetCurrentMethod().Name; TestWorker.ValueToCheck = false; StepTestWorker.ValueToCheck = false; JobConductorService jc = GetTestJobConductor(name); string jobName = "Job_" + name; jc.AddWorker(typeof(TestWorker).AssemblyQualifiedName, "TestWorker", jobName); jc.AddWorker(typeof(StepTestWorker).AssemblyQualifiedName, "StepTestWorker", jobName); Expect.IsFalse(TestWorker.ValueToCheck); Expect.IsFalse(StepTestWorker.ValueToCheck); bool? finished = false; AutoResetEvent signal = new AutoResetEvent(false); jc.JobFinished += (o, a) => { Expect.IsFalse(TestWorker.ValueToCheck, "testworker value should have been false after job finished"); Expect.IsTrue(StepTestWorker.ValueToCheck, "Step test worker value should have been true after job finished"); finished = true; signal.Set(); }; JobConf conf = jc.GetJob(jobName); jc.RunJob(conf.CreateJob(), 1); signal.WaitOne(10000); Expect.IsTrue(finished.Value, "finished value should have been set"); }
public void JobConfShouldCreateValidJob() { DirectoryInfo dir = new DirectoryInfo(".\\{0}"._Format(MethodBase.GetCurrentMethod().Name)); if (dir.Exists) { dir.Delete(true); } JobConf jobConf = new JobConf(); jobConf.JobDirectory = dir.FullName; GitGetSourceWorker worker = new GitGetSourceWorker("monkey"); jobConf.AddWorker(worker); string filePath = jobConf.Save(); JobConf check = JobConf.Load(filePath); Job job = check.CreateJob(); IWorker checkWork = job["monkey"]; Expect.IsNotNull(checkWork); Expect.AreEqual(typeof(GitGetSourceWorker), checkWork.GetType()); GitGetSourceWorker checkWorker = job.GetWorker <GitGetSourceWorker>("monkey"); Expect.AreEqual("Git", checkWorker.SourceControlType); }
protected internal void EnqueueJob(JobConf conf, int stepNumber = 0) { Args.ThrowIfNull(conf, "JobConf"); lock (_jobQueueLock) { if (!_isRunning) { StartJobRunnerThread(); } Job job = conf.CreateJob(); job.StepNumber = stepNumber; JobQueue.Enqueue(job); _enqueueSignal.Set(); } }
public void AfterAddWorkerCreateJobShouldHaveCorrectWorkers() { string name = MethodBase.GetCurrentMethod().Name; JobConductorService fm = GetTestJobConductor(name); string jobName = "Job_" + name; fm.AddWorker(typeof(TestWorker).AssemblyQualifiedName, "one", jobName); fm.AddWorker(typeof(TestWorker).AssemblyQualifiedName, "two", jobName); JobConf conf = fm.GetJob(jobName); Job job = conf.CreateJob(); Expect.IsTrue(job.WorkerNames.Length == 2); Expect.IsNotNull(job["one"]); Expect.IsNotNull(job["two"]); Expect.AreEqual("one", job["one"].Name); Expect.AreEqual("two", job["two"].Name); }