コード例 #1
0
        public async Task StopJobsRunningAsyncTest()
        {
            var jobTest     = new TestJob();
            var progress    = new SynchronousProgress <ProgressInfo>();
            var cancelToken = (new CancellationTokenSource()).Token;
            var pauseToken  = (new PauseTokenSource()).Token;
            var jobID       = await jobClient.AddAsync(AppID, () => jobTest.Start("Hello World", progress, cancelToken, pauseToken));

            //run job
            await jobServer.RunJobsAsync(new List <string> {
                jobID
            });

            Thread.Sleep(1000);

            var job = await jobClient.GetJobAsync(jobID);

            Assert.NotNull(job);
            Assert.Equal(JobStatus.Running, job.Status);

            await jobClient.SetCommandStopAsync(new List <string> {
                jobID
            });

            await jobServer.StopJobsAsync(); //stop running job

            Thread.Sleep(3000);

            job = await jobClient.GetJobAsync(jobID);

            await jobClient.DeleteJobsAsync(new List <string>() { jobID });

            Assert.Equal(JobStatus.Stopped, job.Status);
        }
コード例 #2
0
        public void CleanUpTest()
        {
            //Test StopJobs with CleanUp() calls

            var jobTest  = new TestJob();
            var progress = new SynchronousProgress <ProgressInfo>();
            var token    = (new CancellationTokenSource()).Token;
            var jobID    = jobClient.Add(appID, () => jobTest.Start("Hello World", progress, token));

            //run job
            jobServer.RunJobs(new List <string> {
                jobID
            });
            Thread.Sleep(1000);

            var job = jobClient.GetJob(jobID);

            Assert.IsNotNull(job);
            Assert.AreEqual(JobStatus.Running, job.Status);

            jobClient.SetCommandStop(new List <string> {
                jobID
            });
            jobServer.CleanUp();
            Thread.Sleep(3000);

            job = jobClient.GetJob(jobID);
            Assert.AreEqual(JobStatus.Stopped, job.Status);

            jobClient.DeleteJobs(new List <string>()
            {
                jobID
            });
        }
コード例 #3
0
ファイル: JobServerRedisTest.cs プロジェクト: lulzzz/Shift
        public void ContinueJobsPausedTest()
        {
            var jobTest     = new TestJob();
            var progress    = new SynchronousProgress <ProgressInfo>();
            var cancelToken = (new CancellationTokenSource()).Token;
            var pauseToken  = (new PauseTokenSource()).Token;
            var jobID       = jobClient.Add(AppID, () => jobTest.Start("Hello World", progress, cancelToken, pauseToken));

            //run job
            jobServer.RunJobs(new List <string> {
                jobID
            });
            Thread.Sleep(1000);

            jobClient.SetCommandPause(new List <string> {
                jobID
            });
            jobServer.PauseJobs(); //pause running job
            Thread.Sleep(3000);

            var job = jobClient.GetJob(jobID);

            Assert.NotNull(job);
            Assert.Equal(JobStatus.Paused, job.Status);

            jobClient.SetCommandContinue(new List <string> {
                jobID
            });
            jobServer.ContinueJobs(); //continue paused job
            Thread.Sleep(3000);

            job = jobClient.GetJob(jobID);
            jobClient.SetCommandStop(new List <string> {
                jobID
            });
            jobServer.StopJobs();
            Thread.Sleep(3000);
            jobClient.DeleteJobs(new List <string>()
            {
                jobID
            });

            Assert.Equal(JobStatus.Running, job.Status);
        }