diff --git a/tests/IntegrationTests/WorkflowExecutor.IntegrationTests/DICOMs/output_metadata/dcm/output.dcm b/tests/IntegrationTests/WorkflowExecutor.IntegrationTests/DICOMs/output_metadata/dcm/output.dcm new file mode 100644 index 000000000..ff2073177 Binary files /dev/null and b/tests/IntegrationTests/WorkflowExecutor.IntegrationTests/DICOMs/output_metadata/dcm/output.dcm differ diff --git a/tests/IntegrationTests/WorkflowExecutor.IntegrationTests/Features/PayloadCollection.feature b/tests/IntegrationTests/WorkflowExecutor.IntegrationTests/Features/PayloadCollection.feature index 9882428f1..36a9ca729 100644 --- a/tests/IntegrationTests/WorkflowExecutor.IntegrationTests/Features/PayloadCollection.feature +++ b/tests/IntegrationTests/WorkflowExecutor.IntegrationTests/Features/PayloadCollection.feature @@ -17,32 +17,26 @@ Feature: PayloadCollection Tests around the payload collection @PatientDetails -Scenario: Seed MinIO with patient metadata, and payload collection has details +Scenario: Payload collection will be populated with patient details after receiving a Workflow Request when patient metadata exists Given I have a clinical workflow Basic_Workflow_1 - And I have a bucket in MinIO bucket1 - And I have a payload in the bucket bucket1 with payload id - When I publish a Workflow Request Message + When I publish a Workflow Request Message with artifacts in minio Then A payload collection is created with patient details - Then I can see Workflow Instance is created + And I can see Workflow Instance is created Examples: - | workflowRequestMessage | metadata | patientTestData | payloadId | workflowInstance | - | Basic_AeTitle_Payload_Collection_Request_1 | full_patient_metadata | Full_Patient | 23b96697-0174-465c-b9cb-368b20a4591d | 1 | - | Basic_Non_Existant_Request | partial_patient_metadata | Partial_Patient | c9c1e0f1-5994-4882-b3d4-9e1009729377 | 0 | + | workflowRequestMessage | objects | patientTestData | workflowInstance | + | Basic_AeTitle_Payload_Collection_Request_1 | full_patient_metadata | Full_Patient | 1 | + | Basic_Non_Existant_Request | partial_patient_metadata | Partial_Patient | 0 | @PatientDetails -Scenario: Seed MinIO with blank patient data, and payload collection has null details +Scenario: Payload collection will be populated with null patient details after receiving a Workflow Request when patient metadata is blank Given I have a clinical workflow Basic_Workflow_1 - And I have a bucket in MinIO bucket1 - And I have a payload null_patient_metadata in the bucket bucket1 with payload id 64a2b260-0379-4614-9f05-ff1279cf9e83 - When I publish a Workflow Request Message Basic_AeTitle_Payload_Collection_Request_2 + When I publish a Workflow Request Message Basic_AeTitle_Payload_Collection_Request_2 with artifacts null_patient_metadata in minio Then A payload collection is created with patient details Null_Patient - Then I can see 1 Workflow Instance is created + And I can see 1 Workflow Instance is created @PatientDetails -Scenario: Seed MinIO with no patient data, and payload collection has null details +Scenario: Payload collection will be populated with null patient details after receiving a Workflow Request when patient metadata is missing Given I have a clinical workflow Basic_Workflow_1 - And I have a bucket in MinIO bucket1 - And I have a payload no_patient_metadata in the bucket bucket1 with payload id b91f5559-8ab2-455a-806d-961244ea22af - When I publish a Workflow Request Message Basic_AeTitle_Payload_Collection_Request_3 + When I publish a Workflow Request Message Basic_AeTitle_Payload_Collection_Request_3 with artifacts no_patient_metadata in minio Then A payload collection is created with patient details Null_Patient - Then I can see 1 Workflow Instance is created + And I can see 1 Workflow Instance is created diff --git a/tests/IntegrationTests/WorkflowExecutor.IntegrationTests/Features/RouterTasks.feature b/tests/IntegrationTests/WorkflowExecutor.IntegrationTests/Features/RouterTasks.feature index 9610ebaa0..d4b98ff8a 100644 --- a/tests/IntegrationTests/WorkflowExecutor.IntegrationTests/Features/RouterTasks.feature +++ b/tests/IntegrationTests/WorkflowExecutor.IntegrationTests/Features/RouterTasks.feature @@ -19,47 +19,41 @@ Workflow supports Router Tasks @RouterTasks Scenario: Routing Task dispatches single plug-in task Given I have a clinical workflow Routing_Workflow_Single_Destination - And I have a bucket in MinIO bucket1 - When I publish a Workflow Request Message Routing_Workflow_Request + When I publish a Workflow Request Message Routing_Workflow_Request with no artifacts Then I can see 1 Workflow Instance is created And Task Dispatch events for TaskIds taskdest1 are published @RouterTasks Scenario: Routing Task dispatches multiple plug-in tasks Given I have a clinical workflow Routing_Workflow_Multi_Destination - And I have a bucket in MinIO bucket1 - When I publish a Workflow Request Message Routing_Workflow_Request + When I publish a Workflow Request Message Routing_Workflow_Request with no artifacts Then I can see 1 Workflow Instance is created And Task Dispatch events for TaskIds taskdest1, taskdest2 are published @RouterTasks Scenario: Routing Task dispatches single plug-in task based on conditional statements Given I have a clinical workflow Routing_Workflow_Single_Destination_Conditional - And I have a bucket in MinIO bucket1 - When I publish a Workflow Request Message Routing_Workflow_Request + When I publish a Workflow Request Message Routing_Workflow_Request with no artifacts Then I can see 1 Workflow Instance is created And Task Dispatch events for TaskIds taskdest1 are published @RouterTasks Scenario: Routing Task dispatches no tasks based on conditional statements Given I have a clinical workflow Routing_Workflow_No_Destination_Conditional - And I have a bucket in MinIO bucket1 - When I publish a Workflow Request Message Routing_Workflow_Request + When I publish a Workflow Request Message Routing_Workflow_Request with no artifacts Then I can see 1 Workflow Instance is created And A Task Dispatch event is not published @RouterTasks Scenario: Routing Task dispatches additonal plugin task and triggers another router task Given I have a clinical workflow Routing_Workflow_Multi_Router - And I have a bucket in MinIO bucket1 - When I publish a Workflow Request Message Routing_Workflow_Request + When I publish a Workflow Request Message Routing_Workflow_Request with no artifacts Then I can see 1 Workflow Instance is created And Task Dispatch events for TaskIds taskdest1, taskdest2, taskdest3 are published @RouterTasks Scenario: Routing Task attempts to dispatch task which does not exist in workflow Given I have a clinical workflow Routing_Workflow_Invalid_Destination - And I have a bucket in MinIO bucket1 - When I publish a Workflow Request Message Routing_Workflow_Request + When I publish a Workflow Request Message Routing_Workflow_Request with no artifacts Then I can see 1 Workflow Instance is created And A Task Dispatch event is not published diff --git a/tests/IntegrationTests/WorkflowExecutor.IntegrationTests/Features/TaskDestinations.feature b/tests/IntegrationTests/WorkflowExecutor.IntegrationTests/Features/TaskDestinations.feature index 22d81d667..4f63865dc 100644 --- a/tests/IntegrationTests/WorkflowExecutor.IntegrationTests/Features/TaskDestinations.feature +++ b/tests/IntegrationTests/WorkflowExecutor.IntegrationTests/Features/TaskDestinations.feature @@ -19,7 +19,7 @@ New task is dispatched after a Task update message is received. @TaskUpdate Scenario: Publish a valid Task Update event which triggers a single new task Given I have a clinical workflow Multi_Task_Workflow_3 - And I have a Workflow Instance WFI_Multi_Task_3 + And I have a Workflow Instance WFI_Multi_Task_3 with no artifacts When I publish a Task Update Message Task_Update_To_Dispatch_Single_Task with status Succeeded Then 1 Task Dispatch event is published And Workflow Instance is updated with the new Task @@ -29,7 +29,7 @@ Scenario: Publish a valid Task Update event which triggers a single new task @TaskUpdate Scenario: Publish a valid Task Update event which triggers multiple new tasks Given I have a clinical workflow Multi_Task_Workflow_2 - And I have a Workflow Instance WFI_Multi_Task_2 + And I have a Workflow Instance WFI_Multi_Task_2 with no artifacts When I publish a Task Update Message Task_Update_Dispatches_Multi_Tasks with status Succeeded Then 2 Task Dispatch events are published And Workflow Instance is updated with the new Tasks @@ -39,7 +39,7 @@ Scenario: Publish a valid Task Update event which triggers multiple new tasks @TaskUpdate Scenario Outline: Publish a valid Task Update event where the Task status is not created Given I have a clinical workflow Multi_Task_Workflow_1 - And I have a Workflow Instance + And I have a Workflow Instance with no artifacts When I publish a Task Update Message Task_Update_Dispatches_Single_Task with status Succeeded Then A Task Dispatch event is not published Examples: @@ -51,7 +51,7 @@ Scenario Outline: Publish a valid Task Update event where the Task status is not @TaskUpdate Scenario: Publish a valid Task Update event as failed which does not trigger a new task and updates the workflow status to Failed Given I have a clinical workflow Multi_Task_Workflow_1 - And I have a Workflow Instance WFI_Multi_Task_1 + And I have a Workflow Instance WFI_Multi_Task_1 with no artifacts When I publish a Task Update Message Task_Update_Dispatches_Single_Task with status Failed Then A Task Dispatch event is not published And Workflow Instance status is Failed @@ -59,35 +59,35 @@ Scenario: Publish a valid Task Update event as failed which does not trigger a n @TaskDestinationConditions Scenario: Task destination with condition true, WFI is updated with Task and task dispatch message is published Given I have a clinical workflow Multi_Task_Workflow_Destination_Single_Condition_True - And I have a Workflow Instance WFI_Task_Destination_Condition_True + And I have a Workflow Instance WFI_Task_Destination_Condition_True with no artifacts When I publish a Task Update Message Task_Update_Task_Destination_Condition_True with status Succeeded Then 1 Task Dispatch event is published @TaskDestinationConditions Scenario: Task destination with condition false, WFI is not updated with Task and task dispatch message is not published Given I have a clinical workflow Multi_Task_Workflow_Destination_Single_Condition_False - And I have a Workflow Instance WFI_Task_Destination_Condition_False + And I have a Workflow Instance WFI_Task_Destination_Condition_False with no artifacts When I publish a Task Update Message Task_Update_Task_Destination_Condition_False with status Succeeded Then A Task Dispatch event is not published @TaskDestinationConditions Scenario: Multiple task destinations with condition true, multiple task dispatch messages sent Given I have a clinical workflow Multi_Task_Workflow_Multiple_Destination_Single_Condition_True - And I have a Workflow Instance WFI_Task_Multiple_Destination_Condition_True + And I have a Workflow Instance WFI_Task_Multiple_Destination_Condition_True with no artifacts When I publish a Task Update Message Task_Update_Task_Multiple_Destination_Condition_True with status Succeeded Then 3 Task Dispatch events are published @TaskDestinationConditions Scenario: Multiple task destinations with condition false, no task dispatch messages sent Given I have a clinical workflow Multi_Task_Workflow_Multiple_Destination_Single_Condition_False - And I have a Workflow Instance WFI_Task_Multiple_Destination_Condition_False + And I have a Workflow Instance WFI_Task_Multiple_Destination_Condition_False with no artifacts When I publish a Task Update Message Task_Update_Task_Multiple_Destination_Condition_False with status Succeeded Then A Task Dispatch event is not published @TaskDestinationConditions Scenario: Multiple task destinations one with condition true and one with false, 1 task dispatch message published for task which is true Given I have a clinical workflow Multi_Task_Workflow_Destination_Multiple_Condition_True_And_False - And I have a Workflow Instance WFI_Task_Destination_Condition_True_And_False + And I have a Workflow Instance WFI_Task_Destination_Condition_True_And_False with no artifacts When I publish a Task Update Message Task_Update_Task_Destination_Condition_True_And_False with status Succeeded Then 1 Task Dispatch event is published And The Task Dispatch event is for Task Id b9964b10-acb4-4050-a610-374fdbe2100d @@ -95,7 +95,7 @@ Scenario: Multiple task destinations one with condition true and one with false, @TaskDestinationConditions Scenario: Workflow instance status remains created when any task status is either dispatch or accepted Given I have a clinical workflow Multi_Task_Workflow_Destination_Single_Condition_True - And I have a Workflow Instance WFI_Task_Destination_Condition_True + And I have a Workflow Instance WFI_Task_Destination_Condition_True with no artifacts When I publish a Task Update Message Task_Update_Task_Destination_Condition_True with status Succeeded Then 1 Task Dispatch event is published And Workflow Instance status is Created @@ -103,7 +103,7 @@ Scenario: Workflow instance status remains created when any task status is eithe @TaskDestinationConditions Scenario: Workflow instance status is failed when a condition is invalid Given I have a clinical workflow Multi_Task_Workflow_Task_Destination_Invalid_Condition - And I have a Workflow Instance WFI_Task_Destination_Invalid_Condition + And I have a Workflow Instance WFI_Task_Destination_Invalid_Condition with no artifacts When I publish a Task Update Message Task_Update_Task_Destination_Invalid_Condition with status Succeeded Then A Task Dispatch event is not published And Workflow Instance status is Succeeded @@ -111,8 +111,6 @@ Scenario: Workflow instance status is failed when a condition is invalid @TaskDestinationConditions Scenario: Task destination based on Dicom data conditional is successful, and task is completed and marked as succeeded Given I have a clinical workflow Workflow_Revision_for_bucket_minio - And I have a Workflow Instance Workflow_instance_for_bucket_minio - And I have a bucket in MinIO bucket1 - And I have a payload patient_1_lordge in the bucket bucket1 with payload id 5450c3a9-2b19-45b0-8b17-fb10f89d1b2d - When I publish a Task Update Message Task_status_update_for_bucket_minio with status Succeeded + And I have a Workflow Instance Workflow_instance_for_bucket_minio with artifacts patient_1_lordge in minio + When I publish a Task Update Message Task_status_update_for_bucket_minio with artifacts patient_1_lordge in minio Then I can see the status of the Task is Succeeded diff --git a/tests/IntegrationTests/WorkflowExecutor.IntegrationTests/Features/TaskStatusUpdate.feature b/tests/IntegrationTests/WorkflowExecutor.IntegrationTests/Features/TaskStatusUpdate.feature index ca2a10736..f51ad471c 100644 --- a/tests/IntegrationTests/WorkflowExecutor.IntegrationTests/Features/TaskStatusUpdate.feature +++ b/tests/IntegrationTests/WorkflowExecutor.IntegrationTests/Features/TaskStatusUpdate.feature @@ -19,7 +19,7 @@ Update task status in the workflow instance from a Task Update Event @TaskUpdate Scenario Outline: Publish a valid Task Update event which updates the Task status Given I have a clinical workflow Task_Status_Update_Workflow - And I have a Workflow Instance WFI_Task_Status_Update + And I have a Workflow Instance WFI_Task_Status_Update with no artifacts When I publish a Task Update Message Task_Status_Update with status Then I can see the status of the Task is updated Examples: @@ -32,15 +32,15 @@ Scenario Outline: Publish a valid Task Update event which updates the Task statu @TaskUpdate Scenario: Publish a valid Task Update event that where WorkflowInstance does not contain TaskId Given I have a clinical workflow Task_Status_Update_Workflow - And I have a Workflow Instance WFI_Task_Status_Update - When I publish a Task Update Message Task_Status_Update_TaskId_Not_Found with status Succeeded + And I have a Workflow Instance WFI_Task_Status_Update with no artifacts + When I publish a Task Update Message Task_Status_Update_TaskId_Not_Found with status Succeeded Then I can see the status of the Task is not updated @TaskUpdate Scenario Outline: Publish an invalid Task Update event which does not update the task status Given I have a clinical workflow Task_Status_Update_Workflow - And I have a Workflow Instance WFI_Task_Status_Update - When I publish a Task Update Message with status Succeeded + And I have a Workflow Instance WFI_Task_Status_Update with no artifacts + When I publish a Task Update Message with status Succeeded Then I can see the status of the Task is not updated Examples: | taskUpdateMessage | @@ -51,7 +51,7 @@ Scenario Outline: Publish an invalid Task Update event which does not update the @TaskUpdate Scenario Outline: Publish an valid Task Update event with a status that is invalid for current status - Given I have a Workflow Instance + Given I have a Workflow Instance with no artifacts When I publish a Task Update Message with status Then I can see the status of the Task is not updated Examples: diff --git a/tests/IntegrationTests/WorkflowExecutor.IntegrationTests/Features/WorkflowInstancesApi.feature b/tests/IntegrationTests/WorkflowExecutor.IntegrationTests/Features/WorkflowInstancesApi.feature index 2e081d460..da0ff00cf 100644 --- a/tests/IntegrationTests/WorkflowExecutor.IntegrationTests/Features/WorkflowInstancesApi.feature +++ b/tests/IntegrationTests/WorkflowExecutor.IntegrationTests/Features/WorkflowInstancesApi.feature @@ -19,9 +19,9 @@ API to interact with WorkflowInstances collection @GetWorkflowInstances Scenario: Get all workflows instances - multiple Given I have an endpoint /workflowinstances - And I have a Workflow Instance Existing_WFI_Created - And I have a Workflow Instance Existing_WFI_Dispatched - And I have a Workflow Instance WFI_Multi_Task_Dispatched + And I have a Workflow Instance Existing_WFI_Created with no artifacts + And I have a Workflow Instance Existing_WFI_Dispatched with no artifacts + And I have a Workflow Instance WFI_Multi_Task_Dispatched with no artifacts When I send a GET request Then I will get a 200 response And I can see expected workflow instances are returned @@ -29,7 +29,7 @@ Scenario: Get all workflows instances - multiple @GetWorkflowInstances Scenario: Get all workflows instances - single Given I have an endpoint /workflowinstances - And I have a Workflow Instance Existing_WFI_Created + And I have a Workflow Instance Existing_WFI_Created with no artifacts When I send a GET request Then I will get a 200 response And I can see expected workflow instances are returned @@ -82,8 +82,8 @@ Scenario Outline: Invalid pagination returns 400 @GetWorkflowInstances Scenario: Get all workflows instances by Id Given I have an endpoint /workflowinstances/bff4cfd0-3af3-4e2b-9f3c-de2a6f2b9569 - And I have a Workflow Instance WFI_Static_1 - And I have a Workflow Instance WFI_Static_2 + And I have a Workflow Instance WFI_Static_1 with no artifacts + And I have a Workflow Instance WFI_Static_2 with no artifacts When I send a GET request Then I will get a 200 response And I can see expected workflow instance is returned @@ -91,13 +91,13 @@ Scenario: Get all workflows instances by Id @GetWorkflowInstances Scenario: Get all workflows instances by Id. Id Not Found Given I have an endpoint /workflowinstances/bff4cfd0-3af3-4e2b-9f3c-de2a6f2b9575 - And I have a Workflow Instance WFI_Static_1 + And I have a Workflow Instance WFI_Static_1 with no artifacts When I send a GET request Then I will get a 404 response @GetWorkflowInstances Scenario: Get all workflows instances by Id. Id Bad Request Given I have an endpoint /workflowinstances/absfsushs - And I have a Workflow Instance WFI_Static_1 + And I have a Workflow Instance WFI_Static_1 with no artifacts When I send a GET request Then I will get a 400 response diff --git a/tests/IntegrationTests/WorkflowExecutor.IntegrationTests/Features/WorkflowRequest.feature b/tests/IntegrationTests/WorkflowExecutor.IntegrationTests/Features/WorkflowRequest.feature index 07272f9a2..ef447e5bc 100644 --- a/tests/IntegrationTests/WorkflowExecutor.IntegrationTests/Features/WorkflowRequest.feature +++ b/tests/IntegrationTests/WorkflowExecutor.IntegrationTests/Features/WorkflowRequest.feature @@ -1,4 +1,4 @@ -# Copyright 2022 MONAI Consortium +# Copyright 2022 MONAI Consortium # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -19,8 +19,7 @@ Publishing a workflow request is consumed by the Workflow Manager. @WorkflowRequest Scenario Outline: Publish a valid workflow request which creates a single workflow instance Given I have a clinical workflow - And I have a bucket in MinIO bucket1 - When I publish a Workflow Request Message + When I publish a Workflow Request Message with no artifacts Then I can see 1 Workflow Instance is created And 1 Task Dispatch event is published Examples: @@ -32,8 +31,7 @@ Scenario Outline: Publish a valid workflow request which creates a single workfl Scenario Outline: Publish a valid workflow request which creates multiple workflow instances Given I have a clinical workflow And I have a clinical workflow - And I have a bucket in MinIO bucket1 - When I publish a Workflow Request Message + When I publish a Workflow Request Message with no artifacts Then I can see 2 Workflow Instances are created And 2 Task Dispatch events are published Examples: @@ -45,16 +43,14 @@ Scenario Outline: Publish a valid workflow request which creates multiple workfl Scenario: Publish a valid workflow request with mismatched AE title and workflow ID Given I have a clinical workflow Basic_Workflow_1 And I have a clinical workflow Basic_Workflow_3 - And I have a bucket in MinIO bucket1 - When I publish a Workflow Request Message Mismatch_Id_AeTitle_WF_Request + When I publish a Workflow Request Message Mismatch_Id_AeTitle_WF_Request with no artifacts Then I can see 1 Workflow Instance is created @WorkflowRequest Scenario: Publish a valid workflow request triggering a workflow with multiple revisions Given I have a clinical workflow Basic_Workflow_Multiple_Revisions_1 And I have a clinical workflow Basic_Workflow_Multiple_Revisions_2 - And I have a bucket in MinIO bucket1 - When I publish a Workflow Request Message + When I publish a Workflow Request Message with no artifacts Then I can see 1 Workflow Instances are created Examples: | workflowRequestMessage | @@ -64,8 +60,7 @@ Scenario: Publish a valid workflow request triggering a workflow with multiple r @WorkflowRequest Scenario: Publish an invalid workflow request which does not create a workflow instance Given I have a clinical workflow Basic_Workflow_3 - And I have a bucket in MinIO bucket1 - When I publish a Workflow Request Message + When I publish a Workflow Request Message with no artifacts Then I can see 0 Workflow Instances are created Examples: | workflowRequestMessage | @@ -79,17 +74,15 @@ Scenario: Publish an invalid workflow request which does not create a workflow i @WorkflowRequest Scenario: Publish a valid workflow request with an exiting Workflow Instance with a Task which is not dispatched Given I have a clinical workflow Multi_Request_Workflow_Created - And I have a bucket in MinIO bucket1 - And I have a Workflow Instance Existing_WFI_Created - When I publish a Workflow Request Message Multi_WF_Created + And I have a Workflow Instance Existing_WFI_Created with no artifacts + When I publish a Workflow Request Message Multi_WF_Created with no artifacts Then I can see an additional Workflow Instance is not created And 1 Task Dispatch event is published @WorkflowRequest Scenario: Publish a valid workflow request with an exiting Workflow Instance with a Task which is dispatched Given I have a clinical workflow Multi_Request_Workflow_Dispatched - And I have a bucket in MinIO bucket1 - And I have a Workflow Instance Existing_WFI_Dispatched - When I publish a Workflow Request Message Multi_WF_Dispatched + And I have a Workflow Instance Existing_WFI_Dispatched with no artifacts + When I publish a Workflow Request Message Multi_WF_Dispatched with no artifacts Then I can see an additional Workflow Instance is not created And A Task Dispatch event is not published diff --git a/tests/IntegrationTests/WorkflowExecutor.IntegrationTests/Features/WorkflowTaskArtefacts.feature b/tests/IntegrationTests/WorkflowExecutor.IntegrationTests/Features/WorkflowTaskArtefacts.feature deleted file mode 100644 index 4e29fc704..000000000 --- a/tests/IntegrationTests/WorkflowExecutor.IntegrationTests/Features/WorkflowTaskArtefacts.feature +++ /dev/null @@ -1,61 +0,0 @@ -# Copyright 2022 MONAI Consortium -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -Feature: WorkflowTaskArtefact - -Artefacts can get passed into and between tasks - -@WorkflowTaskArtefacts @ignore -Scenario Outline: Bucket exists in MinIO, publish workflow request which uses input artefacts - Given I have a bucket in MinIO monai - And I have a clinical workflow Single_Task_Context_Input - When I publish a Workflow Request Message Context_Input_AE - Then I can see 1 Workflow Instance is created - And 1 Task Dispatch event is published - -@WorkflowTaskArtefacts @ignore -Scenario Outline: Bucket does not exist in MinIO, publish workflow request which uses non existant bucket - Given I have a clinical workflow Single_Task_Context_Input - When I publish a Workflow Request Message Context_Input_AE - Then The workflow instance fails - -@WorkflowTaskArtefacts @ignore -Scenario Outline: Create artefact in MinIO, publish task update message with artefact as output - Given I have a bucket in MinIO outputArtefact - And I have a clinical workflow Multi_Task_Output_Artifact - And I have a Workflow Instance Single_Task_Completed - When I publish a task update message output_artefact - When I publish a task update message - Then I can see 1 Workflow Instance is created - And 1 Task Dispatch event is published - Examples: - | Task_Update_Message | - | output_artefact_file | - | output_artefact_dir | - -@WorkflowTaskArtefacts @ignore -Scenario Outline: Bucket exists in MinIO, send task dispatch with non existant file path - Given I have a bucket in MinIO dicom - And I have a clinical workflow Single_Task_Context_Input - When I publish a Workflow Request Message Context_Input_AE - When I publish a task update message output_artefact - Then The workflow instance fails - -@WorkflowTaskArtefacts @ignore -Scenario Outline: Bucket exists in MinIO, send task dispatch with non existant artefact - Given I have a bucket in MinIO dicom - And I have a clinical workflow Single_Task_Context_Input - And I have a Workflow Instance non_existant_artefact - When I publish a Workflow Request Message Context_Input_AE - Then The workflow instance fails diff --git a/tests/IntegrationTests/WorkflowExecutor.IntegrationTests/Features/WorkflowTaskArtifacts.feature b/tests/IntegrationTests/WorkflowExecutor.IntegrationTests/Features/WorkflowTaskArtifacts.feature new file mode 100644 index 000000000..c42511a56 --- /dev/null +++ b/tests/IntegrationTests/WorkflowExecutor.IntegrationTests/Features/WorkflowTaskArtifacts.feature @@ -0,0 +1,86 @@ +# Copyright 2022 MONAI Consortium +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +Feature: WorkflowTaskArtifact + +Integration test for Task input and output artifacts + +@TaskArtifacts_WorkflowRequest +Scenario Outline: Workflow with context.input.dicom is triggered when mandatory files exist resulting in a successful Task dispatch + Given I have a clinical workflow + When I publish a Workflow Request Message Artifact_AeTitle_Request_1 with artifacts full_patient_metadata in minio + Then I can see 1 Workflow Instance is created + And Input artifacts are mapped + And 1 Task Dispatch event is published + Examples: + | workflow | + | OneTask_Context.Dicom.Input_ArtifactMandatory=Null | + | OneTask_Context.Dicom.Input_ArtifactMandatory=True | + | OneTask_Context.Dicom.Input_ArtifactMandatory=False | + +@TaskArtifacts_WorkflowRequest +Scenario Outline: Workflow is triggered when mandatory artifacts are missing resulting in a failed Task dispatch + Given I have a clinical workflow + When I publish a Workflow Request Message Artifact_AeTitle_Request_1 with no artifacts + Then Workflow Instance status is Failed + And A Task Dispatch event is not published + Examples: + | workflow | + | OneTask_Context.Dicom.Input_ArtifactMandatory=Null | + | OneTask_Context.Dicom.Input_ArtifactMandatory=True | + +@TaskArtifacts_WorkflowRequest +Scenario Outline: Workflow with context.input.dicom is triggered when non-mandatory files are missing resulting in a successful Task dispatch + Given I have a clinical workflow OneTask_Context.Dicom.Input_ArtifactMandatory=False + When I publish a Workflow Request Message Artifact_AeTitle_Request_1 with no artifacts + Then I can see 1 Workflow Instance is created + And 1 Task Dispatch event is published + +@TaskArtifacts_TaskUpdate +Scenario Outline: Task with context.input.dicom is triggered when mandatory files exist resulting in a successful Task dispatch + Given I have a clinical workflow + And I have a Workflow Instance with artifacts full_patient_metadata in minio + When I publish a Task Update Message with artifacts output_metadata in minio + Then 1 Task Dispatch event is published + And I can see 1 Workflow Instance is updated + And Input artifacts are mapped + Examples: + | workflow | workflowInstance | taskUpdate | + | TwoTask_Context.Dicom.Input_ArtifactMandatory=Null | TwoTask_Context.Dicom.Input_ArtifactMandatory=Null | TwoTask_Context.Dicom.Input_ArtifactMandatory=Null | + | TwoTask_Context.Dicom.Input_ArtifactMandatory=True | TwoTask_Context.Dicom.Input_ArtifactMandatory=True | TwoTask_Context.Dicom.Input_ArtifactMandatory=True | + | TwoTask_Context.Dicom.Input_ArtifactMandatory=False | TwoTask_Context.Dicom.Input_ArtifactMandatory=False | TwoTask_Context.Dicom.Input_ArtifactMandatory=False | + +@TaskArtifacts_TaskUpdate +Scenario Outline: Task with context.input.dicom is triggered when non mandatory files do not exist resulting in a successful Task Dispatch + Given I have a clinical workflow + And I have a Workflow Instance with no artifacts + When I publish a Task Update Message with artifacts output_metadata in minio + Then 1 Task Dispatch event is published + And I can see 1 Workflow Instance is updated + And Input artifacts are mapped + Examples: + | workflow | workflowInstance | taskUpdate | + | TwoTask_Context.Dicom.Input_ArtifactMandatory=Null | TwoTask_Context.Dicom.Input_ArtifactMandatory=Null | TwoTask_Context.Dicom.Input_ArtifactMandatory=Null | + | TwoTask_Context.Dicom.Input_ArtifactMandatory=True | TwoTask_Context.Dicom.Input_ArtifactMandatory=True | TwoTask_Context.Dicom.Input_ArtifactMandatory=True | + +@TaskArtifacts_TaskUpdate +Scenario Outline: Task with context.input.dicom is triggered when mandatory files do not exist resulting in a failed Task Dispatch + Given I have a clinical workflow + And I have a Workflow Instance with no artifacts + When I publish a Task Update Message with artifacts output_metadata in minio + Then A Task Dispatch event is not published + Examples: + | workflow | workflowInstance | taskUpdate | + | TwoTask_Context.Dicom.Input_ArtifactMandatory=Null | TwoTask_Context.Dicom.Input_ArtifactMandatory=Null | TwoTask_Context.Dicom.Input_ArtifactMandatory=Null | + | TwoTask_Context.Dicom.Input_ArtifactMandatory=True | TwoTask_Context.Dicom.Input_ArtifactMandatory=True | TwoTask_Context.Dicom.Input_ArtifactMandatory=True | diff --git a/tests/IntegrationTests/WorkflowExecutor.IntegrationTests/Hooks.cs b/tests/IntegrationTests/WorkflowExecutor.IntegrationTests/Hooks.cs index 94ecc90dc..ef86d6e8d 100644 --- a/tests/IntegrationTests/WorkflowExecutor.IntegrationTests/Hooks.cs +++ b/tests/IntegrationTests/WorkflowExecutor.IntegrationTests/Hooks.cs @@ -14,7 +14,6 @@ * limitations under the License. */ -using System.Diagnostics; using BoDi; using Microsoft.Extensions.Configuration; using Microsoft.Extensions.Hosting; @@ -139,8 +138,9 @@ public void SetUp() ObjectContainer.RegisterInstanceAs(apiHelper); } - [BeforeTestRun(Order = 1)] + [BeforeTestRun(Order = 2)] [AfterTestRun(Order = 0)] + [AfterScenario] public static void ClearTestData() { MongoClient?.DeleteAllWorkflowRevisionDocuments(); @@ -148,52 +148,10 @@ public static void ClearTestData() MongoClient?.DeleteAllPayloadDocuments(); } - [AfterScenario] - public void DeleteTestData() - { - var dataHelper = ObjectContainer.Resolve(); - - if (dataHelper.WorkflowRevisions.Count > 0) - { - foreach (var workflowRevision in dataHelper.WorkflowRevisions) - { - MongoClient?.DeleteWorkflowRevisionDocumentByWorkflowId(workflowRevision.WorkflowId); - } - } - - if (dataHelper.WorkflowInstances.Count > 0) - { - foreach (var workflowInstance in dataHelper.WorkflowInstances) - { - MongoClient?.DeleteWorkflowInstance(workflowInstance.Id); - } - } - - if (dataHelper.Payload.Count > 0) - { - foreach (var payload in dataHelper.Payload) - { - MongoClient?.DeletePayloadDocumentByPayloadId(payload.PayloadId); - } - } - - if (dataHelper.WorkflowRequestMessage != null) - { - MongoClient?.DeletePayloadDocumentByPayloadId(dataHelper.WorkflowRequestMessage.PayloadId.ToString()); - - foreach (var workflowRevision in dataHelper.WorkflowRevisions) - { - MongoClient?.DeleteWorkflowRevisionDocumentByWorkflowId(workflowRevision.WorkflowId); - } - } - } - - [AfterScenario] - public void PurgeRabbitMessages() + [BeforeTestRun(Order = 3)] + public async static Task CreateBucket() { - RabbitConnectionFactory.PurgeQueue(TestExecutionConfig.RabbitConfig.TaskDispatchQueue); - RabbitConnectionFactory.PurgeQueue(TestExecutionConfig.RabbitConfig.TaskUpdateQueue); - RabbitConnectionFactory.PurgeQueue(TestExecutionConfig.RabbitConfig.WorkflowRequestQueue); + await MinioClient.CreateBucket(TestExecutionConfig.MinioConfig.Bucket); } /// diff --git a/tests/IntegrationTests/WorkflowExecutor.IntegrationTests/Monai.Deploy.WorkflowManager.WorkflowExecutor.IntegrationTests.csproj b/tests/IntegrationTests/WorkflowExecutor.IntegrationTests/Monai.Deploy.WorkflowManager.WorkflowExecutor.IntegrationTests.csproj index f471d2b4a..1db068535 100644 --- a/tests/IntegrationTests/WorkflowExecutor.IntegrationTests/Monai.Deploy.WorkflowManager.WorkflowExecutor.IntegrationTests.csproj +++ b/tests/IntegrationTests/WorkflowExecutor.IntegrationTests/Monai.Deploy.WorkflowManager.WorkflowExecutor.IntegrationTests.csproj @@ -1,19 +1,19 @@ - - + + @@ -53,10 +53,6 @@ - - - - @@ -67,7 +63,7 @@ PayloadCollection.feature - + @@ -76,29 +72,32 @@ PreserveNewest - + PreserveNewest - + PreserveNewest - + + + PreserveNewest + PreserveNewest - + PreserveNewest - + PreserveNewest PreserveNewest - + PreserveNewest - + PreserveNewest @@ -111,7 +110,7 @@ $(UsingMicrosoftNETSdk) %(RelativeDir)%(Filename).feature$(DefaultLanguageSourceExtension) - + diff --git a/tests/IntegrationTests/WorkflowExecutor.IntegrationTests/StepDefinitions/PayloadApiStepDefinitions.cs b/tests/IntegrationTests/WorkflowExecutor.IntegrationTests/StepDefinitions/PayloadApiStepDefinitions.cs index 1178873b9..7d49cfacd 100644 --- a/tests/IntegrationTests/WorkflowExecutor.IntegrationTests/StepDefinitions/PayloadApiStepDefinitions.cs +++ b/tests/IntegrationTests/WorkflowExecutor.IntegrationTests/StepDefinitions/PayloadApiStepDefinitions.cs @@ -32,7 +32,7 @@ public PayloadApiStepDefinitions(ObjectContainer objectContainer, ISpecFlowOutpu DataHelper = objectContainer.Resolve(); MongoClient = objectContainer.Resolve(); _outputHelper = outputHelper; - Assertions = new Assertions(); + Assertions = new Assertions(objectContainer); } private Assertions Assertions { get; } diff --git a/tests/IntegrationTests/WorkflowExecutor.IntegrationTests/StepDefinitions/PayloadCollectionStepDefinitions.cs b/tests/IntegrationTests/WorkflowExecutor.IntegrationTests/StepDefinitions/PayloadCollectionStepDefinitions.cs index 7fc2f3668..69fe69ee2 100644 --- a/tests/IntegrationTests/WorkflowExecutor.IntegrationTests/StepDefinitions/PayloadCollectionStepDefinitions.cs +++ b/tests/IntegrationTests/WorkflowExecutor.IntegrationTests/StepDefinitions/PayloadCollectionStepDefinitions.cs @@ -33,7 +33,7 @@ public class PayloadCollectionStepDefinitions public PayloadCollectionStepDefinitions(ObjectContainer objectContainer, ISpecFlowOutputHelper outputHelper) { _outputHelper = outputHelper; - Assertions = new Assertions(); + Assertions = new Assertions(objectContainer); DataHelper = objectContainer.Resolve(); } diff --git a/tests/IntegrationTests/WorkflowExecutor.IntegrationTests/StepDefinitions/TaskDestinationsStepDefinitions.cs b/tests/IntegrationTests/WorkflowExecutor.IntegrationTests/StepDefinitions/TaskDestinationsStepDefinitions.cs index 27c16af9d..c01791fc9 100644 --- a/tests/IntegrationTests/WorkflowExecutor.IntegrationTests/StepDefinitions/TaskDestinationsStepDefinitions.cs +++ b/tests/IntegrationTests/WorkflowExecutor.IntegrationTests/StepDefinitions/TaskDestinationsStepDefinitions.cs @@ -37,7 +37,7 @@ public TaskDestinationsStepDefinitions(ObjectContainer objectContainer, ISpecFlo MongoClient = objectContainer.Resolve(); DataHelper = objectContainer.Resolve(); RetryPolicy = Policy.Handle().WaitAndRetry(retryCount: 10, sleepDurationProvider: _ => TimeSpan.FromMilliseconds(500)); - Assertions = new Assertions(); + Assertions = new Assertions(objectContainer); _outputHelper = outputHelper; } @@ -59,8 +59,21 @@ public void ThenWorkflowInstanceStatusIs(string status) { RetryPolicy.Execute(() => { - _outputHelper.WriteLine($"Retrieving workflow instance by id={DataHelper.TaskUpdateEvent.WorkflowInstanceId}"); - var workflowInstance = MongoClient.GetWorkflowInstanceById(DataHelper.TaskUpdateEvent.WorkflowInstanceId); + Contracts.Models.WorkflowInstance workflowInstance; + if (DataHelper.TaskUpdateEvent.WorkflowInstanceId != "") + { + _outputHelper.WriteLine($"Retrieving workflow instance by id={DataHelper.TaskUpdateEvent.WorkflowInstanceId}"); + workflowInstance = MongoClient.GetWorkflowInstanceById(DataHelper.TaskUpdateEvent.WorkflowInstanceId); + } + else if (DataHelper.WorkflowRequestMessage.PayloadId != null) + { + _outputHelper.WriteLine($"Retrieving workflow instance by PayloadId={DataHelper.WorkflowRequestMessage.PayloadId.ToString()}"); + workflowInstance = MongoClient.GetWorkflowInstance(DataHelper.WorkflowRequestMessage.PayloadId.ToString()); + } + else + { + throw new Exception("Workflow Instance cannot be found using Id or PayloadId"); + } _outputHelper.WriteLine("Retrieved workflow instance"); Assertions.WorkflowInstanceStatus(status, workflowInstance); }); diff --git a/tests/IntegrationTests/WorkflowExecutor.IntegrationTests/StepDefinitions/TaskStatusUpdateStepDefinitions.cs b/tests/IntegrationTests/WorkflowExecutor.IntegrationTests/StepDefinitions/TaskStatusUpdateStepDefinitions.cs index 67391f466..a62c1729b 100644 --- a/tests/IntegrationTests/WorkflowExecutor.IntegrationTests/StepDefinitions/TaskStatusUpdateStepDefinitions.cs +++ b/tests/IntegrationTests/WorkflowExecutor.IntegrationTests/StepDefinitions/TaskStatusUpdateStepDefinitions.cs @@ -18,6 +18,7 @@ using Monai.Deploy.Messaging.Events; using Monai.Deploy.Messaging.Messages; using Monai.Deploy.WorkflowManager.IntegrationTests.Support; +using Monai.Deploy.WorkflowManager.WorkflowExecutor.IntegrationTests.Support; using Polly; using Polly.Retry; using TechTalk.SpecFlow.Infrastructure; @@ -32,6 +33,7 @@ public class TaskStatusUpdateStepDefinitions private RetryPolicy RetryPolicy { get; set; } private DataHelper DataHelper { get; set; } private readonly ISpecFlowOutputHelper _outputHelper; + public MinioDataSeeding MinioDataSeeding { get; } public TaskStatusUpdateStepDefinitions(ObjectContainer objectContainer, ISpecFlowOutputHelper outputHelper) { @@ -40,10 +42,11 @@ public TaskStatusUpdateStepDefinitions(ObjectContainer objectContainer, ISpecFlo DataHelper = objectContainer.Resolve(); RetryPolicy = Policy.Handle().WaitAndRetry(retryCount: 10, sleepDurationProvider: _ => TimeSpan.FromMilliseconds(500)); _outputHelper = outputHelper; + MinioDataSeeding = new MinioDataSeeding(objectContainer.Resolve(), DataHelper, _outputHelper); } [When(@"I publish a Task Update Message (.*) with status (.*)")] - public void WhenIPublishATaskUpdateMessageTaskUpdateMessage(string name, string updateStatus) + public void WhenIPublishATaskUpdateMessageWithStatus(string name, string updateStatus) { var message = new JsonMessage( DataHelper.GetTaskUpdateTestData(name, updateStatus), @@ -54,6 +57,31 @@ public void WhenIPublishATaskUpdateMessageTaskUpdateMessage(string name, string TaskUpdatePublisher.PublishMessage(message.ToMessage()); } + [When(@"I publish a Task Update Message (.*) with artifacts (.*) in minio")] + public async Task WhenIPublishATaskUpdateMessageWithObjects(string name, string folderName) + { + var taskUpdateMessage = DataHelper.GetTaskUpdateTestData(name, "succeeded"); + + foreach (var workflowInstance in DataHelper.WorkflowInstances) + { + var task = workflowInstance.Tasks.FirstOrDefault(x => x.Status == TaskExecutionStatus.Accepted); + + if (task != null) + { + _outputHelper.WriteLine("Seeding minio with task output artifacts"); + await MinioDataSeeding.SeedTaskOutputArtifacts(workflowInstance.PayloadId, workflowInstance.Id, task.ExecutionId, folderName); + } + } + + var message = new JsonMessage( + DataHelper.GetTaskUpdateTestData(name, "succeeded"), + "16988a78-87b5-4168-a5c3-2cfc2bab8e54", + Guid.NewGuid().ToString(), + string.Empty); + + TaskUpdatePublisher.PublishMessage(message.ToMessage()); + } + [Then(@"I can see the status of the Tasks are updated")] [Then(@"I can see the status of the Task is updated")] public void ThenICanSeeTheStatusOfTheTaskIsUpdated() diff --git a/tests/IntegrationTests/WorkflowExecutor.IntegrationTests/StepDefinitions/WorkflowApiStepDefinitions.cs b/tests/IntegrationTests/WorkflowExecutor.IntegrationTests/StepDefinitions/WorkflowApiStepDefinitions.cs index 9e708d94e..daa63adfc 100644 --- a/tests/IntegrationTests/WorkflowExecutor.IntegrationTests/StepDefinitions/WorkflowApiStepDefinitions.cs +++ b/tests/IntegrationTests/WorkflowExecutor.IntegrationTests/StepDefinitions/WorkflowApiStepDefinitions.cs @@ -30,7 +30,7 @@ public WorkflowApiStepDefinitions(ObjectContainer objectContainer) DataHelper = objectContainer.Resolve(); MongoClient = objectContainer.Resolve(); ApiHelper = objectContainer.Resolve(); - Assertions = new Assertions(); + Assertions = new Assertions(objectContainer); } private ApiHelper ApiHelper { get; } diff --git a/tests/IntegrationTests/WorkflowExecutor.IntegrationTests/StepDefinitions/WorkflowInstancesApiStepDefinitions.cs b/tests/IntegrationTests/WorkflowExecutor.IntegrationTests/StepDefinitions/WorkflowInstancesApiStepDefinitions.cs index 18f5f33b2..0c20661ff 100644 --- a/tests/IntegrationTests/WorkflowExecutor.IntegrationTests/StepDefinitions/WorkflowInstancesApiStepDefinitions.cs +++ b/tests/IntegrationTests/WorkflowExecutor.IntegrationTests/StepDefinitions/WorkflowInstancesApiStepDefinitions.cs @@ -29,7 +29,7 @@ public WorkflowInstancesApiStepDefinitions(ObjectContainer objectContainer) { DataHelper = objectContainer.Resolve(); ApiHelper = objectContainer.Resolve(); - Assertions = new Assertions(); + Assertions = new Assertions(objectContainer); } private ApiHelper ApiHelper { get; } diff --git a/tests/IntegrationTests/WorkflowExecutor.IntegrationTests/StepDefinitions/WorkflowRequestStepDefinitions.cs b/tests/IntegrationTests/WorkflowExecutor.IntegrationTests/StepDefinitions/WorkflowRequestStepDefinitions.cs index 3dec12157..aea1d9328 100644 --- a/tests/IntegrationTests/WorkflowExecutor.IntegrationTests/StepDefinitions/WorkflowRequestStepDefinitions.cs +++ b/tests/IntegrationTests/WorkflowExecutor.IntegrationTests/StepDefinitions/WorkflowRequestStepDefinitions.cs @@ -20,6 +20,9 @@ using Monai.Deploy.WorkflowManager.IntegrationTests.Models; using Monai.Deploy.WorkflowManager.IntegrationTests.Support; using TechTalk.SpecFlow.Infrastructure; +using Polly; +using Polly.Retry; +using Monai.Deploy.WorkflowManager.WorkflowExecutor.IntegrationTests.Support; namespace Monai.Deploy.WorkflowManager.IntegrationTests.StepDefinitions { @@ -32,19 +35,23 @@ public class WorkflowRequestStepDefinitions private Assertions Assertions { get; set; } private DataHelper DataHelper { get; set; } private readonly ISpecFlowOutputHelper _outputHelper; + private RetryPolicy RetryPolicy { get; set; } + private MinioDataSeeding MinioDataSeeding { get; set; } public WorkflowRequestStepDefinitions(ObjectContainer objectContainer, ISpecFlowOutputHelper outputHelper) { WorkflowPublisher = objectContainer.Resolve("WorkflowPublisher"); TaskDispatchConsumer = objectContainer.Resolve("TaskDispatchConsumer"); MongoClient = objectContainer.Resolve(); - Assertions = new Assertions(); + Assertions = new Assertions(objectContainer); DataHelper = objectContainer.Resolve(); _outputHelper = outputHelper; + MinioDataSeeding = new MinioDataSeeding(objectContainer.Resolve(), DataHelper, _outputHelper); + RetryPolicy = Policy.Handle().WaitAndRetry(retryCount: 20, sleepDurationProvider: _ => TimeSpan.FromMilliseconds(500)); } [Given(@"I have a clinical workflow (.*)")] - public void GivenIHaveAClinicalWorkflow(string name) + public void GivenIHaveClinicalWorkflows(string name) { _outputHelper.WriteLine($"Retrieving workflow revision with name={name}"); MongoClient.CreateWorkflowRevisionDocument(DataHelper.GetWorkflowRevisionTestData(name)); @@ -63,7 +70,7 @@ public void GivenIHaveClinicalWorkflows(int count) } } - [Given(@"I have a Workflow Instance (.*)")] + [Given(@"I have a Workflow Instance (.*) with no artifacts")] public void GivenIHaveAWorkflowInstance(string name) { _outputHelper.WriteLine($"Retrieving workflow instance with name={name}"); @@ -71,6 +78,18 @@ public void GivenIHaveAWorkflowInstance(string name) _outputHelper.WriteLine("Retrieved workflow instance"); } + [Given(@"I have a Workflow Instance (.*) with artifacts (.*) in minio")] + public async Task GivenIHaveAWorkflowInstanceWithArtifacts(string name, string folderName) + { + var workflowInstance = DataHelper.GetWorkflowInstanceTestData(name); + _outputHelper.WriteLine("Seeding minio with workflow input artifacts"); + await MinioDataSeeding.SeedWorkflowInputArtifacts(workflowInstance.PayloadId, folderName); + + _outputHelper.WriteLine($"Retrieving workflow instance with name={name}"); + MongoClient.CreateWorkflowInstanceDocument(workflowInstance); + _outputHelper.WriteLine("Retrieved workflow instance"); + } + [Given(@"I have (.*) Workflow Instances")] public void GivenIHaveWorkflowInstances(int count) { @@ -83,8 +102,26 @@ public void GivenIHaveWorkflowInstances(int count) } } - [When(@"I publish a Workflow Request Message (.*)")] - public void WhenIPublishAWorkflowRequestMessage(string name) + [When(@"I publish a Workflow Request Message (.*) with artifacts (.*) in minio")] + public async Task WhenIPublishAWorkflowRequestMessageWithObjects(string name, string folderName) + { + var workflowRequestMessage = DataHelper.GetWorkflowRequestTestData(name); + _outputHelper.WriteLine("Seeding minio with workflow input artifacts"); + await MinioDataSeeding.SeedWorkflowInputArtifacts(workflowRequestMessage.PayloadId.ToString(), folderName); + + var message = new JsonMessage( + workflowRequestMessage, + "16988a78-87b5-4168-a5c3-2cfc2bab8e54", + Guid.NewGuid().ToString(), + string.Empty); + + _outputHelper.WriteLine($"Publishing WorkflowRequestEvent with name={name}"); + WorkflowPublisher.PublishMessage(message.ToMessage()); + _outputHelper.WriteLine($"Event published"); + } + + [When(@"I publish a Workflow Request Message (.*) with no artifacts")] + public void WhenIPublishAWorkflowRequestMessageWithNoObjects(string name) { var message = new JsonMessage( DataHelper.GetWorkflowRequestTestData(name), @@ -92,14 +129,16 @@ public void WhenIPublishAWorkflowRequestMessage(string name) Guid.NewGuid().ToString(), string.Empty); + _outputHelper.WriteLine($"Publishing WorkflowRequestEvent with name={name}"); WorkflowPublisher.PublishMessage(message.ToMessage()); + _outputHelper.WriteLine($"Event published"); } [Then(@"I can see (.*) Workflow Instances are created")] [Then(@"I can see (.*) Workflow Instance is created")] public void ThenICanSeeAWorkflowInstanceIsCreated(int count) { - _outputHelper.WriteLine($"Retrieving {count} workflow instance/s using the payloadid={DataHelper.WorkflowRequestMessage.PayloadId}"); + _outputHelper.WriteLine($"Retrieving {count} workflow instance/s using the payloadid={DataHelper.WorkflowRequestMessage.PayloadId.ToString()}"); var workflowInstances = DataHelper.GetWorkflowInstances(count, DataHelper.WorkflowRequestMessage.PayloadId.ToString()); _outputHelper.WriteLine($"Retrieved {count} workflow instance/s"); @@ -112,6 +151,7 @@ public void ThenICanSeeAWorkflowInstanceIsCreated(int count) if (workflowRevision != null) { Assertions.AssertWorkflowInstanceMatchesExpectedWorkflow(workflowInstance, workflowRevision, DataHelper.WorkflowRequestMessage); + } else { @@ -121,6 +161,36 @@ public void ThenICanSeeAWorkflowInstanceIsCreated(int count) } } + [Then(@"I can see (.*) Workflow Instances are updated")] + [Then(@"I can see (.*) Workflow Instance is updated")] + public void ThenICanSeeAWorkflowInstanceIsUpdated(int count) + { + RetryPolicy.Execute(() => + { + _outputHelper.WriteLine($"Retrieving {count} workflow instance/s using the payloadid={DataHelper.WorkflowInstances[0].PayloadId}"); + DataHelper.SeededWorkflowInstances = DataHelper.WorkflowInstances; + var workflowInstances = DataHelper.GetWorkflowInstances(count, DataHelper.WorkflowInstances[0].PayloadId); + _outputHelper.WriteLine($"Retrieved {count} workflow instance/s"); + + if (workflowInstances != null) + { + foreach (var workflowInstance in workflowInstances) + { + var taskUpdate = DataHelper.TaskUpdateEvent; + if (taskUpdate != null) + { + var workflowInstanceTask = workflowInstance.Tasks.FirstOrDefault(x => x.TaskId.Equals(taskUpdate.TaskId)); + if (workflowInstanceTask != null) + { + workflowInstanceTask.Status.Should().Be(taskUpdate.Status); + Assertions.AssertOutputArtifactsForTaskUpdate(workflowInstanceTask.OutputArtifacts, DataHelper.TaskUpdateEvent.Outputs); + } + } + } + } + }); + } + [Then(@"(.*) Task Dispatch event is published")] [Then(@"(.*) Task Dispatch events are published")] public void TaskDispatchEventIsPublished(int count) @@ -129,21 +199,25 @@ public void TaskDispatchEventIsPublished(int count) var taskDispatchEvents = DataHelper.GetTaskDispatchEvents(count, DataHelper.WorkflowInstances); _outputHelper.WriteLine($"Retrieved {count} task dispatch event/s"); - foreach (var taskDispatchEvent in taskDispatchEvents) + RetryPolicy.Execute(() => { - var workflowInstance = MongoClient.GetWorkflowInstanceById(taskDispatchEvent.WorkflowInstanceId); + foreach (var taskDispatchEvent in taskDispatchEvents) + { + var workflowInstance = MongoClient.GetWorkflowInstanceById(taskDispatchEvent.WorkflowInstanceId); - var workflow = DataHelper.WorkflowRevisions.FirstOrDefault(x => x.WorkflowId.Equals(workflowInstance.WorkflowId)); + var workflowRevision = DataHelper.WorkflowRevisions.OrderByDescending(x => x.Revision).FirstOrDefault(x => x.WorkflowId.Equals(workflowInstance.WorkflowId)); - if (string.IsNullOrEmpty(DataHelper.TaskUpdateEvent.ExecutionId)) - { - Assertions.AssertTaskDispatchEvent(taskDispatchEvent, workflowInstance, workflow, DataHelper.WorkflowRequestMessage); - } - else - { - Assertions.AssertTaskDispatchEvent(taskDispatchEvent, workflowInstance, workflow, null, DataHelper.TaskUpdateEvent); + if (string.IsNullOrEmpty(DataHelper.TaskUpdateEvent.ExecutionId)) + { + Assertions.AssertTaskDispatchEvent(taskDispatchEvent, workflowInstance, workflowRevision, DataHelper.WorkflowRequestMessage); + } + else + { + Assertions.AssertTaskDispatchEvent(taskDispatchEvent, workflowInstance, workflowRevision, null, DataHelper.TaskUpdateEvent); + } } - } + }); + } [Then(@"I can see an additional Workflow Instance is not created")] diff --git a/tests/IntegrationTests/WorkflowExecutor.IntegrationTests/StepDefinitions/WorkflowTaskArtefactStepDefinitions.cs b/tests/IntegrationTests/WorkflowExecutor.IntegrationTests/StepDefinitions/WorkflowTaskArtefactStepDefinitions.cs deleted file mode 100644 index 6816ccb78..000000000 --- a/tests/IntegrationTests/WorkflowExecutor.IntegrationTests/StepDefinitions/WorkflowTaskArtefactStepDefinitions.cs +++ /dev/null @@ -1,140 +0,0 @@ -/* - * Copyright 2021-2022 MONAI Consortium - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -using System.Reflection; -using BoDi; -using Monai.Deploy.WorkflowManager.IntegrationTests.Support; -using TechTalk.SpecFlow.Infrastructure; - -namespace Monai.Deploy.WorkflowManager.IntegrationTests.StepDefinitions -{ - [Binding] - public class WorkflowTaskArtefactStepDefinitions - { - - private RabbitPublisher WorkflowPublisher { get; set; } - private RabbitConsumer TaskDispatchConsumer { get; set; } - private MongoClientUtil MongoClient { get; set; } - private MinioClientUtil MinioClient { get; set; } - private Assertions Assertions { get; set; } - private DataHelper DataHelper { get; set; } - private readonly ISpecFlowOutputHelper _outputHelper; - - public WorkflowTaskArtefactStepDefinitions(ObjectContainer objectContainer, ScenarioContext scenarioContext, ISpecFlowOutputHelper outputHelper) - { - WorkflowPublisher = objectContainer.Resolve("WorkflowPublisher"); - TaskDispatchConsumer = objectContainer.Resolve("TaskDispatchConsumer"); - MongoClient = objectContainer.Resolve(); - MinioClient = objectContainer.Resolve(); - Assertions = new Assertions(); - DataHelper = objectContainer.Resolve(); - _outputHelper = outputHelper; - } - - [Given(@"I have a bucket in MinIO (.*)")] - public async Task GivenIHaveABucketInMinIO(string name) - { - _outputHelper.WriteLine($"Creating bucket {name}"); - await MinioClient.CreateBucket(name); - _outputHelper.WriteLine($"{name} bucket created"); - } - - [Given(@"I have a payload (.*) in the bucket (.*) with payload id (.*)")] - public async Task GivenIHaveAPayloadInTheBucket(string folderName, string bucketName, string payloadId) - { - _outputHelper.WriteLine("Retrieving pathname"); - var pathname = Path.Combine(GetDirectory(), "DICOMs", folderName, "dcm"); - _outputHelper.WriteLine($"Retrieved pathname {pathname}"); - _outputHelper.WriteLine($"Adding {folderName} folder"); - await MinioClient.AddFileToStorage(pathname, bucketName, DataHelper.GetPayloadId(payloadId)); - _outputHelper.WriteLine($"Folder added"); - } - - [Given(@"I have a payload (.*) and bucket in MinIO (.*)")] - public async Task GivenIHaveABucketInMinIOAndPayloadId(string payloadId, string name) - { - _outputHelper.WriteLine($"Creating bucket {name}"); - await MinioClient.CreateBucket(name); - _outputHelper.WriteLine($"{name} bucket created"); - _outputHelper.WriteLine("Retrieving pathname"); - var pathname = Path.Combine(GetDirectory(), "DICOMs", name, "dcm"); - _outputHelper.WriteLine($"Retrieved pathname {pathname}"); - _outputHelper.WriteLine($"Adding {payloadId} file"); - await MinioClient.AddFileToStorage(pathname, name, DataHelper.GetPayloadId(payloadId)); - _outputHelper.WriteLine($"File added"); - } - - [Then(@"I can see a task dispatch event with a path to the DICOM bucket")] - public void ThenICanSeeATaskDispatchEventWithAPathToTheDICOMBucket() - { - throw new PendingStepException(); - } - - [Then(@"The workflow instance fails")] - public void ThenTheWorkflowInstanceFails() - { - throw new PendingStepException(); - } - - [When(@"I publish a task update message (.*)")] - public void WhenIPublishATaskUpdateMessage(string name) - { - throw new PendingStepException(); - } - - [Then(@"The workflow instance is updated with correct file path")] - public void ThenTheWorkflowInstanceIsUpdatedWithCorrectFilePath() - { - throw new PendingStepException(); - } - - [Then(@"The task dispatch message is updated with correct file path")] - public void ThenTheTaskDispatchMessageIsUpdatedWithCorrectFilePath() - { - throw new PendingStepException(); - } - - [Given(@"I have a workflow instance")] - public void GivenIHaveAWorkflowInstance() - { - throw new PendingStepException(); - } - - [When(@"I publish a task dispatch Message (.*)")] - public void WhenIPublishATaskDispatchMessage() - { - throw new PendingStepException(); - } - - [When(@"I publish a workflow instance (.*)")] - public void WhenIPublishAWorkflowInstance() - { - throw new PendingStepException(); - } - - private string GetDirectory() - { - return Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location); - } - - /*[AfterScenario] - public async Task DeleteObjects() - { - await MinioClient.RemoveObjects(TestExecutionConfig.MinioConfig.Bucket, DataHelper.PayloadId); - }*/ - - } -} diff --git a/tests/IntegrationTests/WorkflowExecutor.IntegrationTests/StepDefinitions/WorkflowTaskArtifactStepDefinitions.cs b/tests/IntegrationTests/WorkflowExecutor.IntegrationTests/StepDefinitions/WorkflowTaskArtifactStepDefinitions.cs new file mode 100644 index 000000000..822d3f1b1 --- /dev/null +++ b/tests/IntegrationTests/WorkflowExecutor.IntegrationTests/StepDefinitions/WorkflowTaskArtifactStepDefinitions.cs @@ -0,0 +1,82 @@ +/* + * Copyright 2022 MONAI Consortium + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +using BoDi; +using Monai.Deploy.WorkflowManager.IntegrationTests.Support; +using TechTalk.SpecFlow.Infrastructure; + +namespace Monai.Deploy.WorkflowManager.IntegrationTests.StepDefinitions +{ + [Binding] + public class WorkflowTaskArtifactStepDefinitions + { + private Assertions Assertions { get; set; } + private DataHelper DataHelper { get; set; } + private readonly ISpecFlowOutputHelper _outputHelper; + + public WorkflowTaskArtifactStepDefinitions(ObjectContainer objectContainer, ScenarioContext scenarioContext, ISpecFlowOutputHelper outputHelper) + { + Assertions = new Assertions(objectContainer); + DataHelper = objectContainer.Resolve(); + _outputHelper = outputHelper; + } + + [Then(@"Input artifacts are mapped")] + public void ThenInputArtifactsAreMapped() + { + string PayloadId; + + if (DataHelper.SeededWorkflowInstances == null) + { + PayloadId = DataHelper.WorkflowRequestMessage.PayloadId.ToString(); + } + else + { + PayloadId = DataHelper.WorkflowInstances[0].PayloadId; + } + + _outputHelper.WriteLine($"Retrieving updated workflow instance using the payloadid={PayloadId}"); + + var workflowInstances = DataHelper.GetWorkflowInstances(1, PayloadId); + + if (workflowInstances == null) + { + throw new Exception($"WorkflowInstance not found for payloadId {PayloadId}"); + } + + _outputHelper.WriteLine("Retrieved workflow instance"); + + foreach (var workflowInstance in workflowInstances) + { + var workflowRevision = DataHelper.WorkflowRevisions.OrderByDescending(x => x.Revision).First(x => x.WorkflowId.Equals(workflowInstance.WorkflowId)); + + var seededWorkflowInstance = DataHelper.SeededWorkflowInstances?.FirstOrDefault(x => x.Id.Equals(workflowInstance.Id)); + + foreach (var task in workflowInstance.Tasks) + { + var seededTask = seededWorkflowInstance?.Tasks.FirstOrDefault(x => x.ExecutionId.Equals(task.ExecutionId)); + + if (seededTask == null) + { + var workflowTask = workflowRevision.Workflow.Tasks.First(x => x.Id.Equals(task.TaskId)); + + Assertions.AssertInputArtifacts(workflowTask, PayloadId, task); + } + } + } + } + } +} diff --git a/tests/IntegrationTests/WorkflowExecutor.IntegrationTests/Support/Assertions.cs b/tests/IntegrationTests/WorkflowExecutor.IntegrationTests/Support/Assertions.cs index 2d40c1bf7..111c02016 100644 --- a/tests/IntegrationTests/WorkflowExecutor.IntegrationTests/Support/Assertions.cs +++ b/tests/IntegrationTests/WorkflowExecutor.IntegrationTests/Support/Assertions.cs @@ -16,14 +16,23 @@ using System.Collections; using FluentAssertions; +using BoDi; using Monai.Deploy.Messaging.Events; using Monai.Deploy.WorkflowManager.Contracts.Models; using Monai.Deploy.WorkflowManager.IntegrationTests.Models; +using Monai.Deploy.WorkflowManager.IntegrationTests.POCO; namespace Monai.Deploy.WorkflowManager.IntegrationTests.Support { public class Assertions { + private static MinioClientUtil? MinioClient { get; set; } + + public Assertions(ObjectContainer objectContainer) + { + MinioClient = objectContainer.Resolve(); + } + public void AssertWorkflowInstanceMatchesExpectedWorkflow(WorkflowInstance workflowInstance, WorkflowRevision workflowRevision, WorkflowRequestMessage workflowRequestMessage) { workflowInstance.PayloadId.Should().Match(workflowRequestMessage.PayloadId.ToString()); @@ -37,6 +46,7 @@ public void AssertWorkflowInstanceMatchesExpectedWorkflow(WorkflowInstance workf { task.TaskId.Should().Match(workflowTask.Id); task.TaskType.Should().Match(workflowTask.Type); + AssertOutputDirectory(task, workflowInstance.PayloadId, workflowInstance.Id); } else { @@ -45,9 +55,66 @@ public void AssertWorkflowInstanceMatchesExpectedWorkflow(WorkflowInstance workf } } + public void AssertInputArtifacts(TaskObject workflowRevisionTask, string payloadId, TaskExecution workflowInstanceTask) + { + foreach (var workflowArtifact in workflowRevisionTask.Artifacts.Input) + { + if (workflowArtifact.Value == "{{ context.input.dicom }}") + { + workflowInstanceTask.InputArtifacts[workflowArtifact.Name].Should().Match($"{payloadId}/dcm/"); + } + } + } + + public void AssertInputArtifactsForTaskDispatch(TaskObject workflowRevisionTask, string payloadId, List taskDispatchInput) + { + foreach (var workflowArtifact in workflowRevisionTask.Artifacts.Input) + { + if (workflowArtifact.Value == "{{ context.input.dicom }}") + { + var taskDispatchArtifact = taskDispatchInput.FirstOrDefault(x => x.Name.Equals(workflowArtifact.Name)); + taskDispatchArtifact.RelativeRootPath.Should().Match($"{payloadId}/dcm/"); + taskDispatchArtifact.Bucket.Should().Match(TestExecutionConfig.MinioConfig.Bucket); + } + } + } + + public void AssertOutputDirectory(TaskExecution task, string payloadId, string workflowInstanceId) + { + task.OutputDirectory.Should().Match($"{payloadId}/workflows/{workflowInstanceId}/{task.ExecutionId}"); + } + + public void AssertOutputArtifactsForTaskUpdate(Dictionary workflowInstanceTaskOutput, List taskUpdateOutput) + { + foreach (var artifact in taskUpdateOutput) + { + var workflowInstanceTaskArtifact = workflowInstanceTaskOutput.First(x => x.Key.Equals(artifact.Name)); + + if (workflowInstanceTaskArtifact.Key != null) + { + workflowInstanceTaskArtifact.Key.Should().Be(artifact.Name); + workflowInstanceTaskArtifact.Value.Should().Be(artifact.RelativeRootPath); + } + else + { + throw new Exception($"Output Artifact name={artifact.Name} was not found in Task!"); + } + } + } + + public void AssertOutputArtifactsForTaskDispatch(List taskDispatchOuput, string payloadId, string workflowInstanceId, string executionId) + { + foreach (var output in taskDispatchOuput) + { + output.RelativeRootPath.Should().Match($"{payloadId}/workflows/{workflowInstanceId}/{executionId}"); + } + } + public void AssertTaskDispatchEvent(TaskDispatchEvent taskDispatchEvent, WorkflowInstance workflowInstance, WorkflowRevision workflowRevision, WorkflowRequestMessage workflowRequestMessage = null, TaskUpdateEvent taskUpdateEvent = null) { - var taskDetails = workflowInstance.Tasks.FirstOrDefault(c => c.TaskId.Equals(taskDispatchEvent.TaskId)); + var workflowInstanceTask = workflowInstance.Tasks.FirstOrDefault(x => x.TaskId.Equals(taskDispatchEvent.TaskId, StringComparison.OrdinalIgnoreCase)); + + var workflowRevisionTask = workflowRevision.Workflow.Tasks.FirstOrDefault(x => x.Id.Equals(taskDispatchEvent.TaskId, StringComparison.OrdinalIgnoreCase)); if (workflowRequestMessage != null) { @@ -59,10 +126,21 @@ public void AssertTaskDispatchEvent(TaskDispatchEvent taskDispatchEvent, Workflo } taskDispatchEvent.WorkflowInstanceId.Should().Match(workflowInstance.Id); + taskDispatchEvent.TaskId.Should().Match(workflowInstanceTask.TaskId); + taskDispatchEvent.PayloadId.Should().Match(workflowInstance.PayloadId); + taskDispatchEvent.ExecutionId.Should().Match(workflowInstanceTask.ExecutionId); - taskDispatchEvent.TaskId.Should().Match(taskDetails.TaskId); + if (taskDispatchEvent.Inputs.Count > 0) + { + AssertInputArtifactsForTaskDispatch(workflowRevisionTask, workflowInstance.PayloadId, taskDispatchEvent.Inputs); + } + + if (taskDispatchEvent.Outputs.Count > 0) + { + AssertOutputArtifactsForTaskDispatch(taskDispatchEvent.Outputs, workflowInstance.PayloadId, workflowInstance.Id, workflowInstanceTask.ExecutionId); + } - taskDetails.Status.Should().Be(TaskExecutionStatus.Dispatched); + workflowInstanceTask.Status.Should().Be(TaskExecutionStatus.Dispatched); } public void AssertPayload(Payload payload, Payload? actualPayload) diff --git a/tests/IntegrationTests/WorkflowExecutor.IntegrationTests/Support/DataHelper.cs b/tests/IntegrationTests/WorkflowExecutor.IntegrationTests/Support/DataHelper.cs index 7d0844cd4..db59c1730 100644 --- a/tests/IntegrationTests/WorkflowExecutor.IntegrationTests/Support/DataHelper.cs +++ b/tests/IntegrationTests/WorkflowExecutor.IntegrationTests/Support/DataHelper.cs @@ -38,15 +38,17 @@ public class DataHelper private RetryPolicy> RetryPayloadCollections { get; set; } private RabbitConsumer TaskDispatchConsumer { get; set; } private MongoClientUtil MongoClient { get; set; } - public string PayloadId { get; private set; } - + public string PayloadId { get; private set; } + public string BucketId { get; internal set; } + public List SeededWorkflowInstances { get; internal set; } + public DataHelper(RabbitConsumer taskDispatchConsumer, MongoClientUtil mongoClient) { TaskDispatchConsumer = taskDispatchConsumer; MongoClient = mongoClient; - RetryWorkflowInstances = Policy>.Handle().WaitAndRetry(retryCount: 10, sleepDurationProvider: _ => TimeSpan.FromMilliseconds(500)); - RetryTaskDispatches = Policy>.Handle().WaitAndRetry(retryCount: 10, sleepDurationProvider: _ => TimeSpan.FromMilliseconds(500)); - RetryPayloadCollections = Policy>.Handle().WaitAndRetry(retryCount: 10, sleepDurationProvider: _ => TimeSpan.FromMilliseconds(500)); + RetryWorkflowInstances = Policy>.Handle().WaitAndRetry(retryCount: 20, sleepDurationProvider: _ => TimeSpan.FromMilliseconds(500)); + RetryTaskDispatches = Policy>.Handle().WaitAndRetry(retryCount: 20, sleepDurationProvider: _ => TimeSpan.FromMilliseconds(500)); + RetryPayloadCollections = Policy>.Handle().WaitAndRetry(retryCount: 20, sleepDurationProvider: _ => TimeSpan.FromMilliseconds(500)); } public WorkflowRevision GetWorkflowRevisionTestData(string name) diff --git a/tests/IntegrationTests/WorkflowExecutor.IntegrationTests/Support/MinioClientUtil.cs b/tests/IntegrationTests/WorkflowExecutor.IntegrationTests/Support/MinioClientUtil.cs index b05032e0d..39c85c62c 100644 --- a/tests/IntegrationTests/WorkflowExecutor.IntegrationTests/Support/MinioClientUtil.cs +++ b/tests/IntegrationTests/WorkflowExecutor.IntegrationTests/Support/MinioClientUtil.cs @@ -84,19 +84,19 @@ await RetryPolicy.ExecuteAsync(async () => }); } - public async Task AddFileToStorage(string fileLocation, string bucketName, string objectName) + public async Task AddFileToStorage(string localPath, string folderPath) { await RetryPolicy.ExecuteAsync(async () => { try { - FileAttributes fileAttributes = File.GetAttributes(fileLocation); + FileAttributes fileAttributes = File.GetAttributes(localPath); if (fileAttributes.HasFlag(FileAttributes.Directory)) { - var files = Directory.GetFiles($"{fileLocation}", "*.*", SearchOption.AllDirectories); + var files = Directory.GetFiles($"{localPath}", "*.*", SearchOption.AllDirectories); foreach (var file in files) { - var relativePath = $"{objectName}/dcm/{Path.GetRelativePath(fileLocation, file)}"; + var relativePath = $"{folderPath}{Path.GetRelativePath(localPath, file)}"; var fileName = Path.GetFileName(file); byte[] bs = File.ReadAllBytes(file); using (var filestream = new MemoryStream(bs)) @@ -107,7 +107,7 @@ await RetryPolicy.ExecuteAsync(async () => { "Test-Metadata", "Test Test" } }; await Client.PutObjectAsync( - bucketName, + TestExecutionConfig.MinioConfig.Bucket, relativePath, file, "application/octet-stream", @@ -117,18 +117,18 @@ await Client.PutObjectAsync( } else { - byte[] bs = File.ReadAllBytes(fileLocation); + byte[] bs = File.ReadAllBytes(localPath); using (MemoryStream filestream = new MemoryStream(bs)) { - FileInfo fileInfo = new FileInfo(fileLocation); + FileInfo fileInfo = new FileInfo(localPath); var metaData = new Dictionary { { "Test-Metadata", "Test Test" } }; await Client.PutObjectAsync( - bucketName, - objectName, - fileLocation, + TestExecutionConfig.MinioConfig.Bucket, + folderPath, + localPath, "application/octet-stream", metaData); } @@ -146,6 +146,22 @@ public async Task GetFile(string bucketName, string objectName, string fileName) await Client.GetObjectAsync(bucketName, objectName, fileName); } + public async Task CheckFileExists(string bucketName, string objectName) + { + var args = new StatObjectArgs() + .WithBucket(bucketName) + .WithObject(objectName); + try + { + await Client.StatObjectAsync(args); + } + catch (Exception) + { + return false; + } + return true; + } + public async Task DeleteBucket(string bucketName) { bool found = await Client.BucketExistsAsync(bucketName); diff --git a/tests/IntegrationTests/WorkflowExecutor.IntegrationTests/Support/MinioDataSeeding.cs b/tests/IntegrationTests/WorkflowExecutor.IntegrationTests/Support/MinioDataSeeding.cs new file mode 100644 index 000000000..3eb3b76b8 --- /dev/null +++ b/tests/IntegrationTests/WorkflowExecutor.IntegrationTests/Support/MinioDataSeeding.cs @@ -0,0 +1,89 @@ +/* + * Copyright 2022 MONAI Consortium + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +using System.Reflection; +using Monai.Deploy.WorkflowManager.IntegrationTests.POCO; +using Monai.Deploy.WorkflowManager.IntegrationTests.Support; +using TechTalk.SpecFlow.Infrastructure; + +namespace Monai.Deploy.WorkflowManager.WorkflowExecutor.IntegrationTests.Support +{ + public class MinioDataSeeding + { + private MinioClientUtil MinioClient { get; set; } + + private DataHelper DataHelper { get; set; } + + private ISpecFlowOutputHelper OutputHelper { get; set; } + + public MinioDataSeeding(MinioClientUtil minioClient, DataHelper dataHelper, ISpecFlowOutputHelper outputHelper) + { + MinioClient = minioClient; + DataHelper = dataHelper; + OutputHelper = outputHelper; + } + + public async Task SeedWorkflowInputArtifacts(string payloadId, string? folderName = null) + { + string localPath; + + if (string.IsNullOrEmpty(folderName)) + { + OutputHelper.WriteLine($"folderName not specified. Seeding Minio with objects from **/DICOMs/full_patient_metadata/dcm/"); + + localPath = Path.Combine(GetDirectory(), "DICOMs", "full_patient_metadata", "dcm"); + } + else + { + OutputHelper.WriteLine($"Seeding Minio with artifacts from **/DICOMs/{folderName}/dcm/"); + + localPath = Path.Combine(GetDirectory(), "DICOMs", folderName, "dcm"); + } + + OutputHelper.WriteLine($"Seeding objects to {TestExecutionConfig.MinioConfig.Bucket}/{payloadId}/dcm/"); + await MinioClient.AddFileToStorage(localPath, $"{payloadId}/dcm/"); + OutputHelper.WriteLine($"Objects seeded"); + } + + public async Task SeedTaskOutputArtifacts(string payloadId, string workflowInstanceId, string executionId, string? folderName = null) + { + string localPath; + + if (string.IsNullOrEmpty(folderName)) + { + OutputHelper.WriteLine($"folderName not specified. Seeding Minio with objects from **/DICOMs/output_metadata/dcm/"); + + localPath = Path.Combine(GetDirectory(), "DICOMs", "output_metadata", "dcm"); + } + else + { + OutputHelper.WriteLine($"Seeding Minio with objects from **/DICOMs/{folderName}/dcm/"); + + localPath = Path.Combine(GetDirectory(), "DICOMs", folderName, "dcm"); + } + + OutputHelper.WriteLine($"Seeding objects to {TestExecutionConfig.MinioConfig.Bucket}/{payloadId}/workflows/{workflowInstanceId}/{executionId}/"); + await MinioClient.AddFileToStorage(localPath, $"{payloadId}/workflows/{workflowInstanceId}/{executionId}/"); + OutputHelper.WriteLine($"Objects seeded"); + } + + private string GetDirectory() + { + return Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location); + } + + } +} diff --git a/tests/IntegrationTests/WorkflowExecutor.IntegrationTests/Support/MongoClientUtil.cs b/tests/IntegrationTests/WorkflowExecutor.IntegrationTests/Support/MongoClientUtil.cs index 88680374d..cb2e29480 100644 --- a/tests/IntegrationTests/WorkflowExecutor.IntegrationTests/Support/MongoClientUtil.cs +++ b/tests/IntegrationTests/WorkflowExecutor.IntegrationTests/Support/MongoClientUtil.cs @@ -61,6 +61,14 @@ public void DeleteWorkflowRevisionDocument(string id) } public void DeleteWorkflowRevisionDocumentByWorkflowId(string workflowId) + { + RetryMongo.Execute(() => + { + WorkflowRevisionCollection.DeleteMany(x => x.WorkflowId.Equals(workflowId)); + }); + } + + public void DeleteWorkflowRevisions(string workflowId) { RetryMongo.Execute(() => { @@ -70,7 +78,17 @@ public void DeleteWorkflowRevisionDocumentByWorkflowId(string workflowId) public void DeleteAllWorkflowRevisionDocuments() { - WorkflowRevisionCollection.DeleteMany("{ }"); + RetryMongo.Execute(() => + { + WorkflowRevisionCollection.DeleteMany("{ }"); + + var workflows = WorkflowRevisionCollection.Find("{ }").ToList(); + + if (workflows.Count > 0) + { + throw new Exception("All workflows are not deleted!"); + } + }); } public List GetWorkflowRevisionsByWorkflowId(string workflowId) @@ -104,8 +122,18 @@ public List GetWorkflowInstancesByPayloadId(string payloadId) } public void DeleteAllWorkflowInstances() - { - WorkflowInstanceCollection.DeleteMany("{ }"); + { + RetryMongo.Execute(() => + { + WorkflowInstanceCollection.DeleteMany("{ }"); + + var workflowInstances = WorkflowInstanceCollection.Find("{ }").ToList(); + + if (workflowInstances.Count > 0) + { + throw new Exception("All workflows instances are not deleted!"); + } + }); } public void DeleteWorkflowInstance(string id) @@ -159,8 +187,18 @@ public void DeletePayloadDocumentByPayloadId(string payloadId) } public void DeleteAllPayloadDocuments() - { - PayloadCollection.DeleteMany("{ }"); + { + RetryMongo.Execute(() => + { + PayloadCollection.DeleteMany("{ }"); + + var payloads = PayloadCollection.Find("{ }").ToList(); + + if (payloads.Count > 0) + { + throw new Exception("All payloads are not deleted!"); + } + }); } #endregion diff --git a/tests/IntegrationTests/WorkflowExecutor.IntegrationTests/TestData/TaskUpdateTestData.cs b/tests/IntegrationTests/WorkflowExecutor.IntegrationTests/TestData/TaskUpdateTestData.cs index aa626ba6f..cf2be80b5 100644 --- a/tests/IntegrationTests/WorkflowExecutor.IntegrationTests/TestData/TaskUpdateTestData.cs +++ b/tests/IntegrationTests/WorkflowExecutor.IntegrationTests/TestData/TaskUpdateTestData.cs @@ -1,421 +1,493 @@ -/* - * Copyright 2022 MONAI Consortium - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -using Monai.Deploy.Messaging.Events; - -namespace Monai.Deploy.WorkflowManager.WorkflowExecutor.IntegrationTests.TestData -{ - public class TaskUpdateTestData - { - public string? Name { get; set; } - - public TaskUpdateEvent? TaskUpdateEvent { get; set; } - } - - public static class TaskUpdatesTestData - { - public static List TestData = new List() - { - new TaskUpdateTestData() - { - Name = "Task_status_update_for_bucket_minio", - TaskUpdateEvent = new TaskUpdateEvent() - { - WorkflowInstanceId = Helper.GetWorkflowInstanceByName("Workflow_instance_for_bucket_minio").WorkflowInstance.Id, - ExecutionId = Helper.GetWorkflowInstanceByName("Workflow_instance_for_bucket_minio").WorkflowInstance.Tasks[0].ExecutionId, - CorrelationId = Guid.NewGuid().ToString(), - Status = TaskExecutionStatus.Succeeded, - Reason = FailureReason.None, - Message = "Task Message", - TaskId = Helper.GetWorkflowInstanceByName("Workflow_instance_for_bucket_minio").WorkflowInstance.Tasks[0].TaskId, - Metadata = new Dictionary() - { - } - } - }, - new TaskUpdateTestData() - { - Name = "Task_Status_Update", - TaskUpdateEvent = new TaskUpdateEvent() - { - WorkflowInstanceId = Helper.GetWorkflowInstanceByName("WFI_Task_Status_Update").WorkflowInstance.Id, - ExecutionId = Helper.GetWorkflowInstanceByName("WFI_Task_Status_Update").WorkflowInstance.Tasks[0].ExecutionId, - CorrelationId = Guid.NewGuid().ToString(), - Status = TaskExecutionStatus.Unknown, - Reason = FailureReason.None, - Message = "Task Message", - TaskId = Helper.GetWorkflowInstanceByName("WFI_Task_Status_Update").WorkflowInstance.Tasks[0].TaskId, - Metadata = new Dictionary() - { - } - } - }, - new TaskUpdateTestData() - { - Name = "Task_Status_Update_TaskId_Not_Found", - TaskUpdateEvent = new TaskUpdateEvent() - { - WorkflowInstanceId = Helper.GetWorkflowInstanceByName("WFI_Task_Status_Update").WorkflowInstance.Id, - ExecutionId = Helper.GetWorkflowInstanceByName("WFI_Task_Status_Update").WorkflowInstance.Tasks[0].ExecutionId, - CorrelationId = Guid.NewGuid().ToString(), - Status = TaskExecutionStatus.Unknown, - Reason = FailureReason.None, - Message = "Task Message", - TaskId = "303c441f-7181-43cf-b1fd-83e5acec99fa", - Metadata = new Dictionary() - { - } - } - }, - new TaskUpdateTestData() - { - Name = "Task_Status_Update_Missing_TaskId", - TaskUpdateEvent = new TaskUpdateEvent() - { - WorkflowInstanceId = Helper.GetWorkflowInstanceByName("WFI_Task_Status_Update").WorkflowInstance.Id, - ExecutionId = Helper.GetWorkflowInstanceByName("WFI_Task_Status_Update").WorkflowInstance.Tasks[0].ExecutionId, - CorrelationId = Guid.NewGuid().ToString(), - Status = TaskExecutionStatus.Unknown, - Reason = FailureReason.None, - Message = "Task Message", - Metadata = new Dictionary() - { - } - } - }, - new TaskUpdateTestData() - { - Name = "Task_Status_Update_Missing_ExecutionId", - TaskUpdateEvent = new TaskUpdateEvent() - { - WorkflowInstanceId = Helper.GetWorkflowInstanceByName("WFI_Task_Status_Update").WorkflowInstance.Id, - CorrelationId = Guid.NewGuid().ToString(), - Status = TaskExecutionStatus.Unknown, - Reason = FailureReason.None, - Message = "Task Message", - TaskId = Helper.GetWorkflowInstanceByName("WFI_Task_Status_Update").WorkflowInstance.Tasks[0].TaskId, - Metadata = new Dictionary() - { - } - } - }, - new TaskUpdateTestData() - { - Name = "Task_Status_Update_Missing_CorrelationId", - TaskUpdateEvent = new TaskUpdateEvent() - { - WorkflowInstanceId = Helper.GetWorkflowInstanceByName("WFI_Task_Status_Update").WorkflowInstance.Id, - ExecutionId = Helper.GetWorkflowInstanceByName("WFI_Task_Status_Update").WorkflowInstance.Tasks[0].ExecutionId, - Status = TaskExecutionStatus.Unknown, - Reason = FailureReason.None, - Message = "Task Message", - TaskId = Helper.GetWorkflowInstanceByName("WFI_Task_Status_Update").WorkflowInstance.Tasks[0].TaskId, - Metadata = new Dictionary() - { - } - } - }, - new TaskUpdateTestData() - { - Name = "Task_Status_Update_Missing_Status", - TaskUpdateEvent = new TaskUpdateEvent() - { - WorkflowInstanceId = Helper.GetWorkflowInstanceByName("WFI_Task_Status_Update").WorkflowInstance.Id, - ExecutionId = Helper.GetWorkflowInstanceByName("WFI_Task_Status_Update").WorkflowInstance.Tasks[0].ExecutionId, - CorrelationId = Guid.NewGuid().ToString(), - Reason = FailureReason.None, - Message = "Task Message", - TaskId = Helper.GetWorkflowInstanceByName("WFI_Task_Status_Update").WorkflowInstance.Tasks[0].TaskId, - Metadata = new Dictionary() - { - } - } - }, - new TaskUpdateTestData() - { - Name = "Task_Status_Update_Status_Invalid_When_Succeeded", - TaskUpdateEvent = new TaskUpdateEvent() - { - WorkflowInstanceId = Helper.GetWorkflowInstanceByName("WFI_Task_Status_Succeeded").WorkflowInstance.Id, - ExecutionId = Helper.GetWorkflowInstanceByName("WFI_Task_Status_Succeeded").WorkflowInstance.Tasks[0].ExecutionId, - CorrelationId = Guid.NewGuid().ToString(), - Reason = FailureReason.None, - Message = "Task Message", - TaskId = Helper.GetWorkflowInstanceByName("WFI_Task_Status_Succeeded").WorkflowInstance.Tasks[0].TaskId, - Metadata = new Dictionary() - { - } - } - }, - new TaskUpdateTestData() - { - Name = "Task_Status_Update_Status_Invalid_When_Failed", - TaskUpdateEvent = new TaskUpdateEvent() - { - WorkflowInstanceId = Helper.GetWorkflowInstanceByName("WFI_Task_Status_Failed").WorkflowInstance.Id, - ExecutionId = Helper.GetWorkflowInstanceByName("WFI_Task_Status_Failed").WorkflowInstance.Tasks[0].ExecutionId, - CorrelationId = Guid.NewGuid().ToString(), - Reason = FailureReason.None, - Message = "Task Message", - TaskId = Helper.GetWorkflowInstanceByName("WFI_Task_Status_Failed").WorkflowInstance.Tasks[0].TaskId, - Metadata = new Dictionary() - { - } - } - }, - new TaskUpdateTestData() - { - Name = "Task_Status_Update_Status_Invalid_When_Canceled", - TaskUpdateEvent = new TaskUpdateEvent() - { - WorkflowInstanceId = Helper.GetWorkflowInstanceByName("WFI_Task_Status_Canceled").WorkflowInstance.Id, - ExecutionId = Helper.GetWorkflowInstanceByName("WFI_Task_Status_Canceled").WorkflowInstance.Tasks[0].ExecutionId, - CorrelationId = Guid.NewGuid().ToString(), - Reason = FailureReason.None, - Message = "Task Message", - TaskId = Helper.GetWorkflowInstanceByName("WFI_Task_Status_Canceled").WorkflowInstance.Tasks[0].TaskId, - Metadata = new Dictionary() - { - } - } - }, - new TaskUpdateTestData() - { - Name = "Task_Update_Dispatches_Single_Task", - TaskUpdateEvent = new TaskUpdateEvent() - { - WorkflowInstanceId = Helper.GetWorkflowInstanceByName("WFI_Multi_Task_1").WorkflowInstance.Id, - ExecutionId = Helper.GetWorkflowInstanceByName("WFI_Multi_Task_1").WorkflowInstance.Tasks[0].ExecutionId, - CorrelationId = Guid.NewGuid().ToString(), - Reason = FailureReason.None, - Message = "Task Message", - TaskId = Helper.GetWorkflowInstanceByName("WFI_Multi_Task_1").WorkflowInstance.Tasks[0].TaskId, - Metadata = new Dictionary() - { - } - } - }, - new TaskUpdateTestData() - { - Name = "Task_Update_Dispatches_Multi_Tasks", - TaskUpdateEvent = new TaskUpdateEvent() - { - WorkflowInstanceId = Helper.GetWorkflowInstanceByName("WFI_Multi_Task_2").WorkflowInstance.Id, - ExecutionId = Helper.GetWorkflowInstanceByName("WFI_Multi_Task_2").WorkflowInstance.Tasks[0].ExecutionId, - CorrelationId = Guid.NewGuid().ToString(), - Reason = FailureReason.None, - Message = "Task Message", - TaskId = Helper.GetWorkflowInstanceByName("WFI_Multi_Task_2").WorkflowInstance.Tasks[0].TaskId, - Metadata = new Dictionary() - { - } - } - }, - new TaskUpdateTestData() - { - Name = "Task_Update_To_Dispatch_Single_Task", - TaskUpdateEvent = new TaskUpdateEvent() - { - WorkflowInstanceId = Helper.GetWorkflowInstanceByName("WFI_Multi_Task_3").WorkflowInstance.Id, - ExecutionId = Helper.GetWorkflowInstanceByName("WFI_Multi_Task_3").WorkflowInstance.Tasks[0].ExecutionId, - CorrelationId = Guid.NewGuid().ToString(), - Reason = FailureReason.None, - Message = "Task Message", - TaskId = Helper.GetWorkflowInstanceByName("WFI_Multi_Task_3").WorkflowInstance.Tasks[0].TaskId, - Metadata = new Dictionary() - { - } - } - }, - new TaskUpdateTestData() - { - Name = "Task_Update_Independent_Task", - TaskUpdateEvent = new TaskUpdateEvent() - { - WorkflowInstanceId = Helper.GetWorkflowInstanceByName("WFI_Multi_Independent_Task").WorkflowInstance.Id, - ExecutionId = Helper.GetWorkflowInstanceByName("WFI_Multi_Independent_Task").WorkflowInstance.Tasks[0].ExecutionId, - CorrelationId = Guid.NewGuid().ToString(), - Reason = FailureReason.None, - Message = "Task Message", - TaskId = Helper.GetWorkflowInstanceByName("WFI_Multi_Independent_Task").WorkflowInstance.Tasks[0].TaskId, - Metadata = new Dictionary() - { - } - } - }, - new TaskUpdateTestData() - { - Name = "Task_Update_Independent_Task", - TaskUpdateEvent = new TaskUpdateEvent() - { - WorkflowInstanceId = Helper.GetWorkflowInstanceByName("WFI_Multi_Independent_Task").WorkflowInstance.Id, - ExecutionId = Helper.GetWorkflowInstanceByName("WFI_Multi_Independent_Task").WorkflowInstance.Tasks[0].ExecutionId, - CorrelationId = Guid.NewGuid().ToString(), - Reason = FailureReason.None, - Message = "Task Message", - TaskId = Helper.GetWorkflowInstanceByName("WFI_Multi_Independent_Task").WorkflowInstance.Tasks[0].TaskId, - Metadata = new Dictionary() - { - } - } - }, - new TaskUpdateTestData() - { - Name = "Task_Update_Invalid_Task_Destination", - TaskUpdateEvent = new TaskUpdateEvent() - { - WorkflowInstanceId = Helper.GetWorkflowInstanceByName("WFI_Invalid_Task_Destination").WorkflowInstance.Id, - ExecutionId = Helper.GetWorkflowInstanceByName("WFI_Invalid_Task_Destination").WorkflowInstance.Tasks[0].ExecutionId, - CorrelationId = Guid.NewGuid().ToString(), - Reason = FailureReason.None, - Message = "Task Message", - TaskId = Helper.GetWorkflowInstanceByName("WFI_Invalid_Task_Destination").WorkflowInstance.Tasks[0].TaskId, - Metadata = new Dictionary() - { - } - } - }, - new TaskUpdateTestData() - { - Name = "output_artefact_file", - TaskUpdateEvent = new TaskUpdateEvent() - { - WorkflowInstanceId = Helper.GetWorkflowInstanceByName("WFI_Invalid_Task_Destination").WorkflowInstance.Id, - ExecutionId = Helper.GetWorkflowInstanceByName("WFI_Invalid_Task_Destination").WorkflowInstance.Tasks[0].ExecutionId, - CorrelationId = Guid.NewGuid().ToString(), - Reason = FailureReason.None, - Message = "Task Message", - TaskId = Helper.GetWorkflowInstanceByName("WFI_Invalid_Task_Destination").WorkflowInstance.Tasks[0].TaskId, - Metadata = new Dictionary() - { - } - } - }, - new TaskUpdateTestData() - { - Name = "output_artefact_dir", - TaskUpdateEvent = new TaskUpdateEvent() - { - WorkflowInstanceId = Helper.GetWorkflowInstanceByName("WFI_Invalid_Task_Destination").WorkflowInstance.Id, - ExecutionId = Helper.GetWorkflowInstanceByName("WFI_Invalid_Task_Destination").WorkflowInstance.Tasks[0].ExecutionId, - CorrelationId = Guid.NewGuid().ToString(), - Reason = FailureReason.None, - Message = "Task Message", - TaskId = Helper.GetWorkflowInstanceByName("WFI_Invalid_Task_Destination").WorkflowInstance.Tasks[0].TaskId, - Metadata = new Dictionary() - { - } - } - }, - new TaskUpdateTestData() - { - Name = "Task_Update_Task_Destination_Condition_True", - TaskUpdateEvent = new TaskUpdateEvent() - { - WorkflowInstanceId = Helper.GetWorkflowInstanceByName("WFI_Task_Destination_Condition_True").WorkflowInstance.Id, - ExecutionId = Helper.GetWorkflowInstanceByName("WFI_Task_Destination_Condition_True").WorkflowInstance.Tasks[0].ExecutionId, - CorrelationId = Guid.NewGuid().ToString(), - Reason = FailureReason.None, - Message = "Task Message", - TaskId = Helper.GetWorkflowInstanceByName("WFI_Task_Destination_Condition_True").WorkflowInstance.Tasks[0].TaskId, - Metadata = new Dictionary() - { - } - } - }, - new TaskUpdateTestData() - { - Name = "Task_Update_Task_Destination_Condition_False", - TaskUpdateEvent = new TaskUpdateEvent() - { - WorkflowInstanceId = Helper.GetWorkflowInstanceByName("WFI_Task_Destination_Condition_False").WorkflowInstance.Id, - ExecutionId = Helper.GetWorkflowInstanceByName("WFI_Task_Destination_Condition_False").WorkflowInstance.Tasks[0].ExecutionId, - CorrelationId = Guid.NewGuid().ToString(), - Reason = FailureReason.None, - Message = "Task Message", - TaskId = Helper.GetWorkflowInstanceByName("WFI_Task_Destination_Condition_False").WorkflowInstance.Tasks[0].TaskId, - Metadata = new Dictionary() - { - } - } - }, - new TaskUpdateTestData() - { - Name = "Task_Update_Task_Multiple_Destination_Condition_True", - TaskUpdateEvent = new TaskUpdateEvent() - { - WorkflowInstanceId = Helper.GetWorkflowInstanceByName("WFI_Task_Multiple_Destination_Condition_True").WorkflowInstance.Id, - ExecutionId = Helper.GetWorkflowInstanceByName("WFI_Task_Multiple_Destination_Condition_True").WorkflowInstance.Tasks[0].ExecutionId, - CorrelationId = Guid.NewGuid().ToString(), - Reason = FailureReason.None, - Message = "Task Message", - TaskId = Helper.GetWorkflowInstanceByName("WFI_Task_Multiple_Destination_Condition_True").WorkflowInstance.Tasks[0].TaskId, - Metadata = new Dictionary() - { - } - } - }, - new TaskUpdateTestData() - { - Name = "Task_Update_Task_Multiple_Destination_Condition_False", - TaskUpdateEvent = new TaskUpdateEvent() - { - WorkflowInstanceId = Helper.GetWorkflowInstanceByName("WFI_Task_Multiple_Destination_Condition_False").WorkflowInstance.Id, - ExecutionId = Helper.GetWorkflowInstanceByName("WFI_Task_Multiple_Destination_Condition_False").WorkflowInstance.Tasks[0].ExecutionId, - CorrelationId = Guid.NewGuid().ToString(), - Reason = FailureReason.None, - Message = "Task Message", - TaskId = Helper.GetWorkflowInstanceByName("WFI_Task_Multiple_Destination_Condition_False").WorkflowInstance.Tasks[0].TaskId, - Metadata = new Dictionary() - { - } - } - }, - new TaskUpdateTestData() - { - Name = "Task_Update_Task_Destination_Condition_True_And_False", - TaskUpdateEvent = new TaskUpdateEvent() - { - WorkflowInstanceId = Helper.GetWorkflowInstanceByName("WFI_Task_Destination_Condition_True_And_False").WorkflowInstance.Id, - ExecutionId = Helper.GetWorkflowInstanceByName("WFI_Task_Destination_Condition_True_And_False").WorkflowInstance.Tasks[0].ExecutionId, - CorrelationId = Guid.NewGuid().ToString(), - Reason = FailureReason.None, - Message = "Task Message", - TaskId = Helper.GetWorkflowInstanceByName("WFI_Task_Destination_Condition_True_And_False").WorkflowInstance.Tasks[0].TaskId, - Metadata = new Dictionary() - { - } - } - }, - new TaskUpdateTestData() - { - Name = "Task_Update_Task_Destination_Invalid_Condition", - TaskUpdateEvent = new TaskUpdateEvent() - { - WorkflowInstanceId = Helper.GetWorkflowInstanceByName("WFI_Task_Destination_Invalid_Condition").WorkflowInstance.Id, - ExecutionId = Helper.GetWorkflowInstanceByName("WFI_Task_Destination_Invalid_Condition").WorkflowInstance.Tasks[0].ExecutionId, - CorrelationId = Guid.NewGuid().ToString(), - Reason = FailureReason.None, - Message = "Task Message", - TaskId = Helper.GetWorkflowInstanceByName("WFI_Task_Destination_Invalid_Condition").WorkflowInstance.Tasks[0].TaskId, - Metadata = new Dictionary() - { - } - } - }, - }; - } -} +/* + * Copyright 2022 MONAI Consortium + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +using Monai.Deploy.Messaging.Events; + +namespace Monai.Deploy.WorkflowManager.WorkflowExecutor.IntegrationTests.TestData +{ + public class TaskUpdateTestData + { + public string? Name { get; set; } + + public TaskUpdateEvent? TaskUpdateEvent { get; set; } + } + + public static class TaskUpdatesTestData + { + public static string GetRelativePathForOutputArtifacts(string name) + { + var workflowInstance = Helper.GetWorkflowInstanceByName(name)?.WorkflowInstance; + + var executionId = workflowInstance?.Tasks.FirstOrDefault(x => x.Status.Equals(TaskExecutionStatus.Accepted))?.ExecutionId; + + return $"{workflowInstance?.PayloadId}/workflows/{workflowInstance?.Id}/{executionId}"; + } + + public static List TestData = new List() + { + new TaskUpdateTestData() + { + Name = "Task_status_update_for_bucket_minio", + TaskUpdateEvent = new TaskUpdateEvent() + { + WorkflowInstanceId = Helper.GetWorkflowInstanceByName("Workflow_instance_for_bucket_minio").WorkflowInstance.Id, + ExecutionId = Helper.GetWorkflowInstanceByName("Workflow_instance_for_bucket_minio").WorkflowInstance.Tasks[0].ExecutionId, + CorrelationId = Guid.NewGuid().ToString(), + Status = TaskExecutionStatus.Succeeded, + Reason = FailureReason.None, + Message = "Task Message", + TaskId = Helper.GetWorkflowInstanceByName("Workflow_instance_for_bucket_minio").WorkflowInstance.Tasks[0].TaskId, + Metadata = new Dictionary() + { + } + } + }, + new TaskUpdateTestData() + { + Name = "Task_Status_Update", + TaskUpdateEvent = new TaskUpdateEvent() + { + WorkflowInstanceId = Helper.GetWorkflowInstanceByName("WFI_Task_Status_Update").WorkflowInstance.Id, + ExecutionId = Helper.GetWorkflowInstanceByName("WFI_Task_Status_Update").WorkflowInstance.Tasks[0].ExecutionId, + CorrelationId = Guid.NewGuid().ToString(), + Status = TaskExecutionStatus.Unknown, + Reason = FailureReason.None, + Message = "Task Message", + TaskId = Helper.GetWorkflowInstanceByName("WFI_Task_Status_Update").WorkflowInstance.Tasks[0].TaskId, + Metadata = new Dictionary() + { + } + } + }, + new TaskUpdateTestData() + { + Name = "Task_Status_Update_TaskId_Not_Found", + TaskUpdateEvent = new TaskUpdateEvent() + { + WorkflowInstanceId = Helper.GetWorkflowInstanceByName("WFI_Task_Status_Update").WorkflowInstance.Id, + ExecutionId = Helper.GetWorkflowInstanceByName("WFI_Task_Status_Update").WorkflowInstance.Tasks[0].ExecutionId, + CorrelationId = Guid.NewGuid().ToString(), + Status = TaskExecutionStatus.Unknown, + Reason = FailureReason.None, + Message = "Task Message", + TaskId = "303c441f-7181-43cf-b1fd-83e5acec99fa", + Metadata = new Dictionary() + { + } + } + }, + new TaskUpdateTestData() + { + Name = "Task_Status_Update_Missing_TaskId", + TaskUpdateEvent = new TaskUpdateEvent() + { + WorkflowInstanceId = Helper.GetWorkflowInstanceByName("WFI_Task_Status_Update").WorkflowInstance.Id, + ExecutionId = Helper.GetWorkflowInstanceByName("WFI_Task_Status_Update").WorkflowInstance.Tasks[0].ExecutionId, + CorrelationId = Guid.NewGuid().ToString(), + Status = TaskExecutionStatus.Unknown, + Reason = FailureReason.None, + Message = "Task Message", + Metadata = new Dictionary() + { + } + } + }, + new TaskUpdateTestData() + { + Name = "Task_Status_Update_Missing_ExecutionId", + TaskUpdateEvent = new TaskUpdateEvent() + { + WorkflowInstanceId = Helper.GetWorkflowInstanceByName("WFI_Task_Status_Update").WorkflowInstance.Id, + CorrelationId = Guid.NewGuid().ToString(), + Status = TaskExecutionStatus.Unknown, + Reason = FailureReason.None, + Message = "Task Message", + TaskId = Helper.GetWorkflowInstanceByName("WFI_Task_Status_Update").WorkflowInstance.Tasks[0].TaskId, + Metadata = new Dictionary() + { + } + } + }, + new TaskUpdateTestData() + { + Name = "Task_Status_Update_Missing_CorrelationId", + TaskUpdateEvent = new TaskUpdateEvent() + { + WorkflowInstanceId = Helper.GetWorkflowInstanceByName("WFI_Task_Status_Update").WorkflowInstance.Id, + ExecutionId = Helper.GetWorkflowInstanceByName("WFI_Task_Status_Update").WorkflowInstance.Tasks[0].ExecutionId, + Status = TaskExecutionStatus.Unknown, + Reason = FailureReason.None, + Message = "Task Message", + TaskId = Helper.GetWorkflowInstanceByName("WFI_Task_Status_Update").WorkflowInstance.Tasks[0].TaskId, + Metadata = new Dictionary() + { + } + } + }, + new TaskUpdateTestData() + { + Name = "Task_Status_Update_Missing_Status", + TaskUpdateEvent = new TaskUpdateEvent() + { + WorkflowInstanceId = Helper.GetWorkflowInstanceByName("WFI_Task_Status_Update").WorkflowInstance.Id, + ExecutionId = Helper.GetWorkflowInstanceByName("WFI_Task_Status_Update").WorkflowInstance.Tasks[0].ExecutionId, + CorrelationId = Guid.NewGuid().ToString(), + Reason = FailureReason.None, + Message = "Task Message", + TaskId = Helper.GetWorkflowInstanceByName("WFI_Task_Status_Update").WorkflowInstance.Tasks[0].TaskId, + Metadata = new Dictionary() + { + } + } + }, + new TaskUpdateTestData() + { + Name = "Task_Status_Update_Status_Invalid_When_Succeeded", + TaskUpdateEvent = new TaskUpdateEvent() + { + WorkflowInstanceId = Helper.GetWorkflowInstanceByName("WFI_Task_Status_Succeeded").WorkflowInstance.Id, + ExecutionId = Helper.GetWorkflowInstanceByName("WFI_Task_Status_Succeeded").WorkflowInstance.Tasks[0].ExecutionId, + CorrelationId = Guid.NewGuid().ToString(), + Reason = FailureReason.None, + Message = "Task Message", + TaskId = Helper.GetWorkflowInstanceByName("WFI_Task_Status_Succeeded").WorkflowInstance.Tasks[0].TaskId, + Metadata = new Dictionary() + { + } + } + }, + new TaskUpdateTestData() + { + Name = "Task_Status_Update_Status_Invalid_When_Failed", + TaskUpdateEvent = new TaskUpdateEvent() + { + WorkflowInstanceId = Helper.GetWorkflowInstanceByName("WFI_Task_Status_Failed").WorkflowInstance.Id, + ExecutionId = Helper.GetWorkflowInstanceByName("WFI_Task_Status_Failed").WorkflowInstance.Tasks[0].ExecutionId, + CorrelationId = Guid.NewGuid().ToString(), + Reason = FailureReason.None, + Message = "Task Message", + TaskId = Helper.GetWorkflowInstanceByName("WFI_Task_Status_Failed").WorkflowInstance.Tasks[0].TaskId, + Metadata = new Dictionary() + { + } + } + }, + new TaskUpdateTestData() + { + Name = "Task_Status_Update_Status_Invalid_When_Canceled", + TaskUpdateEvent = new TaskUpdateEvent() + { + WorkflowInstanceId = Helper.GetWorkflowInstanceByName("WFI_Task_Status_Canceled").WorkflowInstance.Id, + ExecutionId = Helper.GetWorkflowInstanceByName("WFI_Task_Status_Canceled").WorkflowInstance.Tasks[0].ExecutionId, + CorrelationId = Guid.NewGuid().ToString(), + Reason = FailureReason.None, + Message = "Task Message", + TaskId = Helper.GetWorkflowInstanceByName("WFI_Task_Status_Canceled").WorkflowInstance.Tasks[0].TaskId, + Metadata = new Dictionary() + { + } + } + }, + new TaskUpdateTestData() + { + Name = "Task_Update_Dispatches_Single_Task", + TaskUpdateEvent = new TaskUpdateEvent() + { + WorkflowInstanceId = Helper.GetWorkflowInstanceByName("WFI_Multi_Task_1").WorkflowInstance.Id, + ExecutionId = Helper.GetWorkflowInstanceByName("WFI_Multi_Task_1").WorkflowInstance.Tasks[0].ExecutionId, + CorrelationId = Guid.NewGuid().ToString(), + Reason = FailureReason.None, + Message = "Task Message", + TaskId = Helper.GetWorkflowInstanceByName("WFI_Multi_Task_1").WorkflowInstance.Tasks[0].TaskId, + Metadata = new Dictionary() + { + } + } + }, + new TaskUpdateTestData() + { + Name = "Task_Update_Dispatches_Multi_Tasks", + TaskUpdateEvent = new TaskUpdateEvent() + { + WorkflowInstanceId = Helper.GetWorkflowInstanceByName("WFI_Multi_Task_2").WorkflowInstance.Id, + ExecutionId = Helper.GetWorkflowInstanceByName("WFI_Multi_Task_2").WorkflowInstance.Tasks[0].ExecutionId, + CorrelationId = Guid.NewGuid().ToString(), + Reason = FailureReason.None, + Message = "Task Message", + TaskId = Helper.GetWorkflowInstanceByName("WFI_Multi_Task_2").WorkflowInstance.Tasks[0].TaskId, + Metadata = new Dictionary() + { + } + } + }, + new TaskUpdateTestData() + { + Name = "Task_Update_To_Dispatch_Single_Task", + TaskUpdateEvent = new TaskUpdateEvent() + { + WorkflowInstanceId = Helper.GetWorkflowInstanceByName("WFI_Multi_Task_3").WorkflowInstance.Id, + ExecutionId = Helper.GetWorkflowInstanceByName("WFI_Multi_Task_3").WorkflowInstance.Tasks[0].ExecutionId, + CorrelationId = Guid.NewGuid().ToString(), + Reason = FailureReason.None, + Message = "Task Message", + TaskId = Helper.GetWorkflowInstanceByName("WFI_Multi_Task_3").WorkflowInstance.Tasks[0].TaskId, + Metadata = new Dictionary() + { + } + } + }, + new TaskUpdateTestData() + { + Name = "Task_Update_Independent_Task", + TaskUpdateEvent = new TaskUpdateEvent() + { + WorkflowInstanceId = Helper.GetWorkflowInstanceByName("WFI_Multi_Independent_Task").WorkflowInstance.Id, + ExecutionId = Helper.GetWorkflowInstanceByName("WFI_Multi_Independent_Task").WorkflowInstance.Tasks[0].ExecutionId, + CorrelationId = Guid.NewGuid().ToString(), + Reason = FailureReason.None, + Message = "Task Message", + TaskId = Helper.GetWorkflowInstanceByName("WFI_Multi_Independent_Task").WorkflowInstance.Tasks[0].TaskId, + Metadata = new Dictionary() + { + } + } + }, + new TaskUpdateTestData() + { + Name = "Task_Update_Independent_Task", + TaskUpdateEvent = new TaskUpdateEvent() + { + WorkflowInstanceId = Helper.GetWorkflowInstanceByName("WFI_Multi_Independent_Task").WorkflowInstance.Id, + ExecutionId = Helper.GetWorkflowInstanceByName("WFI_Multi_Independent_Task").WorkflowInstance.Tasks[0].ExecutionId, + CorrelationId = Guid.NewGuid().ToString(), + Reason = FailureReason.None, + Message = "Task Message", + TaskId = Helper.GetWorkflowInstanceByName("WFI_Multi_Independent_Task").WorkflowInstance.Tasks[0].TaskId, + Metadata = new Dictionary() + { + } + } + }, + new TaskUpdateTestData() + { + Name = "Task_Update_Invalid_Task_Destination", + TaskUpdateEvent = new TaskUpdateEvent() + { + WorkflowInstanceId = Helper.GetWorkflowInstanceByName("WFI_Invalid_Task_Destination").WorkflowInstance.Id, + ExecutionId = Helper.GetWorkflowInstanceByName("WFI_Invalid_Task_Destination").WorkflowInstance.Tasks[0].ExecutionId, + CorrelationId = Guid.NewGuid().ToString(), + Reason = FailureReason.None, + Message = "Task Message", + TaskId = Helper.GetWorkflowInstanceByName("WFI_Invalid_Task_Destination").WorkflowInstance.Tasks[0].TaskId, + Metadata = new Dictionary() + { + } + } + }, + new TaskUpdateTestData() + { + Name = "output_artefact_file", + TaskUpdateEvent = new TaskUpdateEvent() + { + WorkflowInstanceId = Helper.GetWorkflowInstanceByName("WFI_Invalid_Task_Destination").WorkflowInstance.Id, + ExecutionId = Helper.GetWorkflowInstanceByName("WFI_Invalid_Task_Destination").WorkflowInstance.Tasks[0].ExecutionId, + CorrelationId = Guid.NewGuid().ToString(), + Reason = FailureReason.None, + Message = "Task Message", + TaskId = Helper.GetWorkflowInstanceByName("WFI_Invalid_Task_Destination").WorkflowInstance.Tasks[0].TaskId, + Metadata = new Dictionary() + { + } + } + }, + new TaskUpdateTestData() + { + Name = "output_artefact_dir", + TaskUpdateEvent = new TaskUpdateEvent() + { + WorkflowInstanceId = Helper.GetWorkflowInstanceByName("WFI_Invalid_Task_Destination").WorkflowInstance.Id, + ExecutionId = Helper.GetWorkflowInstanceByName("WFI_Invalid_Task_Destination").WorkflowInstance.Tasks[0].ExecutionId, + CorrelationId = Guid.NewGuid().ToString(), + Reason = FailureReason.None, + Message = "Task Message", + TaskId = Helper.GetWorkflowInstanceByName("WFI_Invalid_Task_Destination").WorkflowInstance.Tasks[0].TaskId, + Metadata = new Dictionary() + { + } + } + }, + new TaskUpdateTestData() + { + Name = "Task_Update_Task_Destination_Condition_True", + TaskUpdateEvent = new TaskUpdateEvent() + { + WorkflowInstanceId = Helper.GetWorkflowInstanceByName("WFI_Task_Destination_Condition_True").WorkflowInstance.Id, + ExecutionId = Helper.GetWorkflowInstanceByName("WFI_Task_Destination_Condition_True").WorkflowInstance.Tasks[0].ExecutionId, + CorrelationId = Guid.NewGuid().ToString(), + Reason = FailureReason.None, + Message = "Task Message", + TaskId = Helper.GetWorkflowInstanceByName("WFI_Task_Destination_Condition_True").WorkflowInstance.Tasks[0].TaskId, + Metadata = new Dictionary() + { + } + } + }, + new TaskUpdateTestData() + { + Name = "Task_Update_Task_Destination_Condition_False", + TaskUpdateEvent = new TaskUpdateEvent() + { + WorkflowInstanceId = Helper.GetWorkflowInstanceByName("WFI_Task_Destination_Condition_False").WorkflowInstance.Id, + ExecutionId = Helper.GetWorkflowInstanceByName("WFI_Task_Destination_Condition_False").WorkflowInstance.Tasks[0].ExecutionId, + CorrelationId = Guid.NewGuid().ToString(), + Reason = FailureReason.None, + Message = "Task Message", + TaskId = Helper.GetWorkflowInstanceByName("WFI_Task_Destination_Condition_False").WorkflowInstance.Tasks[0].TaskId, + Metadata = new Dictionary() + { + } + } + }, + new TaskUpdateTestData() + { + Name = "Task_Update_Task_Multiple_Destination_Condition_True", + TaskUpdateEvent = new TaskUpdateEvent() + { + WorkflowInstanceId = Helper.GetWorkflowInstanceByName("WFI_Task_Multiple_Destination_Condition_True").WorkflowInstance.Id, + ExecutionId = Helper.GetWorkflowInstanceByName("WFI_Task_Multiple_Destination_Condition_True").WorkflowInstance.Tasks[0].ExecutionId, + CorrelationId = Guid.NewGuid().ToString(), + Reason = FailureReason.None, + Message = "Task Message", + TaskId = Helper.GetWorkflowInstanceByName("WFI_Task_Multiple_Destination_Condition_True").WorkflowInstance.Tasks[0].TaskId, + Metadata = new Dictionary() + { + } + } + }, + new TaskUpdateTestData() + { + Name = "Task_Update_Task_Multiple_Destination_Condition_False", + TaskUpdateEvent = new TaskUpdateEvent() + { + WorkflowInstanceId = Helper.GetWorkflowInstanceByName("WFI_Task_Multiple_Destination_Condition_False").WorkflowInstance.Id, + ExecutionId = Helper.GetWorkflowInstanceByName("WFI_Task_Multiple_Destination_Condition_False").WorkflowInstance.Tasks[0].ExecutionId, + CorrelationId = Guid.NewGuid().ToString(), + Reason = FailureReason.None, + Message = "Task Message", + TaskId = Helper.GetWorkflowInstanceByName("WFI_Task_Multiple_Destination_Condition_False").WorkflowInstance.Tasks[0].TaskId, + Metadata = new Dictionary() + { + } + } + }, + new TaskUpdateTestData() + { + Name = "Task_Update_Task_Destination_Condition_True_And_False", + TaskUpdateEvent = new TaskUpdateEvent() + { + WorkflowInstanceId = Helper.GetWorkflowInstanceByName("WFI_Task_Destination_Condition_True_And_False").WorkflowInstance.Id, + ExecutionId = Helper.GetWorkflowInstanceByName("WFI_Task_Destination_Condition_True_And_False").WorkflowInstance.Tasks[0].ExecutionId, + CorrelationId = Guid.NewGuid().ToString(), + Reason = FailureReason.None, + Message = "Task Message", + TaskId = Helper.GetWorkflowInstanceByName("WFI_Task_Destination_Condition_True_And_False").WorkflowInstance.Tasks[0].TaskId, + Metadata = new Dictionary() + { + } + } + }, + new TaskUpdateTestData() + { + Name = "Task_Update_Task_Destination_Invalid_Condition", + TaskUpdateEvent = new TaskUpdateEvent() + { + WorkflowInstanceId = Helper.GetWorkflowInstanceByName("WFI_Task_Destination_Invalid_Condition").WorkflowInstance.Id, + ExecutionId = Helper.GetWorkflowInstanceByName("WFI_Task_Destination_Invalid_Condition").WorkflowInstance.Tasks[0].ExecutionId, + CorrelationId = Guid.NewGuid().ToString(), + Reason = FailureReason.None, + Message = "Task Message", + TaskId = Helper.GetWorkflowInstanceByName("WFI_Task_Destination_Invalid_Condition").WorkflowInstance.Tasks[0].TaskId, + Metadata = new Dictionary() + { + } + } + }, + new TaskUpdateTestData() + { + Name = "TwoTask_Context.Dicom.Input_ArtifactMandatory=Null", + TaskUpdateEvent = new TaskUpdateEvent() + { + WorkflowInstanceId = Helper.GetWorkflowInstanceByName("TwoTask_Context.Dicom.Input_ArtifactMandatory=Null").WorkflowInstance.Id, + ExecutionId = Helper.GetWorkflowInstanceByName("TwoTask_Context.Dicom.Input_ArtifactMandatory=Null").WorkflowInstance.Tasks[0].ExecutionId, + CorrelationId = Guid.NewGuid().ToString(), + Reason = FailureReason.None, + Message = "Task Message", + TaskId = Helper.GetWorkflowInstanceByName("TwoTask_Context.Dicom.Input_ArtifactMandatory=Null").WorkflowInstance.Tasks[0].TaskId, + Outputs = new List + { + new Messaging.Common.Storage() + { + Name = "output.dcm", + Endpoint = "//output.dcm", + Credentials = new Messaging.Common.Credentials() + { + AccessKey = "test1", + AccessToken = "test", + }, + Bucket = "bucket1", + RelativeRootPath = GetRelativePathForOutputArtifacts("TwoTask_Context.Dicom.Input_ArtifactMandatory=Null") + } + }, + Metadata = new Dictionary() + { + } + } + }, + new TaskUpdateTestData() + { + Name = "TwoTask_Context.Dicom.Input_ArtifactMandatory=True", + TaskUpdateEvent = new TaskUpdateEvent() + { + WorkflowInstanceId = Helper.GetWorkflowInstanceByName("TwoTask_Context.Dicom.Input_ArtifactMandatory=True").WorkflowInstance.Id, + ExecutionId = Helper.GetWorkflowInstanceByName("TwoTask_Context.Dicom.Input_ArtifactMandatory=True").WorkflowInstance.Tasks[0].ExecutionId, + CorrelationId = Guid.NewGuid().ToString(), + Reason = FailureReason.None, + Message = "Task Message", + TaskId = Helper.GetWorkflowInstanceByName("TwoTask_Context.Dicom.Input_ArtifactMandatory=True").WorkflowInstance.Tasks[0].TaskId, + Metadata = new Dictionary() + { + } + } + }, + new TaskUpdateTestData() + { + Name = "TwoTask_Context.Dicom.Input_ArtifactMandatory=False", + TaskUpdateEvent = new TaskUpdateEvent() + { + WorkflowInstanceId = Helper.GetWorkflowInstanceByName("TwoTask_Context.Dicom.Input_ArtifactMandatory=False").WorkflowInstance.Id, + ExecutionId = Helper.GetWorkflowInstanceByName("TwoTask_Context.Dicom.Input_ArtifactMandatory=False").WorkflowInstance.Tasks[0].ExecutionId, + CorrelationId = Guid.NewGuid().ToString(), + Reason = FailureReason.None, + Message = "Task Message", + TaskId = Helper.GetWorkflowInstanceByName("TwoTask_Context.Dicom.Input_ArtifactMandatory=False").WorkflowInstance.Tasks[0].TaskId, + Metadata = new Dictionary() + { + } + } + }, + }; + } +} diff --git a/tests/IntegrationTests/WorkflowExecutor.IntegrationTests/TestData/WorkflowInstanceTestData.cs b/tests/IntegrationTests/WorkflowExecutor.IntegrationTests/TestData/WorkflowInstanceTestData.cs index b593f9952..66322594e 100644 --- a/tests/IntegrationTests/WorkflowExecutor.IntegrationTests/TestData/WorkflowInstanceTestData.cs +++ b/tests/IntegrationTests/WorkflowExecutor.IntegrationTests/TestData/WorkflowInstanceTestData.cs @@ -16,6 +16,7 @@ using Monai.Deploy.Messaging.Events; using Monai.Deploy.WorkflowManager.Contracts.Models; +using Monai.Deploy.WorkflowManager.IntegrationTests.POCO; namespace Monai.Deploy.WorkflowManager.WorkflowExecutor.IntegrationTests.TestData { @@ -53,7 +54,7 @@ public static class WorkflowInstancesTestData ExecutionId = Guid.NewGuid().ToString(), TaskId = "pizza", TaskType = "Multi_task", - Status = TaskExecutionStatus.Dispatched, + Status = TaskExecutionStatus.Accepted, OutputDirectory = "none" } } @@ -783,6 +784,97 @@ public static class WorkflowInstancesTestData } } }, + new WorkflowInstanceTestData() + { + Name = "TwoTask_Context.Dicom.Input_ArtifactMandatory=Null", + WorkflowInstance = new WorkflowInstance() + { + Id = Guid.NewGuid().ToString(), + AeTitle = Helper.GetWorkflowByName("TwoTask_Context.Dicom.Input_ArtifactMandatory=Null").WorkflowRevision.Workflow.InformaticsGateway.AeTitle, + WorkflowId = Helper.GetWorkflowByName("TwoTask_Context.Dicom.Input_ArtifactMandatory=Null").WorkflowRevision.WorkflowId, + PayloadId = Guid.NewGuid().ToString(), + StartTime = DateTime.Now, + Status = Status.Created, + BucketId = TestExecutionConfig.MinioConfig.Bucket, + InputMetaData = new Dictionary() + { + { "", "" } + }, + Tasks = new List + { + new TaskExecution() + { + ExecutionId = Guid.NewGuid().ToString(), + TaskId = Helper.GetWorkflowByName("TwoTask_Context.Dicom.Input_ArtifactMandatory=Null").WorkflowRevision.Workflow.Tasks[0].Id, + TaskType = Helper.GetWorkflowByName("TwoTask_Context.Dicom.Input_ArtifactMandatory=Null").WorkflowRevision?.Workflow.Tasks[0].Type, + Status = TaskExecutionStatus.Accepted, + InputArtifacts = null, + OutputArtifacts = null + }, + } + } + }, + new WorkflowInstanceTestData() + { + Name = "TwoTask_Context.Dicom.Input_ArtifactMandatory=True", + WorkflowInstance = new WorkflowInstance() + { + Id = Guid.NewGuid().ToString(), + AeTitle = Helper.GetWorkflowByName("TwoTask_Context.Dicom.Input_ArtifactMandatory=True").WorkflowRevision.Workflow.InformaticsGateway.AeTitle, + WorkflowId = Helper.GetWorkflowByName("TwoTask_Context.Dicom.Input_ArtifactMandatory=True").WorkflowRevision.WorkflowId, + PayloadId = Guid.NewGuid().ToString(), + StartTime = DateTime.Now, + Status = Status.Created, + BucketId = TestExecutionConfig.MinioConfig.Bucket, + InputMetaData = new Dictionary() + { + { "", "" } + }, + Tasks = new List + { + new TaskExecution() + { + ExecutionId = Guid.NewGuid().ToString(), + TaskId = Helper.GetWorkflowByName("TwoTask_Context.Dicom.Input_ArtifactMandatory=True").WorkflowRevision.Workflow.Tasks[0].Id, + TaskType = Helper.GetWorkflowByName("TwoTask_Context.Dicom.Input_ArtifactMandatory=True").WorkflowRevision?.Workflow.Tasks[0].Type, + Status = TaskExecutionStatus.Accepted, + InputArtifacts = null, + OutputArtifacts = null, + }, + } + } + }, + new WorkflowInstanceTestData() + { + Name = "ATwoTask_Context.Dicom.Input_ArtifactMandatory=False", + WorkflowInstance = new WorkflowInstance() + { + Id = Guid.NewGuid().ToString(), + AeTitle = Helper.GetWorkflowByName("TwoTask_Context.Dicom.Input_ArtifactMandatory=False").WorkflowRevision.Workflow.InformaticsGateway.AeTitle, + WorkflowId = Helper.GetWorkflowByName("TwoTask_Context.Dicom.Input_ArtifactMandatory=False").WorkflowRevision.WorkflowId, + PayloadId = Guid.NewGuid().ToString(), + StartTime = DateTime.Now, + Status = Status.Created, + BucketId = TestExecutionConfig.MinioConfig.Bucket, + InputMetaData = new Dictionary() + { + { "", "" } + }, + Tasks = new List + { + new TaskExecution() + { + ExecutionId = Guid.NewGuid().ToString(), + TaskId = Helper.GetWorkflowByName("TwoTask_Context.Dicom.Input_ArtifactMandatory=False").WorkflowRevision.Workflow.Tasks[0].Id, + TaskType = Helper.GetWorkflowByName("TwoTask_Context.Dicom.Input_ArtifactMandatory=False").WorkflowRevision?.Workflow.Tasks[0].Type, + Status = TaskExecutionStatus.Accepted, + InputArtifacts = null, + OutputArtifacts = null, + }, + } + } + }, + }; } } diff --git a/tests/IntegrationTests/WorkflowExecutor.IntegrationTests/TestData/WorkflowObjectTestData.cs b/tests/IntegrationTests/WorkflowExecutor.IntegrationTests/TestData/WorkflowObjectTestData.cs index 8a1e93eba..b28f8fa3e 100644 --- a/tests/IntegrationTests/WorkflowExecutor.IntegrationTests/TestData/WorkflowObjectTestData.cs +++ b/tests/IntegrationTests/WorkflowExecutor.IntegrationTests/TestData/WorkflowObjectTestData.cs @@ -44,12 +44,13 @@ public static class WorkflowObjectsTestData Id = Guid.NewGuid().ToString(), Type = "Basic_task", Description = "Basic Workflow update Task update", + Args = new Dictionary { { "test", "test" } }, Artifacts = new ArtifactMap() { Input = new Artifact[] {}, Output = new Artifact[] {} }, - Args = new Dictionary { { "test", "test" } } + TaskDestinations = new TaskDestination[] {} } }, InformaticsGateway = new InformaticsGateway() diff --git a/tests/IntegrationTests/WorkflowExecutor.IntegrationTests/TestData/WorkflowRequestTestData.cs b/tests/IntegrationTests/WorkflowExecutor.IntegrationTests/TestData/WorkflowRequestTestData.cs index 38f4fb602..0458e45ec 100644 --- a/tests/IntegrationTests/WorkflowExecutor.IntegrationTests/TestData/WorkflowRequestTestData.cs +++ b/tests/IntegrationTests/WorkflowExecutor.IntegrationTests/TestData/WorkflowRequestTestData.cs @@ -302,7 +302,21 @@ public static class WorkflowRequestsTestData CalledAeTitle = "Router_1", CallingAeTitle = "MWM", } - } + }, + new WorkflowRequestTestData + { + Name = "Artifact_AeTitle_Request_1", + WorkflowRequestMessage = new WorkflowRequestMessage + { + Bucket = "bucket1", + PayloadId = new Guid("3d22bf41-eacd-4e43-9161-d00735b31a2e"), + Workflows = new List() { }, + CorrelationId = Guid.NewGuid().ToString(), + Timestamp = DateTime.Now, + CalledAeTitle = "Artifact_AE", + CallingAeTitle = "MWM", + } + }, }; } } diff --git a/tests/IntegrationTests/WorkflowExecutor.IntegrationTests/TestData/WorkflowRevisionTestData.cs b/tests/IntegrationTests/WorkflowExecutor.IntegrationTests/TestData/WorkflowRevisionTestData.cs index a069f52f0..f3bef4610 100644 --- a/tests/IntegrationTests/WorkflowExecutor.IntegrationTests/TestData/WorkflowRevisionTestData.cs +++ b/tests/IntegrationTests/WorkflowExecutor.IntegrationTests/TestData/WorkflowRevisionTestData.cs @@ -48,7 +48,8 @@ public static class WorkflowRevisionsTestData { Id = Guid.NewGuid().ToString(), Type = "Basic_task", - Description = "Basic Workflow 1 Task 1" + Description = "Basic Workflow 1 Task 1", + Artifacts = new ArtifactMap(), } }, InformaticsGateway = new InformaticsGateway() @@ -77,7 +78,8 @@ public static class WorkflowRevisionsTestData { Id = Guid.NewGuid().ToString(), Type = "Basic_task", - Description = "Basic Workflow 2 Task 1" + Description = "Basic Workflow 2 Task 1", + Artifacts = new ArtifactMap(), } }, InformaticsGateway = new InformaticsGateway() @@ -106,7 +108,8 @@ public static class WorkflowRevisionsTestData { Id = Guid.NewGuid().ToString(), Type = "Basic_task", - Description = "Basic Workflow 3 Task 1" + Description = "Basic Workflow 3 Task 1", + Artifacts = new ArtifactMap(), } }, InformaticsGateway = new InformaticsGateway() @@ -135,7 +138,8 @@ public static class WorkflowRevisionsTestData { Id = Guid.NewGuid().ToString(), Type = "Basic_task", - Description = "Same AeTitle 1 Task 1" + Description = "Same AeTitle 1 Task 1", + Artifacts = new ArtifactMap(), } }, InformaticsGateway = new InformaticsGateway() @@ -164,7 +168,8 @@ public static class WorkflowRevisionsTestData { Id = Guid.NewGuid().ToString(), Type = "Basic_task", - Description = "Same AeTitle 2 Task 1" + Description = "Same AeTitle 2 Task 1", + Artifacts = new ArtifactMap(), } }, InformaticsGateway = new InformaticsGateway() @@ -193,7 +198,8 @@ public static class WorkflowRevisionsTestData { Id = Guid.NewGuid().ToString(), Type = "Basic_Workflow_Multiple_Revisions_1", - Description = "Basic_Workflow_Multiple_Revisions_1" + Description = "Basic_Workflow_Multiple_Revisions_1", + Artifacts = new ArtifactMap(), } }, InformaticsGateway = new InformaticsGateway() @@ -222,7 +228,8 @@ public static class WorkflowRevisionsTestData { Id = Guid.NewGuid().ToString(), Type = "Basic_Workflow_Multiple_Revisions_2", - Description = "Basic_Workflow_Multiple_Revisions_2" + Description = "Basic_Workflow_Multiple_Revisions_2", + Artifacts = new ArtifactMap(), } }, InformaticsGateway = new InformaticsGateway() @@ -251,13 +258,15 @@ public static class WorkflowRevisionsTestData { Id = Guid.NewGuid().ToString(), Type = "task_1", - Description = "Multi task workflow Task 1" + Description = "Multi task workflow Task 1", + Artifacts = new ArtifactMap(), }, new TaskObject { Id = Guid.NewGuid().ToString(), Type = "task_2", - Description = "Multi task workflow Task 2" + Description = "Multi task workflow Task 2", + Artifacts = new ArtifactMap(), } }, InformaticsGateway = new InformaticsGateway() @@ -286,7 +295,8 @@ public static class WorkflowRevisionsTestData { Id = Guid.NewGuid().ToString(), Type = "Task_Update", - Description = "Task Update Task 1" + Description = "Task Update Task 1", + Artifacts = new ArtifactMap(), } }, InformaticsGateway = new InformaticsGateway() @@ -315,7 +325,8 @@ public static class WorkflowRevisionsTestData { Id = "2dbd1af7-b699-4467-8e99-05a0c22422b4", Type = "Multi_task", - Description = "Multiple request task 1" + Description = "Multiple request task 1", + Artifacts = new ArtifactMap(), } }, InformaticsGateway = new InformaticsGateway() @@ -344,7 +355,8 @@ public static class WorkflowRevisionsTestData { Id = "7d7c8b83-6628-413c-9912-a89314e5e2d5", Type = "Multi_task", - Description = "Multiple request task 1" + Description = "Multiple request task 1", + Artifacts = new ArtifactMap(), } }, InformaticsGateway = new InformaticsGateway() @@ -374,6 +386,7 @@ public static class WorkflowRevisionsTestData Id = "00d275ce-81d8-4d54-a923-d34cf1955cc4", Type = "Multi_task", Description = "Multiple request task 1", + Artifacts = new ArtifactMap(), TaskDestinations = new TaskDestination[] { new TaskDestination() @@ -387,6 +400,7 @@ public static class WorkflowRevisionsTestData Id = "510ba0cf-8632-4112-994d-36617318a74f", Type = "Multi_task", Description = "Multiple request task 2", + Artifacts = new ArtifactMap(), }, }, InformaticsGateway = new InformaticsGateway() @@ -416,6 +430,7 @@ public static class WorkflowRevisionsTestData Id = "b971c259-c3d5-4ddf-93b2-56c83fb7b474", Type = "Multi_task", Description = "Multiple request task 1", + Artifacts = new ArtifactMap(), TaskDestinations = new TaskDestination[] { new TaskDestination() @@ -433,12 +448,14 @@ public static class WorkflowRevisionsTestData Id = "6da9b529-f7b5-40c2-a604-b7421599b364", Type = "Multi_task", Description = "Multiple request task 2", + Artifacts = new ArtifactMap(), }, new TaskObject { Id = "eefdd563-c589-433a-969f-2cddfe93af24", Type = "Multi_task", Description = "Multiple request task 3", + Artifacts = new ArtifactMap(), }, }, InformaticsGateway = new InformaticsGateway() @@ -468,6 +485,7 @@ public static class WorkflowRevisionsTestData Id = "f4c96785-4cd4-42c9-9e43-4c50b654e397", Type = "Multi_task", Description = "Multiple request task 1", + Artifacts = new ArtifactMap(), TaskDestinations = new TaskDestination[] { new TaskDestination() @@ -481,6 +499,7 @@ public static class WorkflowRevisionsTestData Id = "6f26fb39-5991-4b6e-9885-67e32a575559", Type = "Multi_task", Description = "Multiple request task 2", + Artifacts = new ArtifactMap(), }, }, InformaticsGateway = new InformaticsGateway() @@ -510,6 +529,7 @@ public static class WorkflowRevisionsTestData Id = "36d29b9d-d496-4568-a305-f0775c0f2084", Type = "Multi_task", Description = "Multiple request task 1", + Artifacts = new ArtifactMap(), TaskDestinations = new TaskDestination[] { new TaskDestination() @@ -523,6 +543,7 @@ public static class WorkflowRevisionsTestData Id = "36dcdd1a-7e57-405e-a6c3-b0e99be1f3d2", Type = "Multi_task", Description = "Multiple request task 1", + Artifacts = new ArtifactMap(), }, }, InformaticsGateway = new InformaticsGateway() @@ -552,7 +573,8 @@ public static class WorkflowRevisionsTestData Id = Guid.NewGuid().ToString(), Type = "Basic_task", Description = "Basic Workflow 1 Task 1", - Args = new Dictionary { { "test", "test" } } + Args = new Dictionary { { "test", "test" } }, + Artifacts = new ArtifactMap(), } }, InformaticsGateway = new InformaticsGateway() @@ -583,7 +605,8 @@ public static class WorkflowRevisionsTestData { Id = Guid.NewGuid().ToString(), Type = "Basic_task", - Description = "Basic Workflow 1 Task 1" + Description = "Basic Workflow 1 Task 1", + Artifacts = new ArtifactMap(), } }, InformaticsGateway = new InformaticsGateway() @@ -612,7 +635,8 @@ public static class WorkflowRevisionsTestData { Id = Guid.NewGuid().ToString(), Type = "Basic_task", - Description = "Basic Workflow 1 Task 1" + Description = "Basic Workflow 1 Task 1", + Artifacts = new ArtifactMap(), } }, InformaticsGateway = new InformaticsGateway() @@ -643,6 +667,7 @@ public static class WorkflowRevisionsTestData Type = "Basic_task", Description = "Basic Workflow 1 Task 1", Args = new Dictionary { { "test", "test" } }, + Artifacts = new ArtifactMap(), TaskDestinations = new TaskDestination[] { new TaskDestination() @@ -657,6 +682,7 @@ public static class WorkflowRevisionsTestData Id = "cake", Type = "Basic_task", Description = "Basic Workflow 1 Task 1", + Artifacts = new ArtifactMap(), Args = new Dictionary { { "test", "test" } } } @@ -690,6 +716,7 @@ public static class WorkflowRevisionsTestData Id = "36d29b9d-d496-4568-a305-f0775c0f2084", Type = "Multi_task", Description = "Multiple request task 1", + Artifacts = new ArtifactMap(), TaskDestinations = new TaskDestination[] { new TaskDestination() @@ -704,6 +731,7 @@ public static class WorkflowRevisionsTestData Id = "b9964b10-acb4-4050-a610-374fdbe2100d", Type = "Multi_task", Description = "Multiple request task 1", + Artifacts = new ArtifactMap(), }, }, InformaticsGateway = new InformaticsGateway() @@ -733,6 +761,7 @@ public static class WorkflowRevisionsTestData Id = "36d29b9d-d496-4568-a305-f0775c0f2084", Type = "Multi_task", Description = "Multiple request task 1", + Artifacts = new ArtifactMap(), TaskDestinations = new TaskDestination[] { new TaskDestination() @@ -747,6 +776,7 @@ public static class WorkflowRevisionsTestData Id = "b9964b10-acb4-4050-a610-374fdbe2100d", Type = "Multi_task", Description = "Multiple request task 1", + Artifacts = new ArtifactMap(), }, }, InformaticsGateway = new InformaticsGateway() @@ -776,6 +806,7 @@ public static class WorkflowRevisionsTestData Id = "36d29b9d-d496-4568-a305-f0775c0f2084", Type = "Multi_task", Description = "Multiple request task 1", + Artifacts = new ArtifactMap(), TaskDestinations = new TaskDestination[] { new TaskDestination() @@ -800,18 +831,21 @@ public static class WorkflowRevisionsTestData Id = "b9964b10-acb4-4050-a610-374fdbe2100d", Type = "Multi_task", Description = "Multiple request task 1", + Artifacts = new ArtifactMap(), }, new TaskObject { Id = "e12849f3-247d-47eb-95c8-5aa16f551f62", Type = "Multi_task", Description = "Multiple request task 1", + Artifacts = new ArtifactMap(), }, new TaskObject { Id = "d2e5219d-9ccb-4584-b078-5216ee4b9b8b", Type = "Multi_task", Description = "Multiple request task 1", + Artifacts = new ArtifactMap(), }, }, InformaticsGateway = new InformaticsGateway() @@ -841,6 +875,7 @@ public static class WorkflowRevisionsTestData Id = "36d29b9d-d496-4568-a305-f0775c0f2084", Type = "Multi_task", Description = "Multiple request task 1", + Artifacts = new ArtifactMap(), TaskDestinations = new TaskDestination[] { new TaskDestination() @@ -855,6 +890,7 @@ public static class WorkflowRevisionsTestData Id = "b9964b10-acb4-4050-a610-374fdbe2100d", Type = "Multi_task", Description = "Multiple request task 1", + Artifacts = new ArtifactMap(), }, }, InformaticsGateway = new InformaticsGateway() @@ -884,6 +920,7 @@ public static class WorkflowRevisionsTestData Id = "36d29b9d-d496-4568-a305-f0775c0f2084", Type = "Multi_task", Description = "Multiple request task 1", + Artifacts = new ArtifactMap(), TaskDestinations = new TaskDestination[] { new TaskDestination() @@ -908,18 +945,21 @@ public static class WorkflowRevisionsTestData Id = "b9964b10-acb4-4050-a610-374fdbe2100d", Type = "Multi_task", Description = "Multiple request task 1", + Artifacts = new ArtifactMap(), }, new TaskObject { Id = "e12849f3-247d-47eb-95c8-5aa16f551f62", Type = "Multi_task", Description = "Multiple request task 1", + Artifacts = new ArtifactMap(), }, new TaskObject { Id = "d2e5219d-9ccb-4584-b078-5216ee4b9b8b", Type = "Multi_task", Description = "Multiple request task 1", + Artifacts = new ArtifactMap(), }, }, InformaticsGateway = new InformaticsGateway() @@ -949,6 +989,7 @@ public static class WorkflowRevisionsTestData Id = "36d29b9d-d496-4568-a305-f0775c0f2084", Type = "Multi_task", Description = "Multiple request task 1", + Artifacts = new ArtifactMap(), TaskDestinations = new TaskDestination[] { new TaskDestination() @@ -973,11 +1014,13 @@ public static class WorkflowRevisionsTestData Id = "b9964b10-acb4-4050-a610-374fdbe2100d", Type = "Multi_task", Description = "Multiple request task 1", + Artifacts = new ArtifactMap(), }, new TaskObject { Id = "e12849f3-247d-47eb-95c8-5aa16f551f62", Type = "Multi_task", + Artifacts = new ArtifactMap(), } }, InformaticsGateway = new InformaticsGateway() @@ -1009,6 +1052,7 @@ public static class WorkflowRevisionsTestData Id = "36d29b9d-d496-4568-a305-f0775c0f2084", Type = "Multi_task", Description = "Multiple request task 1", + Artifacts = new ArtifactMap(), TaskDestinations = new TaskDestination[] { new TaskDestination() @@ -1028,12 +1072,14 @@ public static class WorkflowRevisionsTestData Id = "b9964b10-acb4-4050-a610-374fdbe2100d", Type = "Multi_task", Description = "Multiple request task 1", + Artifacts = new ArtifactMap(), }, new TaskObject { Id = "e12849f3-247d-47eb-95c8-5aa16f551f62", Type = "Multi_task", Description = "Multiple request task 1", + Artifacts = new ArtifactMap(), }, }, InformaticsGateway = new InformaticsGateway() @@ -1063,6 +1109,7 @@ public static class WorkflowRevisionsTestData Id = "36d29b9d-d496-4568-a305-f0775c0f2084", Type = "Multi_task", Description = "Multiple request task 1", + Artifacts = new ArtifactMap(), TaskDestinations = new TaskDestination[] { new TaskDestination() @@ -1077,6 +1124,7 @@ public static class WorkflowRevisionsTestData Id = "b9964b10-acb4-4050-a610-374fdbe2100d", Type = "Multi_task", Description = "Multiple request task 1", + Artifacts = new ArtifactMap(), }, }, InformaticsGateway = new InformaticsGateway() @@ -1106,6 +1154,7 @@ public static class WorkflowRevisionsTestData Id = Guid.NewGuid().ToString(), Type = "router", Description = "Router Task", + Artifacts = new ArtifactMap(), TaskDestinations = new TaskDestination[] { new TaskDestination { Name = "taskdest1" }, @@ -1116,13 +1165,15 @@ public static class WorkflowRevisionsTestData { Id = "taskdest1", Type = "argo", - Description = "Argo plugin Task 1" + Description = "Argo plugin Task 1", + Artifacts = new ArtifactMap(), }, new TaskObject { Id = "taskdest2", Type = "argo", - Description = "Argo plugin Task 2" + Description = "Argo plugin Task 2", + Artifacts = new ArtifactMap(), } }, InformaticsGateway = new InformaticsGateway() @@ -1152,6 +1203,7 @@ public static class WorkflowRevisionsTestData Id = Guid.NewGuid().ToString(), Type = "router", Description = "Router Workflow 1 Task 1", + Artifacts = new ArtifactMap(), TaskDestinations = new TaskDestination[] { new TaskDestination { Name = "taskdest1" } @@ -1161,7 +1213,8 @@ public static class WorkflowRevisionsTestData { Id = "taskdest1", Type = "Basic_task", - Description = "Basic Workflow 1 Task 1" + Description = "Basic Workflow 1 Task 1", + Artifacts = new ArtifactMap(), }, }, InformaticsGateway = new InformaticsGateway() @@ -1191,6 +1244,7 @@ public static class WorkflowRevisionsTestData Id = Guid.NewGuid().ToString(), Type = "router", Description = "Router Workflow 1 Task 1", + Artifacts = new ArtifactMap(), TaskDestinations = new TaskDestination[] { new TaskDestination { Name = "taskdest1", Conditions = "'true'=='true'" }, @@ -1201,13 +1255,15 @@ public static class WorkflowRevisionsTestData { Id = "taskdest1", Type = "argo", - Description = "Argo plugin Task 1" + Description = "Argo plugin Task 1", + Artifacts = new ArtifactMap(), }, new TaskObject { Id = "taskdest2", Type = "argo", - Description = "Argo plugin Task 2" + Description = "Argo plugin Task 2", + Artifacts = new ArtifactMap(), } }, InformaticsGateway = new InformaticsGateway() @@ -1237,6 +1293,7 @@ public static class WorkflowRevisionsTestData Id = Guid.NewGuid().ToString(), Type = "router", Description = "Router Workflow 1 Task 1", + Artifacts = new ArtifactMap(), TaskDestinations = new TaskDestination[] { new TaskDestination { Name = "taskdest1", Conditions = "'false'=='true'" }, @@ -1247,13 +1304,15 @@ public static class WorkflowRevisionsTestData { Id = "taskdest1", Type = "argo", - Description = "Argo plugin Task 1" + Description = "Argo plugin Task 1", + Artifacts = new ArtifactMap(), }, new TaskObject { Id = "taskdest2", Type = "argo", - Description = "Argo plugin Task 2" + Description = "Argo plugin Task 2", + Artifacts = new ArtifactMap(), } }, InformaticsGateway = new InformaticsGateway() @@ -1283,6 +1342,7 @@ public static class WorkflowRevisionsTestData Id = Guid.NewGuid().ToString(), Type = "router", Description = "Router Workflow router task 1", + Artifacts = new ArtifactMap(), TaskDestinations = new TaskDestination[] { new TaskDestination { Name = "taskdest1" }, @@ -1293,13 +1353,15 @@ public static class WorkflowRevisionsTestData { Id = "taskdest1", Type = "argo", - Description = "Argo plugin Task 1" + Description = "Argo plugin Task 1", + Artifacts = new ArtifactMap(), }, new TaskObject { Id = "router2", Type = "router", Description = "Router Workflow router task 2", + Artifacts = new ArtifactMap(), TaskDestinations = new TaskDestination[] { new TaskDestination { Name = "taskdest2" }, @@ -1310,13 +1372,15 @@ public static class WorkflowRevisionsTestData { Id = "taskdest2", Type = "argo", - Description = "Argo plugin Task 2" + Description = "Argo plugin Task 2", + Artifacts = new ArtifactMap(), }, new TaskObject { Id = "taskdest3", Type = "argo", - Description = "Argo plugin Task 3" + Description = "Argo plugin Task 3", + Artifacts = new ArtifactMap(), } }, InformaticsGateway = new InformaticsGateway() @@ -1346,6 +1410,7 @@ public static class WorkflowRevisionsTestData Id = Guid.NewGuid().ToString(), Type = "router", Description = "Router Workflow 1 Task 1", + Artifacts = new ArtifactMap(), TaskDestinations = new TaskDestination[] { new TaskDestination { Name = "taskdest2"}, @@ -1355,7 +1420,8 @@ public static class WorkflowRevisionsTestData { Id = "taskdest1", Type = "argo", - Description = "Argo plugin Task 1" + Description = "Argo plugin Task 1", + Artifacts = new ArtifactMap(), }, }, InformaticsGateway = new InformaticsGateway() @@ -1365,6 +1431,326 @@ public static class WorkflowRevisionsTestData } } }, + new WorkflowRevisionTestData() + { + Name = "OneTask_Context.Dicom.Input_ArtifactMandatory=Null", + WorkflowRevision = new WorkflowRevision() + { + Id = Guid.NewGuid().ToString(), + WorkflowId = Guid.NewGuid().ToString(), + Revision = 1, + Workflow = new Workflow() + { + Name = "Artifact 1", + Description = "Artifact 1", + Version = "1", + Tasks = new TaskObject[] + { + new TaskObject + { + Id = Guid.NewGuid().ToString(), + Type = "Artifact_task", + Description = "Artifact Workflow 1 Task 1", + Artifacts = new ArtifactMap() + { + Input = new Artifact[] + { + new Artifact { Name = "Input", Value = "{{ context.input.dicom }}" }, + }, + } + }, + }, + InformaticsGateway = new InformaticsGateway() + { + AeTitle = "Artifact_AE" + } + } + } + }, + new WorkflowRevisionTestData() + { + Name = "OneTask_Context.Dicom.Input_ArtifactMandatory=True", + WorkflowRevision = new WorkflowRevision() + { + Id = Guid.NewGuid().ToString(), + WorkflowId = Guid.NewGuid().ToString(), + Revision = 1, + Workflow = new Workflow() + { + Name = "Artifact 1", + Description = "Artifact 1", + Version = "1", + Tasks = new TaskObject[] + { + new TaskObject + { + Id = Guid.NewGuid().ToString(), + Type = "Artifact_task", + Description = "Artifact Workflow 1 Task 1", + Artifacts = new ArtifactMap() + { + Input = new Artifact[] + { + new Artifact { Name = "Dicom", Value = "{{ context.input.dicom }}", Mandatory = true }, + }, + } + }, + }, + InformaticsGateway = new InformaticsGateway() + { + AeTitle = "Artifact_AE" + } + } + } + }, + new WorkflowRevisionTestData() + { + Name = "OneTask_Context.Dicom.Input_ArtifactMandatory=False", + WorkflowRevision = new WorkflowRevision() + { + Id = Guid.NewGuid().ToString(), + WorkflowId = Guid.NewGuid().ToString(), + Revision = 1, + Workflow = new Workflow() + { + Name = "Artifact 1", + Description = "Artifact 1", + Version = "1", + Tasks = new TaskObject[] + { + new TaskObject + { + Id = Guid.NewGuid().ToString(), + Type = "Artifact_task", + Description = "Artifact Workflow 1 Task 1", + Artifacts = new ArtifactMap() + { + Input = new Artifact[] + { + new Artifact { Name = "Dicom", Value = "{{ context.input.dicom }}", Mandatory = false }, + }, + } + }, + }, + InformaticsGateway = new InformaticsGateway() + { + AeTitle = "Artifact_AE" + } + } + } + }, + new WorkflowRevisionTestData() + { + Name = "TwoTask_Context.Dicom.Input_ArtifactMandatory=Null", + WorkflowRevision = new WorkflowRevision() + { + Id = Guid.NewGuid().ToString(), + WorkflowId = Guid.NewGuid().ToString(), + Revision = 1, + Workflow = new Workflow() + { + Name = "Artifact 1", + Description = "Artifact 1", + Version = "1", + Tasks = new TaskObject[] + { + new TaskObject + { + Id = "artifact_task_1", + Type = "Artifact_task", + Description = "Artifact Workflow 1 Task 1", + Artifacts = new ArtifactMap() + { + Input = new Artifact[] + { + new Artifact { Name = "Dicom", Value = "{{ context.input.dicom }}" }, + }, + }, + TaskDestinations = new TaskDestination[] + { + new TaskDestination{ Name = "artifact_task_2" } + } + }, + new TaskObject + { + Id = "artifact_task_2", + Type = "Artifact_task", + Description = "Artifact Workflow 1 Task 2", + Artifacts = new ArtifactMap() + { + Input = new Artifact[] + { + new Artifact { Name = "Dicom", Value = "{{ context.input.dicom }}" }, + }, + }, + }, + }, + InformaticsGateway = new InformaticsGateway() + { + AeTitle = "Artifact_AE" + } + } + } + }, + new WorkflowRevisionTestData() + { + Name = "TwoTask_Context.Dicom.Input_ArtifactMandatory=True", + WorkflowRevision = new WorkflowRevision() + { + Id = Guid.NewGuid().ToString(), + WorkflowId = Guid.NewGuid().ToString(), + Revision = 1, + Workflow = new Workflow() + { + Name = "Artifact 1", + Description = "Artifact 1", + Version = "1", + Tasks = new TaskObject[] + { + new TaskObject + { + Id = "artifact_task_1", + Type = "Artifact_task", + Description = "Artifact Workflow 1 Task 1", + Artifacts = new ArtifactMap() + { + Input = new Artifact[] + { + new Artifact { Name = "Dicom", Value = "{{ context.input.dicom }}" }, + }, + }, + TaskDestinations = new TaskDestination[] + { + new TaskDestination{ Name = "artifact_task_2" } + } + }, + new TaskObject + { + Id = "artifact_task_2", + Type = "Artifact_task", + Description = "Artifact Workflow 1 Task 2", + Artifacts = new ArtifactMap() + { + Input = new Artifact[] + { + new Artifact { Name = "Dicom", Value = "{{ context.input.dicom }}" }, + }, + }, + }, + }, + InformaticsGateway = new InformaticsGateway() + { + AeTitle = "Artifact_AE" + } + } + } + }, + new WorkflowRevisionTestData() + { + Name = "TwoTask_Context.Dicom.Input_ArtifactMandatory=False", + WorkflowRevision = new WorkflowRevision() + { + Id = Guid.NewGuid().ToString(), + WorkflowId = Guid.NewGuid().ToString(), + Revision = 1, + Workflow = new Workflow() + { + Name = "Artifact 1", + Description = "Artifact 1", + Version = "1", + Tasks = new TaskObject[] + { + new TaskObject + { + Id = "artifact_task_1", + Type = "Artifact_task", + Description = "Artifact Workflow 1 Task 1", + Artifacts = new ArtifactMap() + { + Input = new Artifact[] + { + new Artifact { Name = "Dicom", Value = "{{ context.input.dicom }}" }, + }, + }, + TaskDestinations = new TaskDestination[] + { + new TaskDestination{ Name = "artifact_task_2" } + } + }, + new TaskObject + { + Id = "artifact_task_2", + Type = "Artifact_task", + Description = "Artifact Workflow 1 Task 2", + Artifacts = new ArtifactMap() + { + Input = new Artifact[] + { + new Artifact { Name = "Dicom", Value = "{{ context.input.dicom }}" }, + }, + }, + }, + }, + InformaticsGateway = new InformaticsGateway() + { + AeTitle = "Artifact_AE" + } + } + } + }, + new WorkflowRevisionTestData() + { + Name = "Artifact_Workflow_Context.Input.Dicom_Non_Mandatory", + WorkflowRevision = new WorkflowRevision() + { + Id = Guid.NewGuid().ToString(), + WorkflowId = Guid.NewGuid().ToString(), + Revision = 1, + Workflow = new Workflow() + { + Name = "Artifact 1", + Description = "Artifact 1", + Version = "1", + Tasks = new TaskObject[] + { + new TaskObject + { + Id = "artifact_task_1", + Type = "Artifact_task", + Description = "Artifact Workflow 1 Task 1", + Artifacts = new ArtifactMap() + { + Input = new Artifact[] + { + new Artifact { Name = "Dicom", Value = "{{ context.input.dicom }}" }, + }, + }, + TaskDestinations = new TaskDestination[] + { + new TaskDestination{ Name = "artifact_task_2" } + } + }, + new TaskObject + { + Id = "artifact_task_2", + Type = "Artifact_task", + Description = "Artifact Workflow 1 Task 2", + Artifacts = new ArtifactMap() + { + Input = new Artifact[] + { + new Artifact { Name = "Dicom", Value = "{{ context.input.dicom }}", Mandatory = false }, + }, + }, + }, + }, + InformaticsGateway = new InformaticsGateway() + { + AeTitle = "Artifact_AE" + } + } + } + }, }; } } diff --git a/tests/IntegrationTests/WorkflowExecutor.IntegrationTests/appsettings.Test.json b/tests/IntegrationTests/WorkflowExecutor.IntegrationTests/appsettings.Test.json index be6ee9266..cfc03b3da 100644 --- a/tests/IntegrationTests/WorkflowExecutor.IntegrationTests/appsettings.Test.json +++ b/tests/IntegrationTests/WorkflowExecutor.IntegrationTests/appsettings.Test.json @@ -25,7 +25,7 @@ "endpoint": "localhost:9000", "accessKey": "minioadmin", "accessToken": "minioadmin", - "bucket": "test-bucket", + "bucket": "bucket1", "region": "eu-west-2", "securedConnection": false, "executableLocation": "/.",