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 e88de548c7..1d28727aff 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 @@ -1637,6 +1637,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 b1105950df..8ea7beb876 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();