-
Notifications
You must be signed in to change notification settings - Fork 5
Unit Tests
The arrows represent dependencies between steps. There are no circular references as this will cause an endless loop. Besides circular references, any type of step inter-relation is possible.
Steps 2 and 3 will run parallel and step 4 will run once when 2 and 3 have completed.
public static List<Step> CreateTestWorkflow_SimpleSteps()
{
// create 4 steps from step 1
List<Step> steps = WorkflowManager.CreateSteps(4, 1, "{default_post_url}");
steps.StepNumber(1).AddSubSteps(steps.StepNumber(2), steps.StepNumber(3));
steps.StepNumber(4).AddParentSteps(steps.StepNumber(2), steps.StepNumber(3));
return steps;
}
This workflow is complex because it contains steps that are both parents and siblings to other steps. Steps 5 and 6 has the same parent, step 2. So 5 and 6 are siblings, and step 5 is also the parent of its sibling step 6. Also note: Steps 2 and 3 are siblings, and step 5 is the child of step 2 and also the parent of step 3. So a step can be a parent of its uncle/aunt step.
public static List<Step> CreateTestWorkflow_Complex1()
{
// create 8 steps from step 1
List<Step> steps = WorkflowManager.CreateSteps(8, 1, "{default_post_url}");
steps.StepNumber(1).AddSubSteps(steps.StepNumber(2), steps.StepNumber(3), steps.StepNumber(4));
steps.StepNumber(2).AddSubSteps(steps.StepNumber(5), steps.StepNumber(6));
steps.StepNumber(3).AddSubSteps(steps.StepNumber(6), steps.StepNumber(7));
steps.StepNumber(4).AddSubSteps(steps.StepNumber(6), steps.StepNumber(8));
steps.StepNumber(5).AddSubSteps(steps.StepNumber(3), steps.StepNumber(6));
steps.StepNumber(6).AddSubSteps(steps.StepNumber(8));
steps.StepNumber(7).AddSubSteps(steps.StepNumber(8));
return steps;
}
Test that scalegroups are working by running a workflow that will run 10 steps in parallel.
Create a workflow with parent step 1, two child steps 2 and 3, 2 with five children and 3 with five children, and step 14 as the child of the ten children of 2 and 3.
This test will prove that the 10 steps (4 - 13), that can run in parallel, will run parallel because the scale group max instance count is set to 10.
graph TD;
1((1)) --> 2((2));
1((1)) --> 3((3));
2((2)) --> 4((4));
2((2))--> 5((5));
2((2)) --> 6((6));
2((2)) --> 7((7));
2((2)) --> 8((8));
3((3)) --> 9((9));
3((3)) --> 10((10));
3((3)) --> 11((11));
3((3)) --> 12((12));
3((3)) --> 13((13));
4 --> 14((14));
5 --> 14((14));
6 --> 14((14));
7 --> 14((14));
8 --> 14((14));
9 --> 14((14));
10 --> 14((14));
11 --> 14((14));
12 --> 14((14));
13 --> 14((14));
public static List<Step> CreateTestWorkflow_10StepsParallel()
{
List<Step> steps = WorkflowManager.CreateSteps(14, 1, "{default_post_url}");
steps.StepNumber(1).AddSubSteps(steps.StepNumber(2), steps.StepNumber(3));
steps.StepNumber(2).AddSubSteps(steps.StepNumber(4), steps.StepNumber(5), steps.StepNumber(6), steps.StepNumber(7), steps.StepNumber(8));
steps.StepNumber(3).AddSubSteps(steps.StepNumber(9), steps.StepNumber(10), steps.StepNumber(11), steps.StepNumber(12), steps.StepNumber(13));
// 2 groups of 5 parallel steps = 10 parallel steps
steps.StepNumber(14).AddParentSteps(steps.StepNumber(4), steps.StepNumber(5), steps.StepNumber(6), steps.StepNumber(7), steps.StepNumber(8), steps.StepNumber(9), steps.StepNumber(10), steps.StepNumber(11), steps.StepNumber(12), steps.StepNumber(13));
return steps;
}
This creates the same workflow that has 10 parallel steps as above in MaxInstanceCountForScaleGroupTo10, but now the scale group max instance count is set to 1. The 10 steps that ran in parallel in MaxInstanceCountForScaleGroupTo10, will now run only 1 at a time. This test proves that scale groups are working.