public void ShouldBeAbleToRunJobWithSpecifiedStepNumber() { string name = MethodBase.GetCurrentMethod().Name; TestWorker.ValueToCheck = false; StepTestWorker.ValueToCheck = false; JobManagerService jc = GetTestJobConductor(name); string jobName = "Job_" + name; jc.AddWorker(jobName, typeof(TestWorker).AssemblyQualifiedName, "TestWorker"); jc.AddWorker(jobName, typeof(StepTestWorker).AssemblyQualifiedName, "StepTestWorker"); 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 AfterAddWorkerCreateJobShouldHaveCorrectWorkers() { string name = MethodBase.GetCurrentMethod().Name; JobManagerService jc = GetTestJobConductor(name); string jobName = "Job_" + name; jc.AddWorker(jobName, typeof(TestWorker).AssemblyQualifiedName, "one"); jc.AddWorker(jobName, typeof(TestWorker).AssemblyQualifiedName, "two"); JobConf conf = jc.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); }
public void AddWorkerShouldSetWorkerName() { string name = MethodBase.GetCurrentMethod().Name; JobManagerService jc = GetTestJobConductor(name); string workerName = "worker_" + name; string jobName = "Job_" + name; jc.AddWorker(jobName, typeof(TestWorker).AssemblyQualifiedName, workerName); Expect.IsTrue(jc.WorkerExists(jobName, workerName)); }
public void AddWorkerShouldCreateJob() { string name = MethodBase.GetCurrentMethod().Name; JobManagerService jc = GetTestJobConductor(name); string jobName = "Job_".RandomLetters(4); Expect.IsFalse(jc.JobExists(jobName)); jc.AddWorker(jobName, typeof(TestWorker).AssemblyQualifiedName, "worker"); Expect.IsTrue(jc.JobExists(jobName)); }
public void AddWorkerShouldThrowArgumentNullException() { string name = MethodBase.GetCurrentMethod().Name; JobManagerService jc = GetTestJobConductor(name); Expect.Throws(() => { jc.AddWorker("JobName", "noTypeByThisNameShouldBeFound".RandomLetters(4), "work_" + name); }, (ex) => { ex.IsInstanceOfType <ArgumentNullException>("Exception wasn't the right type"); }, "Should have thrown an exception but didn't"); }
public override void Add(Action <string> output = null, Action <string> error = null) { try { PrintMessage(); JobProviderArguments providerArguments = GetProviderArguments(true, true) as JobProviderArguments; string workerName = providerArguments.WorkerName; string jobName = providerArguments.JobName; JobConf jobConf = GetJobConf(jobName); string[] workerTypeNames = JobManagerService.GetWorkerTypes(); int workerType = SelectFrom(workerTypeNames, "Please select a worker type"); JobManagerService.AddWorker(jobName, workerTypeNames[workerType], workerName); Message.PrintLine("Added worker {0} to job {1}", ConsoleColor.Cyan, workerName, jobName); Exit(0); } catch (Exception ex) { Message.PrintLine("Error adding worker: {0}", ConsoleColor.Magenta, ex.Message); Exit(1); } }