Exemple #1
0
        public async Task TestMutiLayerWithBuffer()
        {
            var context = new JobTrackerContext(_rawClient);
            var root    = await context.CreateNewJobAsync(new AddJobDto("TestMultiLayer"));

            var layer1Child1 = await context.CreateNewJobAsync(new AddJobDto("", root.JobId));

            var layer2Child1 = await context.CreateNewJobAsync(new AddJobDto("", layer1Child1.JobId));

            var layer2Child2 = await context.CreateNewJobAsync(new AddJobDto("", layer1Child1.JobId));

            var layer2Child3 = await context.CreateNewJobAsync(new AddJobDto("", layer1Child1.JobId));

            var layer1Child2 = await context.CreateNewJobAsync(new AddJobDto("", root.JobId));

            Console.WriteLine($"RootJobId {root.JobId}");

            await context.UpdateJobStatesAsync(root.JobId, new UpdateJobStateDto(JobState.RanToCompletion));

            await context.UpdateJobStatesAsync(layer1Child1.JobId, new UpdateJobStateDto(JobState.RanToCompletion));

            await context.UpdateJobStatesAsync(layer1Child2.JobId, new UpdateJobStateDto(JobState.RanToCompletion));

            await context.UpdateJobStatesAsync(layer2Child1.JobId, new UpdateJobStateDto(JobState.RanToCompletion));

            await context.CommitAndCloseAsync();

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

            Assert.AreEqual(JobState.WaitingForChildrenToComplete, root.CurrentJobState);
            await _rawClient.UpdateJobStatesAsync(layer2Child2.JobId, new UpdateJobStateDto(JobState.Faulted));

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

            Assert.AreEqual(JobState.WaitingForChildrenToComplete, root.CurrentJobState);
            await _rawClient.UpdateJobStatesAsync(layer2Child3.JobId, new UpdateJobStateDto(JobState.RanToCompletion));

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

            Assert.AreEqual(JobState.Faulted, root.CurrentJobState);
        }
        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);
        }