public void RetryPluginTest() { var oldJob = CreateRetryJob(2); var job = oldJob; JobRepository.Add(job); Assert.That(JobRepository.WaitingJobs().Count(), Is.EqualTo(1)); var maxiumJobFinishTime = TimeProvider.GetUtcNow().AddMinutes(5); while ((JobRepository.WaitingJobs().Any() || JobRepository.ActiveJobs().Any()) && TimeProvider.GetUtcNow() < maxiumJobFinishTime) { MockCallbackService.Verify(m => m.MakeCallback(It.IsAny <Job>()), Times.Never, "MakeCallback should not be called yet."); Executor.Pulse(); TimeProvider.Step(TimeSpan.FromSeconds(5)); } Assert.That(TimeProvider.GetUtcNow() < maxiumJobFinishTime, "Must finish the jobs before the time limit."); retryPlugin.Verify(m => m.Assign(It.IsAny <ExecutionTask>()), Times.Once); retryPlugin.Verify(m => m.Retry(It.IsAny <ExecutionTask>()), Times.Exactly(2)); Assert.That(JobRepository.WaitingJobs().Count(), Is.EqualTo(0)); Assert.That(JobRepository.ActiveJobs().Count(), Is.EqualTo(0)); Assert.That(JobRepository.FailedJobs().Count(), Is.EqualTo(0)); Assert.That(JobRepository.DoneJobs().Count(), Is.EqualTo(1)); job = JobRepository.Get(job.Urn); Assert.That(job.Plan.Tasks.FirstOrDefault(t => t.PluginUrn == RetryPluginUrn).NumberOfRetries, Is.GreaterThan(0)); }
public void OneJob() { var oldJob = CreateNewJob(); var job = oldJob; JobRepository.Add(job); Assert.That(JobRepository.WaitingJobs().Count(), Is.EqualTo(1)); var maxiumJobFinishTime = TimeProvider.GetUtcNow().AddMinutes(5); while ((JobRepository.WaitingJobs().Any() || JobRepository.ActiveJobs().Any()) && TimeProvider.GetUtcNow() < maxiumJobFinishTime) { MockCallbackService.Verify(m => m.MakeCallback(It.IsAny <Job>()), Times.Never, "MakeCallback should not be called yet."); Executor.Pulse(); TimeProvider.Step(TimeSpan.FromSeconds(5)); } MockCallbackService.Verify(m => m.MakeCallback(It.IsAny <Job>()), Times.Once, "MakeCallback have not been called once."); Assert.That(TimeProvider.GetUtcNow() < maxiumJobFinishTime, "Most finish the jobs before the time limit."); Assert.That(JobRepository.WaitingJobs().Count(), Is.EqualTo(0)); Assert.That(JobRepository.ActiveJobs().Count(), Is.EqualTo(0)); Assert.That(JobRepository.DoneJobs().Count(), Is.EqualTo(1)); job = JobRepository.Get(job.Urn); var flags = job.Plan.GetCurrentEssence().Flags; Assert.That((bool)(flags.HasFlag(StateFlags.HardSubtitles) && flags.HasFlag(StateFlags.Logo))); Assert.That(job.Destination.Files.Count, Is.EqualTo(3)); }