public void IfATaskIsMarkedFailed_WorfklowFailsAndNoMoreTasksSubmitted() { var db = _mux.GetDatabase(); db.ScriptEvaluate("print(\"IfATaskIsMarkedFailed_WorfklowFailsAndNoMoreTasksSubmitted\")"); db.ScriptEvaluate("redis.call(\"flushdb\")"); var th = new ErroringTestTaskHandler(2); var complete = new ManualResetEvent(false); var failed = new ManualResetEvent(false); var wh = new WorkflowHandler(); wh.WorkflowComplete += (s, w) => { complete.Set(); }; wh.WorkflowFailed += (s, w) => { failed.Set(); }; using (var wm = new WorkflowManagement(_mux, th, wh, new WorkflowManagementId("test"), null, new Lua())) { var t1 = new TaskName("TestNode1"); var t2 = new TaskName("TestNode2"); var t3 = new TaskName("TestNode3"); var t4 = new TaskName("TestNode4"); var workflow = new Workflow(new WorkflowName("TestWorkflow")); workflow.AddTask(t1, new Payload("Node1"), NoType, SimplePriority, EmptyTaskList, new[] { t2 }); workflow.AddTask(t2, new Payload("Node2"), NoType, SimplePriority, new[] { t1 }, new[] { t3, t4 }); workflow.AddTask(t3, new Payload("Node3"), NoType, SimplePriority, new[] { t2 }, EmptyTaskList); workflow.AddTask(t4, new Payload("Node4"), NoType, SimplePriority, new[] { t2 }, EmptyTaskList); wm.PushWorkflow(workflow); var result = WaitHandle.WaitAny(new[] { failed, complete }, 2000); Assert.AreEqual(0, result); Assert.AreEqual(2, th.TaskRunCount); // only 2 get sent through the task handler; second fails, so no children are executed } }
public void IfATaskIsMarkedFailed_WorfklowFailsAndNoMoreTasksSubmitted() { var db = _mux.GetDatabase(); db.ScriptEvaluate("print(\"IfATaskIsMarkedFailed_WorfklowFailsAndNoMoreTasksSubmitted\")"); db.ScriptEvaluate("redis.call(\"flushdb\")"); var th = new ErroringTestTaskHandler(2); var complete = new ManualResetEvent(false); var failed = new ManualResetEvent(false); var wh = new WorkflowHandler(); wh.WorkflowComplete += (s, w) => { complete.Set(); }; wh.WorkflowFailed += (s, w) => { failed.Set(); }; using (var wm = new WorkflowManagement(_mux, th, wh, "test", null, new Lua())) { var workflowName = "TestWorkflow"; var tasks = new List<Task>(); tasks.Add(new Task { Type = "", Name = "TestNode1", Payload = "Node1", Parents = new string[] { }, Children = new string[] { "TestNode2" }, Workflow = workflowName }); tasks.Add(new Task { Type = "", Name = "TestNode2", Payload = "Node2", Parents = new string[] { "TestNode1" }, Children = new string[] { "TestNode3", "TestNode4" }, Workflow = workflowName }); tasks.Add(new Task { Type = "", Name = "TestNode3", Payload = "Node3", Parents = new string[] { "TestNode2" }, Children = new string[] { }, Workflow = workflowName }); tasks.Add(new Task { Type = "", Name = "TestNode4", Payload = "Node4", Parents = new string[] { "TestNode2" }, Children = new string[] { }, Workflow = workflowName }); var workflow = new Workflow { Name = workflowName, Tasks = tasks }; wm.PushWorkflow(workflow); var result = WaitHandle.WaitAny(new[] { failed, complete }, 2000); Assert.AreEqual(0, result); Assert.AreEqual(2, th.TaskRunCount); // only 2 get sent through the task handler; second fails, so no children are executed } }