Skip to content

Commit

Permalink
Preserve task domains for tasks inside do_while loop
Browse files Browse the repository at this point in the history
On every iteration, apply task domains as set in the workflow execution.
This feature was missing and made do wile behave incorrectly when using
task domains (since the domains were reset for tasks inside the loop)

Signed-off-by: Maros Marsalek <mmarsalek@frinx.io>
  • Loading branch information
marosmars committed Oct 28, 2020
1 parent b51ce0a commit f25c196
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1638,6 +1638,7 @@ private boolean rerunWF(String workflowId, String taskId, Map<String, Object> ta
public void scheduleNextIteration(Task loopTask, Workflow workflow) {
//Schedule only first loop over task. Rest will be taken care in Decider Service when this task will get completed.
List<Task> scheduledLoopOverTasks = deciderService.getTasksToBeScheduled(workflow, loopTask.getWorkflowTask().getLoopOver().get(0), loopTask.getRetryCount(), null);
setTaskDomains(scheduledLoopOverTasks, workflow);
scheduledLoopOverTasks.stream().forEach(t -> {
t.setReferenceTaskName(TaskUtils.appendIteration(t.getReferenceTaskName(), loopTask.getIteration()));
t.setIteration(loopTask.getIteration());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1469,6 +1469,29 @@ public void testStartWorkflow() {
verify(executionDAOFacade, times(1)).createWorkflow(any(Workflow.class));
}

@Test
public void testScheduleNextIteration() {
Workflow workflow = generateSampleWorkflow();
workflow.setTaskToDomain(new HashMap<String, String>() {{
put("TEST", "domain1");
}});
Task loopTask = mock(Task.class);
WorkflowTask loopWfTask = mock(WorkflowTask.class);
when(loopTask.getWorkflowTask()).thenReturn(loopWfTask);
List<WorkflowTask> loopOver = new ArrayList<WorkflowTask>(){{
WorkflowTask e = new WorkflowTask();
e.setType(TaskType.TASK_TYPE_SIMPLE);
e.setName("TEST");
e.setTaskDefinition(new TaskDef());
add(e);
}};
when(loopWfTask.getLoopOver()).thenReturn(loopOver);

workflowExecutor.scheduleNextIteration(loopTask, workflow);

verify(executionDAOFacade).getTaskPollDataByDomain("TEST", "domain1");
}

private Workflow generateSampleWorkflow() {
//setup
Workflow workflow = new Workflow();
Expand Down

0 comments on commit f25c196

Please sign in to comment.