From b30bf7f164bff8db980a5360aff5b55a0d76b926 Mon Sep 17 00:00:00 2001 From: Viren Baraiya Date: Tue, 28 Nov 2023 09:29:31 -0800 Subject: [PATCH] update version --- build.gradle | 2 +- .../client/e2e/DynamicForkOptionalTests.java | 94 ++++++++++++++++--- 2 files changed, 81 insertions(+), 15 deletions(-) diff --git a/build.gradle b/build.gradle index 4592131..0ca8296 100644 --- a/build.gradle +++ b/build.gradle @@ -15,7 +15,7 @@ ext { springBootVersion = '2.7.6' versions = [ - revConductor : '3.14.0', + revConductor : '3.15.0', revTestContainer : '1.17.2', revGuava : '32.0.0-jre', revLog4j : '2.17.1', diff --git a/test-harness/src/test/java/io/orkes/conductor/client/e2e/DynamicForkOptionalTests.java b/test-harness/src/test/java/io/orkes/conductor/client/e2e/DynamicForkOptionalTests.java index e353b01..7b2f085 100644 --- a/test-harness/src/test/java/io/orkes/conductor/client/e2e/DynamicForkOptionalTests.java +++ b/test-harness/src/test/java/io/orkes/conductor/client/e2e/DynamicForkOptionalTests.java @@ -12,9 +12,7 @@ */ package io.orkes.conductor.client.e2e; -import java.util.Arrays; -import java.util.HashMap; -import java.util.Map; +import java.util.*; import java.util.concurrent.TimeUnit; import org.junit.jupiter.api.Test; @@ -54,6 +52,7 @@ public void testTaskDynamicForkOptional() { startWorkflowRequest.setVersion(1); String workflowId = workflowClient.startWorkflow(startWorkflowRequest); + System.out.println("Started " + workflowId); Workflow workflow = workflowClient.getWorkflow(workflowId, true); TaskResult taskResult = new TaskResult(); @@ -61,20 +60,26 @@ public void testTaskDynamicForkOptional() { taskResult.setTaskId(workflow.getTasks().get(0).getTaskId()); taskResult.setStatus(TaskResult.Status.COMPLETED); - WorkflowTask workflowTask2 = new WorkflowTask(); - workflowTask2.setName("integration_task_2"); - workflowTask2.setTaskReferenceName("xdt1"); + List fanoutTasks = new ArrayList<>(); + Map> input = new HashMap<>(); + + for (int i = 0; i < 100; i++) { + WorkflowTask workflowTask = new WorkflowTask(); + workflowTask.setName("integration_task_2"); + workflowTask.setTaskReferenceName("xdt" + i); + workflowTask.setOptional(true); + fanoutTasks.add(workflowTask); + + input.put("xdt" + i, Map.of("k1", "v1")); + + } + + - WorkflowTask workflowTask3 = new WorkflowTask(); - workflowTask3.setName("integration_task_3"); - workflowTask3.setTaskReferenceName("xdt2"); - workflowTask3.setOptional(true); Map output = new HashMap<>(); - Map> input = new HashMap<>(); - input.put("xdt1", Map.of("k1", "v1")); - input.put("xdt2", Map.of("k2", "v2")); - output.put("dynamicTasks", Arrays.asList(workflowTask2, workflowTask3)); + + output.put("dynamicTasks", fanoutTasks); output.put("dynamicTasksInput", input); taskResult.setOutputData(output); taskClient.updateTask(taskResult); @@ -168,6 +173,67 @@ public void testTaskDynamicForkOptional() { metadataClient.unregisterWorkflowDef(workflowName1, 1); } + + @Test + public void testLargeFork() { + + String workflowName1 = "DynamicFanInOutTest"; + int count = 200; + + // Register workflow + registerWorkflowDef(workflowName1, metadataClient); + + // Trigger workflow + StartWorkflowRequest startWorkflowRequest = new StartWorkflowRequest(); + startWorkflowRequest.setName(workflowName1); + startWorkflowRequest.setVersion(1); + + String workflowId = workflowClient.startWorkflow(startWorkflowRequest); + System.out.println("Started " + workflowId); + + Workflow workflow = workflowClient.getWorkflow(workflowId, true); + TaskResult taskResult = new TaskResult(); + taskResult.setWorkflowInstanceId(workflowId); + taskResult.setTaskId(workflow.getTasks().get(0).getTaskId()); + taskResult.setStatus(TaskResult.Status.COMPLETED); + + List fanoutTasks = new ArrayList<>(); + Map> input = new HashMap<>(); + + for (int i = 0; i < count; i++) { + WorkflowTask workflowTask = new WorkflowTask(); + workflowTask.setName("integration_task_2"); + workflowTask.setTaskReferenceName("xdt" + i); + workflowTask.setOptional(true); + fanoutTasks.add(workflowTask); + + input.put("xdt" + i, Map.of("k1", "v1")); + + } + + Map output = new HashMap<>(); + + output.put("dynamicTasks", fanoutTasks); + output.put("dynamicTasksInput", input); + taskResult.setOutputData(output); + taskClient.updateTask(taskResult); + + workflow = workflowClient.getWorkflow(workflowId, true); + for (Task task : workflow.getTasks()) { + if(!task.getStatus().isTerminal()) { + taskResult = new TaskResult(); + taskResult.setWorkflowInstanceId(workflowId); + taskResult.setTaskId(task.getTaskId()); + taskResult.setStatus(TaskResult.Status.COMPLETED); + taskClient.updateTask(taskResult); + } + } + workflow = workflowClient.getWorkflow(workflowId, true); + System.out.println("workflow status: " + workflow.getStatus()); + + + } + @Test public void testTaskDynamicForkRetryCount() {