コード例 #1
0
        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");
        }
コード例 #2
0
        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);
        }
コード例 #3
0
        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));
        }
コード例 #4
0
        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));
        }
コード例 #5
0
        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");
        }
コード例 #6
0
        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);
            }
        }