use of com.netflix.conductor.common.metadata.workflow.WorkflowDef in project conductor by Netflix.
the class WorkflowServiceTest method createWorkflowWithInlineSubWorkflow.
private WorkflowDef createWorkflowWithInlineSubWorkflow() {
WorkflowDef subWorkflowDef = createInlineSubWorkflow();
WorkflowTask subWfTask = new WorkflowTask();
subWfTask.setName("subWorkflowTask");
subWfTask.setType(SUB_WORKFLOW.name());
SubWorkflowParams swp = new SubWorkflowParams();
swp.setName("does-not-existing-wf");
swp.setWorkflowDefinition(subWorkflowDef);
subWfTask.setSubWorkflowParam(swp);
Map<String, Object> inputParam = new HashMap<>();
inputParam.put("test", "test value");
inputParam.put("param1", "sub workflow input param1");
inputParam.put("param2", subWorkflowDef.getVersion());
subWfTask.setInputParameters(inputParam);
subWfTask.setTaskReferenceName("sw1");
WorkflowDef main = new WorkflowDef();
main.setVersion(2);
main.setSchemaVersion(2);
main.setInputParameters(Arrays.asList("param1", "param2"));
main.setName(WF_WITH_INLINE_SUB_WF);
main.getTasks().add(subWfTask);
return main;
}
use of com.netflix.conductor.common.metadata.workflow.WorkflowDef in project conductor by Netflix.
the class WorkflowServiceTest method createWorkflowWithInlineSubWorkflowWithInlineSubWorkflow.
private void createWorkflowWithInlineSubWorkflowWithInlineSubWorkflow() {
WorkflowDef subWorkflowDef = createWorkflowWithInlineSubWorkflow();
WorkflowTask workflowTask = new WorkflowTask();
workflowTask.setName("subWorkflowTask");
workflowTask.setType(SUB_WORKFLOW.name());
SubWorkflowParams swp = new SubWorkflowParams();
swp.setName("dummy-name");
swp.setWorkflowDef(subWorkflowDef);
workflowTask.setSubWorkflowParam(swp);
Map<String, Object> input = new HashMap<>();
input.put("test", "test value");
input.put("param1", "sub workflow task input param1");
input.put("param2", 21);
workflowTask.setInputParameters(input);
workflowTask.setTaskReferenceName("sw2");
WorkflowDef main = new WorkflowDef();
main.setSchemaVersion(2);
main.setInputParameters(Arrays.asList("param1", "param2"));
main.setName(WF_WITH_INLINE_SUB_WF_WITH_INLINE_SUB_WF);
main.getTasks().add(workflowTask);
Map<String, Object> outputParameters = new HashMap<>();
outputParameters.put("o1", "${workflow.input.param1}");
outputParameters.put("o2", "${sw2.output.o2}");
main.setOutputParameters(outputParameters);
metadataService.updateWorkflowDef(Collections.singletonList(main));
}
use of com.netflix.conductor.common.metadata.workflow.WorkflowDef in project conductor by Netflix.
the class WorkflowServiceTest method createInlineSubWorkflow.
private WorkflowDef createInlineSubWorkflow() {
// create inline subworkflow
WorkflowDef subWorkflowDef = new WorkflowDef();
subWorkflowDef.setName("inline_sw_1");
subWorkflowDef.setDescription(subWorkflowDef.getName());
subWorkflowDef.setVersion(3);
subWorkflowDef.setSchemaVersion(2);
Map<String, Object> outputParameters = new HashMap<>();
outputParameters.put("o1", "${workflow.input.param1}");
outputParameters.put("o2", "${isw_t1.output.uuid}");
subWorkflowDef.setOutputParameters(outputParameters);
WorkflowTask wft1 = new WorkflowTask();
wft1.setName("junit_task_1");
wft1.setTaskReferenceName("isw_t1");
subWorkflowDef.setTasks(Collections.singletonList(wft1));
return subWorkflowDef;
}
use of com.netflix.conductor.common.metadata.workflow.WorkflowDef in project conductor by Netflix.
the class RedisMetadataDAOTest method testDup.
@Test(expected = ApplicationException.class)
public void testDup() {
WorkflowDef def = new WorkflowDef();
def.setName("testDup");
def.setVersion(1);
redisMetadataDAO.createWorkflowDef(def);
redisMetadataDAO.createWorkflowDef(def);
}
use of com.netflix.conductor.common.metadata.workflow.WorkflowDef in project conductor by Netflix.
the class AbstractWorkflowServiceTest method testRetry.
@Test
public void testRetry() {
String taskName = "junit_task_1";
TaskDef taskDef = notFoundSafeGetTaskDef(taskName);
int retryCount = taskDef.getRetryCount();
taskDef.setRetryCount(1);
int retryDelay = taskDef.getRetryDelaySeconds();
taskDef.setRetryDelaySeconds(0);
metadataService.updateTaskDef(taskDef);
WorkflowDef workflowDef = metadataService.getWorkflowDef(LINEAR_WORKFLOW_T1_T2, 1);
assertNotNull(workflowDef.getFailureWorkflow());
assertFalse(StringUtils.isBlank(workflowDef.getFailureWorkflow()));
String correlationId = "retry_test_" + UUID.randomUUID().toString();
Map<String, Object> input = new HashMap<>();
input.put("param1", "p1 value");
input.put("param2", "p2 value");
String workflowId = startOrLoadWorkflowExecution("retry", LINEAR_WORKFLOW_T1_T2, 1, correlationId, input, null, null);
assertNotNull(workflowId);
printTaskStatuses(workflowId, "initial");
Workflow workflow = workflowExecutionService.getExecutionStatus(workflowId, true);
assertEquals(RUNNING, workflow.getStatus());
assertEquals(1, workflow.getTasks().size());
Task task = getTask("junit_task_1");
assertNotNull(task);
task.setStatus(FAILED);
workflowExecutionService.updateTask(task);
workflow = workflowExecutionService.getExecutionStatus(workflowId, true);
assertNotNull(workflow);
assertEquals(RUNNING, workflow.getStatus());
assertEquals(2, workflow.getTasks().size());
task = getTask("junit_task_1");
assertNotNull(task);
task.setStatus(FAILED);
workflowExecutionService.updateTask(task);
workflow = workflowExecutionService.getExecutionStatus(workflowId, true);
assertNotNull(workflow);
assertEquals(WorkflowStatus.FAILED, workflow.getStatus());
assertEquals(2, workflow.getTasks().size());
printTaskStatuses(workflowId, "before retry");
workflowExecutor.retry(workflowId, false);
printTaskStatuses(workflowId, "after retry");
workflow = workflowExecutionService.getExecutionStatus(workflowId, true);
assertNotNull(workflow);
assertEquals(RUNNING, workflow.getStatus());
assertEquals(3, workflow.getTasks().size());
task = getTask("junit_task_1");
assertNotNull(task);
assertEquals(workflowId, task.getWorkflowInstanceId());
task.setStatus(COMPLETED);
workflowExecutionService.updateTask(task);
workflow = workflowExecutionService.getExecutionStatus(workflowId, true);
assertNotNull(workflow);
assertEquals(RUNNING, workflow.getStatus());
assertEquals(4, workflow.getTasks().size());
task = getTask("junit_task_2");
assertNotNull(task);
assertEquals(workflowId, task.getWorkflowInstanceId());
task.setStatus(COMPLETED);
workflowExecutionService.updateTask(task);
workflow = workflowExecutionService.getExecutionStatus(workflowId, true);
assertNotNull(workflow);
assertEquals(WorkflowStatus.COMPLETED, workflow.getStatus());
assertEquals(4, workflow.getTasks().size());
assertEquals(3, workflow.getTasks().stream().filter(t -> t.getTaskType().equals("junit_task_1")).count());
taskDef.setRetryCount(retryCount);
taskDef.setRetryDelaySeconds(retryDelay);
metadataService.updateTaskDef(taskDef);
printTaskStatuses(workflowId, "final");
}
Aggregations