diff --git a/core/src/main/java/com/netflix/conductor/core/execution/WorkflowExecutor.java b/core/src/main/java/com/netflix/conductor/core/execution/WorkflowExecutor.java index 4012c1e57b..d42101a5c1 100644 --- a/core/src/main/java/com/netflix/conductor/core/execution/WorkflowExecutor.java +++ b/core/src/main/java/com/netflix/conductor/core/execution/WorkflowExecutor.java @@ -1638,6 +1638,7 @@ private boolean rerunWF(String workflowId, String taskId, Map 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 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()); diff --git a/core/src/test/java/com/netflix/conductor/core/execution/TestWorkflowExecutor.java b/core/src/test/java/com/netflix/conductor/core/execution/TestWorkflowExecutor.java index d78d8eb7ab..7f9e1bffab 100644 --- a/core/src/test/java/com/netflix/conductor/core/execution/TestWorkflowExecutor.java +++ b/core/src/test/java/com/netflix/conductor/core/execution/TestWorkflowExecutor.java @@ -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() {{ + put("TEST", "domain1"); + }}); + Task loopTask = mock(Task.class); + WorkflowTask loopWfTask = mock(WorkflowTask.class); + when(loopTask.getWorkflowTask()).thenReturn(loopWfTask); + List loopOver = new ArrayList(){{ + 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();