From f4aa1069f16a376992ca4e566cdc05c89ff6cb8d Mon Sep 17 00:00:00 2001 From: Joe Batt Date: Fri, 5 Aug 2022 16:03:14 +0100 Subject: [PATCH 1/4] Task API integration tests Signed-off-by: Joe Batt Signed-off-by: Joss Sparkes --- .../Database/Repositories/TasksRepository.cs | 2 +- .../Features/TasksApi.feature | 23 ++++ .../CommonApiStepDefinitions.cs | 7 ++ .../TasksApiStepDefinitions.cs | 29 +++++ .../Support/Assertions.cs | 16 +++ .../Support/DataHelper.cs | 13 ++ .../TestData/TaskRequestTestData.cs | 38 ++++++ .../TestData/WorkflowInstanceTestData.cs | 112 ++++++++++++++++++ 8 files changed, 239 insertions(+), 1 deletion(-) create mode 100644 tests/IntegrationTests/WorkflowExecutor.IntegrationTests/Features/TasksApi.feature create mode 100644 tests/IntegrationTests/WorkflowExecutor.IntegrationTests/StepDefinitions/TasksApiStepDefinitions.cs create mode 100644 tests/IntegrationTests/WorkflowExecutor.IntegrationTests/TestData/TaskRequestTestData.cs diff --git a/src/WorkflowManager/Database/Repositories/TasksRepository.cs b/src/WorkflowManager/Database/Repositories/TasksRepository.cs index 33490625f..f25c287da 100644 --- a/src/WorkflowManager/Database/Repositories/TasksRepository.cs +++ b/src/WorkflowManager/Database/Repositories/TasksRepository.cs @@ -113,7 +113,7 @@ public async Task> GetAllAsync(int? skip, int? limit) { var builder = Builders.Filter; - var filter = builder.Eq(wf => wf.WorkflowId, workflowInstanceId); + var filter = builder.Eq(wf => wf.Id, workflowInstanceId); var result = await _workflowInstanceCollection .Find(filter) diff --git a/tests/IntegrationTests/WorkflowExecutor.IntegrationTests/Features/TasksApi.feature b/tests/IntegrationTests/WorkflowExecutor.IntegrationTests/Features/TasksApi.feature new file mode 100644 index 000000000..43007d4e3 --- /dev/null +++ b/tests/IntegrationTests/WorkflowExecutor.IntegrationTests/Features/TasksApi.feature @@ -0,0 +1,23 @@ +Feature: Tasks Api + +API to retrieve task status. + +@Task_Api +Scenario Outline: Get details of a Task with valid payload + Given I have an endpoint /tasks + And I have a Task Request body + And I have a Workflow Instance WorkflowInstance_TaskApi_1 with no artifacts + When I send a GET request + Then I will get a 200 response + And I can see task payload is returned + Examples: + | taskRequest | + | Valid_Task_Details_1 | + | Valid_Task_Details_2 | + +Scenario: Get details of all Tasks + Given I have an endpoint /tasks/running?pageNumber=1&pageSize=10 + And I have a Workflow Instance WorkflowInstance_TaskApi_1 with no artifacts + When I send a GET request + Then I will get a 200 response + And I can see task payload is returned diff --git a/tests/IntegrationTests/WorkflowExecutor.IntegrationTests/StepDefinitions/CommonApiStepDefinitions.cs b/tests/IntegrationTests/WorkflowExecutor.IntegrationTests/StepDefinitions/CommonApiStepDefinitions.cs index 1f09dedf1..e04f33b7e 100644 --- a/tests/IntegrationTests/WorkflowExecutor.IntegrationTests/StepDefinitions/CommonApiStepDefinitions.cs +++ b/tests/IntegrationTests/WorkflowExecutor.IntegrationTests/StepDefinitions/CommonApiStepDefinitions.cs @@ -58,6 +58,13 @@ public void GivenIHaveABody(string name) Support.HttpRequestMessageExtensions.AddJsonBody(ApiHelper.Request, DataHelper.GetWorkflowObjectTestData(name)); } + [When(@"I have a Task Request body (.*)")] + [Given(@"I have a Task Request body (.*)")] + public void GivenIHaveTaskRequestBody(string name) + { + Support.HttpRequestMessageExtensions.AddJsonBody(ApiHelper.Request, DataHelper.GetTaskRequestTestData(name)); + } + [Then(@"I will recieve the error message (.*)")] public void ThenIWillRecieveTheCorrectErrorMessage(string message) { diff --git a/tests/IntegrationTests/WorkflowExecutor.IntegrationTests/StepDefinitions/TasksApiStepDefinitions.cs b/tests/IntegrationTests/WorkflowExecutor.IntegrationTests/StepDefinitions/TasksApiStepDefinitions.cs new file mode 100644 index 000000000..8583e3c2f --- /dev/null +++ b/tests/IntegrationTests/WorkflowExecutor.IntegrationTests/StepDefinitions/TasksApiStepDefinitions.cs @@ -0,0 +1,29 @@ +using BoDi; +using Monai.Deploy.WorkflowManager.Contracts.Models; +using Monai.Deploy.WorkflowManager.IntegrationTests.Support; +using Newtonsoft.Json; + +namespace Monai.Deploy.WorkflowManager.WorkflowExecutor.IntegrationTests.StepDefinitions +{ + [Binding] + public class TasksApiStepDefinitions + { + public TasksApiStepDefinitions(ObjectContainer objectContainer) + { + DataHelper = objectContainer.Resolve(); + ApiHelper = objectContainer.Resolve(); + Assertions = new Assertions(objectContainer); + } + + public DataHelper DataHelper { get; } + public ApiHelper ApiHelper { get; } + public Assertions Assertions { get; } + + [Then(@"I can see an individual task is returned")] + public void ThenICanSeeAnIndividualTaskIsReturned() + { + var response = JsonConvert.DeserializeObject(ApiHelper.Response.Content.ReadAsStringAsync().Result); + Assertions.AssertTaskPayload(DataHelper.WorkflowInstances, response); + } + } +} diff --git a/tests/IntegrationTests/WorkflowExecutor.IntegrationTests/Support/Assertions.cs b/tests/IntegrationTests/WorkflowExecutor.IntegrationTests/Support/Assertions.cs index a22d804f7..95df4b14a 100644 --- a/tests/IntegrationTests/WorkflowExecutor.IntegrationTests/Support/Assertions.cs +++ b/tests/IntegrationTests/WorkflowExecutor.IntegrationTests/Support/Assertions.cs @@ -32,6 +32,22 @@ public Assertions(ObjectContainer objectContainer) MinioClient = objectContainer.Resolve(); } + public void AssertTaskPayload(List workflowInstances, TaskExecution? response) + { + foreach (var workflowInstance in workflowInstances) + { + var taskExecution = workflowInstance.Tasks.First(x => x.TaskId.Equals(response?.TaskId)); + + if (taskExecution != null) + { + taskExecution.Should().BeEquivalentTo(response, options => options.Excluding(x => x.TaskStartTime)); + return; + } + } + + throw new Exception($"TaskId={response.TaskId} was not found in any workflow instances"); + } + public void AssertWorkflowInstanceMatchesExpectedWorkflow(WorkflowInstance workflowInstance, WorkflowRevision workflowRevision, WorkflowRequestMessage workflowRequestMessage) { workflowInstance.PayloadId.Should().Match(workflowRequestMessage.PayloadId.ToString()); diff --git a/tests/IntegrationTests/WorkflowExecutor.IntegrationTests/Support/DataHelper.cs b/tests/IntegrationTests/WorkflowExecutor.IntegrationTests/Support/DataHelper.cs index 0330e4c08..8239bda1a 100644 --- a/tests/IntegrationTests/WorkflowExecutor.IntegrationTests/Support/DataHelper.cs +++ b/tests/IntegrationTests/WorkflowExecutor.IntegrationTests/Support/DataHelper.cs @@ -17,6 +17,7 @@ using Monai.Deploy.Messaging.Events; using Monai.Deploy.WorkflowManager.Contracts.Models; using Monai.Deploy.WorkflowManager.IntegrationTests.Models; +using Monai.Deploy.WorkflowManager.Models; using Monai.Deploy.WorkflowManager.WorkflowExecutor.IntegrationTests.TestData; using Polly; using Polly.Retry; @@ -57,6 +58,18 @@ public DataHelper(RabbitConsumer taskDispatchConsumer, RabbitConsumer exportRequ RetryPayloadCollections = Policy>.Handle().WaitAndRetry(retryCount: 20, sleepDurationProvider: _ => TimeSpan.FromMilliseconds(500)); } + public TasksRequest GetTaskRequestTestData(string name) + { + var taskRequest = TaskRequestsTestData.TestData.FirstOrDefault(c => c.Name.Equals(name)); + + if (taskRequest?.TaskRequest == null) + { + throw new Exception($"Task Request {name} does not have any applicable test data, please check and try again!"); + } + + return taskRequest.TaskRequest; + } + public WorkflowRevision GetWorkflowRevisionTestData(string name) { var workflowRevision = WorkflowRevisionsTestData.TestData.FirstOrDefault(c => c.Name.Equals(name)); diff --git a/tests/IntegrationTests/WorkflowExecutor.IntegrationTests/TestData/TaskRequestTestData.cs b/tests/IntegrationTests/WorkflowExecutor.IntegrationTests/TestData/TaskRequestTestData.cs new file mode 100644 index 000000000..231a5e348 --- /dev/null +++ b/tests/IntegrationTests/WorkflowExecutor.IntegrationTests/TestData/TaskRequestTestData.cs @@ -0,0 +1,38 @@ +using Monai.Deploy.WorkflowManager.Models; + +namespace Monai.Deploy.WorkflowManager.WorkflowExecutor.IntegrationTests.TestData +{ + public class TaskRequestTestData + { + public string? Name { get; set; } + + public TasksRequest? TaskRequest { get; set; } + } + + public static class TaskRequestsTestData + { + public static List TestData = new List() + { + new TaskRequestTestData + { + Name = "Valid_Task_Details_1", + TaskRequest = new TasksRequest() + { + WorkflowInstanceId = "44a63094-9e36-4ba4-9fea-8e9b76aa875b", + ExecutionId = "8ff3ea90-0113-4071-9b92-5068956daeff", + TaskId = "7b8ea05b-8abe-4848-928d-d55f5eef1bc3", + } + }, + new TaskRequestTestData + { + Name = "Valid_Task_Details_2", + TaskRequest = new TasksRequest() + { + WorkflowInstanceId = "44a63094-9e36-4ba4-9fea-8e9b76aa875b", + ExecutionId = "a1cd5b89-85e8-4d32-b9aa-bdbc0f4bbba5", + TaskId = "953c0236-5292-4186-80ee-ef7d4073220b", + } + } + }; + } +} diff --git a/tests/IntegrationTests/WorkflowExecutor.IntegrationTests/TestData/WorkflowInstanceTestData.cs b/tests/IntegrationTests/WorkflowExecutor.IntegrationTests/TestData/WorkflowInstanceTestData.cs index cc8f4b986..11536955a 100644 --- a/tests/IntegrationTests/WorkflowExecutor.IntegrationTests/TestData/WorkflowInstanceTestData.cs +++ b/tests/IntegrationTests/WorkflowExecutor.IntegrationTests/TestData/WorkflowInstanceTestData.cs @@ -1116,6 +1116,118 @@ public static WorkflowInstance CreateWorkflowInstance(string workflowName) Name = "TwoTask_Context.Executions.Task_id.Output_Dir_Mandatory=Null", WorkflowInstance = CreateWorkflowInstance("TwoTask_Context.Executions.Task_id.Output_Dir_Mandatory=Null") }, + new WorkflowInstanceTestData() + { + Name = "WorkflowInstance_TaskApi_1", + WorkflowInstance = new WorkflowInstance() + { + Id = "44a63094-9e36-4ba4-9fea-8e9b76aa875b", + AeTitle = "Ae_test", + WorkflowId = "a971f5f8-68fa-4cd0-ad34-f20b66675d21", + PayloadId = "e908ff53-d808-4c9b-82b6-698b8c60e811", + StartTime = DateTime.Now, + Status = Status.Created, + BucketId = TestExecutionConfig.MinioConfig.Bucket, + InputMetaData = new Dictionary() + { + { "", "" } + }, + Tasks = new List + { + new TaskExecution() + { + ExecutionId = "8ff3ea90-0113-4071-9b92-5068956daeff", + TaskId = "7b8ea05b-8abe-4848-928d-d55f5eef1bc3", + TaskType = "router", + Status = TaskExecutionStatus.Accepted, + InputArtifacts = null, + OutputArtifacts = null, + }, + new TaskExecution() + { + ExecutionId = "a1cd5b89-85e8-4d32-b9aa-bdbc0f4bbba5", + TaskId = "953c0236-5292-4186-80ee-ef7d4073220b", + TaskType = "export", + Status = TaskExecutionStatus.Succeeded, + InputArtifacts = new Dictionary() + { + {"key_1", "value_1" } + }, + OutputArtifacts = new Dictionary() + { + {"key_1", "value_1" } + }, + OutputDirectory = "payload_id/dcm", + Reason = FailureReason.None, + PreviousTaskId = "PreviousTask", + ExecutionStats = new Dictionary() + { + {"key_1", "value_1" } + }, + ResultMetadata = new Dictionary() + { + {"key_1", "value_1" }, + {"key_2", 1 } + }, + InputParameters = new Dictionary() + { + {"key_1", "value_1" }, + {"key_2", 1 } + }, + TaskPluginArguments = new Dictionary() + { + {"key_1", "value_1" } + }, + TaskStartTime = DateTime.UtcNow + }, + new TaskExecution() + { + ExecutionId = "d1e0a3b7-3026-4cf7-ba04-71c1f50d98f6", + TaskId = "b3b537ae-79e8-4d13-9154-982ee4743595", + TaskType = "argo", + Status = TaskExecutionStatus.Created, + InputArtifacts = null, + OutputArtifacts = null, + }, + new TaskExecution() + { + ExecutionId = "666faff9-c702-48a9-ae37-5d92e1f6b324", + TaskId = "aad3762a-5c49-499b-a368-e5f9b98408e4", + TaskType = "export", + Status = TaskExecutionStatus.Exported, + InputArtifacts = null, + OutputArtifacts = null, + }, + new TaskExecution() + { + ExecutionId = "3b30b992-a87b-4885-9176-824b751f076e", + TaskId = "1ecdcc90-a999-48fa-a507-99d4ea7c9cb0", + TaskType = "argo", + Status = TaskExecutionStatus.Canceled, + InputArtifacts = null, + OutputArtifacts = null, + }, + new TaskExecution() + { + ExecutionId = "d9b54e70-d016-476d-b9c3-86ffb17ef786", + TaskId = "a08920eb-0895-4272-ad81-54f2046d8438", + TaskType = "argo", + Status = TaskExecutionStatus.Succeeded, + InputArtifacts = null, + OutputArtifacts = null, + }, + new TaskExecution() + { + ExecutionId = "0c01f526-e574-40df-b21b-99cd16f5c305", + TaskId = "93d8e1c5-39b1-43f0-9bac-372c438b91c0", + TaskType = "argo", + Status = TaskExecutionStatus.Failed, + InputArtifacts = null, + OutputArtifacts = null, + }, + } + } + }, }; } } From 6e31d95fd1bdba0252d760d33935085c9656fce9 Mon Sep 17 00:00:00 2001 From: Joss Sparkes Date: Mon, 8 Aug 2022 16:10:47 +0100 Subject: [PATCH 2/4] Task tests added and working Signed-off-by: Joss Sparkes --- .../Monai.Deploy.WorkflowManager.slconfig | 28 +- .../CSharp/SonarLint.xml | 178 ++--- ...onai-deploy-workflow-managercsharp.ruleset | 754 +++++++++--------- src/.sonarlint/sonar.settings.json | 1 + ...onai.Deploy.WorkflowManager.Logging.csproj | 5 + ...loy.WorkflowManager.PayloadListener.csproj | 1 + .../Features/TasksApi.feature | 29 +- .../TestData/TaskRequestTestData.cs | 60 ++ 8 files changed, 573 insertions(+), 483 deletions(-) create mode 100644 src/.sonarlint/sonar.settings.json diff --git a/src/.sonarlint/Monai.Deploy.WorkflowManager.slconfig b/src/.sonarlint/Monai.Deploy.WorkflowManager.slconfig index aaa79edd2..11c306c29 100644 --- a/src/.sonarlint/Monai.Deploy.WorkflowManager.slconfig +++ b/src/.sonarlint/Monai.Deploy.WorkflowManager.slconfig @@ -1,15 +1,15 @@ -{ - "ServerUri": "https://sonarcloud.io/", - "Organization": { - "Key": "project-monai", - "Name": "Project MONAI" - }, - "ProjectKey": "Project-MONAI_monai-deploy-workflow-manager", - "ProjectName": "monai-deploy-workflow-manager", - "Profiles": { - "CSharp": { - "ProfileKey": "AX96ONQSnTk2GEVJ9ILJ", - "ProfileTimestamp": "2022-03-31T10:15:41Z" - } - } +{ + "ServerUri": "https://sonarcloud.io/", + "Organization": { + "Key": "project-monai", + "Name": "Project MONAI" + }, + "ProjectKey": "Project-MONAI_monai-deploy-workflow-manager", + "ProjectName": "monai-deploy-workflow-manager", + "Profiles": { + "CSharp": { + "ProfileKey": "AX96ONQSnTk2GEVJ9ILJ", + "ProfileTimestamp": "2022-07-05T10:19:10Z" + } + } } \ No newline at end of file diff --git a/src/.sonarlint/project-monai_monai-deploy-workflow-manager/CSharp/SonarLint.xml b/src/.sonarlint/project-monai_monai-deploy-workflow-manager/CSharp/SonarLint.xml index c6f7cc2ab..9400e26cc 100644 --- a/src/.sonarlint/project-monai_monai-deploy-workflow-manager/CSharp/SonarLint.xml +++ b/src/.sonarlint/project-monai_monai-deploy-workflow-manager/CSharp/SonarLint.xml @@ -1,89 +1,89 @@ - - - - - sonar.cs.analyzeGeneratedCode - false - - - sonar.cs.file.suffixes - .cs - - - sonar.cs.ignoreHeaderComments - true - - - sonar.cs.roslyn.ignoreIssues - false - - - - - S107 - - - max - 7 - - - - - S110 - - - max - 5 - - - - - S1479 - - - maximum - 30 - - - - - S2342 - - - flagsAttributeFormat - ^([A-Z]{1,3}[a-z0-9]+)*([A-Z]{2})?s$ - - - format - ^([A-Z]{1,3}[a-z0-9]+)*([A-Z]{2})?$ - - - - - S2436 - - - max - 2 - - - maxMethod - 3 - - - - - S3776 - - - propertyThreshold - 3 - - - threshold - 15 - - - - - + + + + + sonar.cs.analyzeGeneratedCode + false + + + sonar.cs.file.suffixes + .cs + + + sonar.cs.ignoreHeaderComments + true + + + sonar.cs.roslyn.ignoreIssues + false + + + + + S107 + + + max + 7 + + + + + S110 + + + max + 5 + + + + + S1479 + + + maximum + 30 + + + + + S2342 + + + flagsAttributeFormat + ^([A-Z]{1,3}[a-z0-9]+)*([A-Z]{2})?s$ + + + format + ^([A-Z]{1,3}[a-z0-9]+)*([A-Z]{2})?$ + + + + + S2436 + + + max + 2 + + + maxMethod + 3 + + + + + S3776 + + + propertyThreshold + 3 + + + threshold + 15 + + + + + \ No newline at end of file diff --git a/src/.sonarlint/project-monai_monai-deploy-workflow-managercsharp.ruleset b/src/.sonarlint/project-monai_monai-deploy-workflow-managercsharp.ruleset index 9189ba28c..abde5d2c4 100644 --- a/src/.sonarlint/project-monai_monai-deploy-workflow-managercsharp.ruleset +++ b/src/.sonarlint/project-monai_monai-deploy-workflow-managercsharp.ruleset @@ -1,380 +1,376 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/src/.sonarlint/sonar.settings.json b/src/.sonarlint/sonar.settings.json new file mode 100644 index 000000000..10d827d5c --- /dev/null +++ b/src/.sonarlint/sonar.settings.json @@ -0,0 +1 @@ +{"sonar.exclusions":[],"sonar.global.exclusions":["**/build-wrapper-dump.json"],"sonar.inclusions":[]} \ No newline at end of file diff --git a/src/WorkflowManager/Logging/Monai.Deploy.WorkflowManager.Logging.csproj b/src/WorkflowManager/Logging/Monai.Deploy.WorkflowManager.Logging.csproj index 5c3ceb26d..b1af8cf9c 100644 --- a/src/WorkflowManager/Logging/Monai.Deploy.WorkflowManager.Logging.csproj +++ b/src/WorkflowManager/Logging/Monai.Deploy.WorkflowManager.Logging.csproj @@ -19,8 +19,13 @@ net6.0 enable + ..\.sonarlint\project-monai_monai-deploy-workflow-managercsharp.ruleset + + + + diff --git a/src/WorkflowManager/PayloadListener/Monai.Deploy.WorkflowManager.PayloadListener.csproj b/src/WorkflowManager/PayloadListener/Monai.Deploy.WorkflowManager.PayloadListener.csproj index 069012969..072c981d3 100644 --- a/src/WorkflowManager/PayloadListener/Monai.Deploy.WorkflowManager.PayloadListener.csproj +++ b/src/WorkflowManager/PayloadListener/Monai.Deploy.WorkflowManager.PayloadListener.csproj @@ -44,6 +44,7 @@ true true + ..\.sonarlint\project-monai_monai-deploy-workflow-managercsharp.ruleset diff --git a/tests/IntegrationTests/WorkflowExecutor.IntegrationTests/Features/TasksApi.feature b/tests/IntegrationTests/WorkflowExecutor.IntegrationTests/Features/TasksApi.feature index 43007d4e3..e882bffcc 100644 --- a/tests/IntegrationTests/WorkflowExecutor.IntegrationTests/Features/TasksApi.feature +++ b/tests/IntegrationTests/WorkflowExecutor.IntegrationTests/Features/TasksApi.feature @@ -9,12 +9,39 @@ Scenario Outline: Get details of a Task with valid payload And I have a Workflow Instance WorkflowInstance_TaskApi_1 with no artifacts When I send a GET request Then I will get a 200 response - And I can see task payload is returned + And I can see an individual task is returned Examples: | taskRequest | | Valid_Task_Details_1 | | Valid_Task_Details_2 | +@Task_Api +Scenario Outline: Get details of a Task with invalid payload + Given I have an endpoint /tasks + And I have a Task Request body + And I have a Workflow Instance WorkflowInstance_TaskApi_1 with no artifacts + When I send a GET request + Then I will get a 400 response + Examples: + | taskRequest | + | Invalid_WorkflowID_Task_Details_1 | + | Invalid_ExecutionID_Task_Details_2 | + | Invalid_TaskID_Task_Details_3 | + +@Task_Api +Scenario Outline: Get details of a Task with non-existent id payload + Given I have an endpoint /tasks + And I have a Task Request body + And I have a Workflow Instance WorkflowInstance_TaskApi_1 with no artifacts + When I send a GET request + Then I will get a 404 response + Examples: + | taskRequest | + | Non_Existent_WorkflowID_Task_Details_1 | + | Non_Existent_ExecutionID_Task_Details_2 | + | Non_Existent_TaskID_Task_Details_3 | + +@Task_Api Scenario: Get details of all Tasks Given I have an endpoint /tasks/running?pageNumber=1&pageSize=10 And I have a Workflow Instance WorkflowInstance_TaskApi_1 with no artifacts diff --git a/tests/IntegrationTests/WorkflowExecutor.IntegrationTests/TestData/TaskRequestTestData.cs b/tests/IntegrationTests/WorkflowExecutor.IntegrationTests/TestData/TaskRequestTestData.cs index 231a5e348..2597c1914 100644 --- a/tests/IntegrationTests/WorkflowExecutor.IntegrationTests/TestData/TaskRequestTestData.cs +++ b/tests/IntegrationTests/WorkflowExecutor.IntegrationTests/TestData/TaskRequestTestData.cs @@ -32,6 +32,66 @@ public static class TaskRequestsTestData ExecutionId = "a1cd5b89-85e8-4d32-b9aa-bdbc0f4bbba5", TaskId = "953c0236-5292-4186-80ee-ef7d4073220b", } + }, + new TaskRequestTestData + { + Name = "Invalid_WorkflowID_Task_Details_1", + TaskRequest = new TasksRequest() + { + WorkflowInstanceId = "NotAGUID", + ExecutionId = "a1cd5b89-85e8-4d32-b9aa-bdbc0f4bbba5", + TaskId = "953c0236-5292-4186-80ee-ef7d4073220b", + } + }, + new TaskRequestTestData + { + Name = "Invalid_ExecutionID_Task_Details_2", + TaskRequest = new TasksRequest() + { + WorkflowInstanceId = "44a63094-9e36-4ba4-9fea-8e9b76aa875b", + ExecutionId = "NotAGUID", + TaskId = "953c0236-5292-4186-80ee-ef7d4073220b", + } + }, + new TaskRequestTestData + { + Name = "Invalid_TaskID_Task_Details_3", + TaskRequest = new TasksRequest() + { + WorkflowInstanceId = "44a63094-9e36-4ba4-9fea-8e9b76aa875b", + ExecutionId = "a1cd5b89-85e8-4d32-b9aa-bdbc0f4bbba5", + TaskId = "NotAGUID", + } + }, + new TaskRequestTestData + { + Name = "Non_Existent_WorkflowID_Task_Details_1", + TaskRequest = new TasksRequest() + { + WorkflowInstanceId = "0c533e6d-8c86-422b-8564-00f68aff6e20", + ExecutionId = "a1cd5b89-85e8-4d32-b9aa-bdbc0f4bbba5", + TaskId = "953c0236-5292-4186-80ee-ef7d4073220b", + } + }, + new TaskRequestTestData + { + Name = "Non_Existent_ExecutionID_Task_Details_2", + TaskRequest = new TasksRequest() + { + WorkflowInstanceId = "44a63094-9e36-4ba4-9fea-8e9b76aa875b", + ExecutionId = "60544cb8-d475-4271-8ead-8ef698c0da99", + TaskId = "953c0236-5292-4186-80ee-ef7d4073220b", + } + }, + new TaskRequestTestData + { + Name = "Non_Existent_TaskID_Task_Details_3", + TaskRequest = new TasksRequest() + { + WorkflowInstanceId = "44a63094-9e36-4ba4-9fea-8e9b76aa875b", + ExecutionId = "a1cd5b89-85e8-4d32-b9aa-bdbc0f4bbba5", + TaskId = "c16640cd-af88-495c-8c7e-fcbfbd740179", + } } }; } From 8bf3ac7d357d6970baaa81bd973c627a80f9bdfc Mon Sep 17 00:00:00 2001 From: Joss Sparkes Date: Tue, 9 Aug 2022 13:49:36 +0100 Subject: [PATCH 3/4] Ignored /tasks/running tests as this will be covered in a further ticket Signed-off-by: Joss Sparkes --- .../WorkflowExecutor.IntegrationTests/Features/TasksApi.feature | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/IntegrationTests/WorkflowExecutor.IntegrationTests/Features/TasksApi.feature b/tests/IntegrationTests/WorkflowExecutor.IntegrationTests/Features/TasksApi.feature index e882bffcc..07651b277 100644 --- a/tests/IntegrationTests/WorkflowExecutor.IntegrationTests/Features/TasksApi.feature +++ b/tests/IntegrationTests/WorkflowExecutor.IntegrationTests/Features/TasksApi.feature @@ -41,7 +41,7 @@ Scenario Outline: Get details of a Task with non-existent id payload | Non_Existent_ExecutionID_Task_Details_2 | | Non_Existent_TaskID_Task_Details_3 | -@Task_Api +@Task_Api @ignore #/tasks/running endpoint needs some dev work to ensure the filter works correctly. Ticket https://github.com/Project-MONAI/monai-deploy-workflow-manager/issues/308 Scenario: Get details of all Tasks Given I have an endpoint /tasks/running?pageNumber=1&pageSize=10 And I have a Workflow Instance WorkflowInstance_TaskApi_1 with no artifacts From e5d8d475b8a31fcbbe58d3c9cf45d7ae987ac1ab Mon Sep 17 00:00:00 2001 From: Joss Sparkes Date: Tue, 9 Aug 2022 14:11:20 +0100 Subject: [PATCH 4/4] Added license header to new files Signed-off-by: Joss Sparkes --- .../Features/TasksApi.feature | 16 +++++++++++++++- .../StepDefinitions/TasksApiStepDefinitions.cs | 16 ++++++++++++++++ .../TestData/TaskRequestTestData.cs | 18 +++++++++++++++++- 3 files changed, 48 insertions(+), 2 deletions(-) diff --git a/tests/IntegrationTests/WorkflowExecutor.IntegrationTests/Features/TasksApi.feature b/tests/IntegrationTests/WorkflowExecutor.IntegrationTests/Features/TasksApi.feature index 07651b277..2348fa599 100644 --- a/tests/IntegrationTests/WorkflowExecutor.IntegrationTests/Features/TasksApi.feature +++ b/tests/IntegrationTests/WorkflowExecutor.IntegrationTests/Features/TasksApi.feature @@ -1,4 +1,18 @@ -Feature: Tasks Api +# 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: Tasks Api API to retrieve task status. diff --git a/tests/IntegrationTests/WorkflowExecutor.IntegrationTests/StepDefinitions/TasksApiStepDefinitions.cs b/tests/IntegrationTests/WorkflowExecutor.IntegrationTests/StepDefinitions/TasksApiStepDefinitions.cs index 8583e3c2f..a1d074147 100644 --- a/tests/IntegrationTests/WorkflowExecutor.IntegrationTests/StepDefinitions/TasksApiStepDefinitions.cs +++ b/tests/IntegrationTests/WorkflowExecutor.IntegrationTests/StepDefinitions/TasksApiStepDefinitions.cs @@ -1,3 +1,19 @@ +/* + * 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.Contracts.Models; using Monai.Deploy.WorkflowManager.IntegrationTests.Support; diff --git a/tests/IntegrationTests/WorkflowExecutor.IntegrationTests/TestData/TaskRequestTestData.cs b/tests/IntegrationTests/WorkflowExecutor.IntegrationTests/TestData/TaskRequestTestData.cs index 2597c1914..064acc4a6 100644 --- a/tests/IntegrationTests/WorkflowExecutor.IntegrationTests/TestData/TaskRequestTestData.cs +++ b/tests/IntegrationTests/WorkflowExecutor.IntegrationTests/TestData/TaskRequestTestData.cs @@ -1,4 +1,20 @@ -using Monai.Deploy.WorkflowManager.Models; +/* + * 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.WorkflowManager.Models; namespace Monai.Deploy.WorkflowManager.WorkflowExecutor.IntegrationTests.TestData {