예제 #1
0
        public async Task TestJobPersistAsync()
        {
            var context = new JobTrackerContext(_rawClient);
            var jobName = DateTime.Now.ToString(CultureInfo.InvariantCulture);
            var root    = await context.CreateNewJobAsync(new AddJobDto(jobName));

            await context.CommitAndCloseAsync();

            root = await _rawClient.GetJobEntityAsync(root.JobId);

            Assert.AreEqual(jobName, root.JobName);
        }
        public async Task TestChildrenTrigger()
        {
            var rootJob = await _client.CreateNewJobAsync(new AddJobDto { JobName = "RootJob" });

            Console.WriteLine($"RootJobId {rootJob.JobId}");
            await _client.UpdateJobStatesAsync(rootJob.JobId,
                                               new UpdateJobStateDto(JobState.Running, "rootJobRunning"));

            var child1 = await _client.CreateNewJobAsync(new AddJobDto("child1", rootJob.JobId));

            var child2 = await _client.CreateNewJobAsync(new AddJobDto("child2", rootJob.JobId));

            await _client.UpdateJobStatesAsync(rootJob.JobId,
                                               new UpdateJobStateDto(JobState.RanToCompletion, "rootJobFinished"));

            await _client.UpdateJobStatesAsync(rootJob.JobId,
                                               new UpdateJobStateDto(JobState.Running, "rootJobRunningAgain"));

            await _client.UpdateJobStatesAsync(rootJob.JobId,
                                               new UpdateJobStateDto(JobState.RanToCompletion, "rootJobFinished"));

            rootJob = await _client.GetJobEntityAsync(rootJob.JobId);

            Assert.AreEqual(JobState.WaitingForChildrenToComplete, rootJob.CurrentJobState);

            await _client.UpdateJobStatesAsync(child1.JobId, new UpdateJobStateDto(JobState.Warning, "child1 Running"));

            await _client.UpdateJobStatesAsync(child2.JobId, new UpdateJobStateDto(JobState.Running, "child2 Running"));

            await _client.UpdateJobStatesAsync(child1.JobId,
                                               new UpdateJobStateDto(JobState.RanToCompletion, "child1 finished"));

            await _client.UpdateJobStatesAsync(child2.JobId,
                                               new UpdateJobStateDto(JobState.RanToCompletion, "child2 finished"));

            child1 = await _client.GetJobEntityAsync(child1.JobId);

            child2 = await _client.GetJobEntityAsync(child2.JobId);

            rootJob = await _client.GetJobEntityAsync(rootJob.JobId);

            Assert.AreEqual(JobState.RanToCompletion, rootJob.CurrentJobState);
            Assert.AreEqual(JobState.RanToCompletion, child1.CurrentJobState);
            Assert.AreEqual(JobState.RanToCompletion, child2.CurrentJobState);
        }