Skip to content

Commit

Permalink
Merge pull request #813 from Project-MONAI/samrooke/AC-2211-task-mana…
Browse files Browse the repository at this point in the history
…ger-email-plugin-int-tests

add initial int test for email task
  • Loading branch information
woodheadio authored May 31, 2023
2 parents 2a9eeb5 + 2c60c0e commit 77fb6b8
Show file tree
Hide file tree
Showing 21 changed files with 447 additions and 257 deletions.
12 changes: 6 additions & 6 deletions src/TaskManager/Plug-ins/AideClinicalReview/packages.lock.json
Original file line number Diff line number Diff line change
Expand Up @@ -733,8 +733,8 @@
"monai.deploy.workflowmanager.configuration": {
"type": "Project",
"dependencies": {
"Monai.Deploy.Messaging": "[0.1.23, )",
"Monai.Deploy.Storage": "[0.2.15, )"
"Monai.Deploy.Messaging": "0.1.23",
"Monai.Deploy.Storage": "0.2.15"
}
},
"monai.deploy.workflowmanager.shared": {
Expand All @@ -749,11 +749,11 @@
"monai.deploy.workflowmanager.taskmanager.api": {
"type": "Project",
"dependencies": {
"Monai.Deploy.Messaging": "[0.1.23, )",
"Mongo.Migration": "[3.1.4, )",
"MongoDB.Bson": "[2.19.0, )"
"Monai.Deploy.Messaging": "0.1.23",
"Mongo.Migration": "3.1.4",
"MongoDB.Bson": "2.19.0"
}
}
}
}
}
}
12 changes: 6 additions & 6 deletions src/TaskManager/Plug-ins/Argo/packages.lock.json
Original file line number Diff line number Diff line change
Expand Up @@ -1203,8 +1203,8 @@
"monai.deploy.workflowmanager.configuration": {
"type": "Project",
"dependencies": {
"Monai.Deploy.Messaging": "[0.1.23, )",
"Monai.Deploy.Storage": "[0.2.15, )"
"Monai.Deploy.Messaging": "0.1.23",
"Monai.Deploy.Storage": "0.2.15"
}
},
"monai.deploy.workflowmanager.shared": {
Expand All @@ -1219,11 +1219,11 @@
"monai.deploy.workflowmanager.taskmanager.api": {
"type": "Project",
"dependencies": {
"Monai.Deploy.Messaging": "[0.1.23, )",
"Mongo.Migration": "[3.1.4, )",
"MongoDB.Bson": "[2.19.0, )"
"Monai.Deploy.Messaging": "0.1.23",
"Mongo.Migration": "3.1.4",
"MongoDB.Bson": "2.19.0"
}
}
}
}
}
}
4 changes: 0 additions & 4 deletions src/TaskManager/Plug-ins/Email/EmailPlugin.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,7 @@


using System.Net.Mail;
using System.Text.Json;
using Ardalis.GuardClauses;
using FellowOakDicom.Serialization;
using FellowOakDicom;
using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Options;
Expand Down Expand Up @@ -113,8 +111,6 @@ private void ValidateEventAndInit()
}
}



public override async Task<ExecutionStatus> ExecuteTask(CancellationToken cancellationToken = default)
{
using var loggingScope = _logger.BeginScope(new Dictionary<string, object>
Expand Down
1 change: 0 additions & 1 deletion src/TaskManager/TaskManager/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@
using Monai.Deploy.WorkflowManager.Shared.Services;
using Microsoft.AspNetCore.Builder;


namespace Monai.Deploy.WorkflowManager.TaskManager
{
public class Program
Expand Down
21 changes: 15 additions & 6 deletions src/TaskManager/TaskManager/packages.lock.json
Original file line number Diff line number Diff line change
Expand Up @@ -1920,8 +1920,8 @@
"monai.deploy.workflowmanager.configuration": {
"type": "Project",
"dependencies": {
"Monai.Deploy.Messaging": "[0.1.23, )",
"Monai.Deploy.Storage": "[0.2.15, )"
"Monai.Deploy.Messaging": "0.1.23",
"Monai.Deploy.Storage": "0.2.15"
}
},
"monai.deploy.workflowmanager.shared": {
Expand Down Expand Up @@ -1969,9 +1969,18 @@
"monai.deploy.workflowmanager.taskmanager.docker": {
"type": "Project",
"dependencies": {
"Docker.DotNet": "[3.125.13, )",
"Monai.Deploy.WorkflowManager.Configuration": "[1.0.0, )",
"Monai.Deploy.WorkflowManager.TaskManager.API": "[1.0.0, )"
"Docker.DotNet": "3.125.13",
"Monai.Deploy.WorkflowManager.Configuration": "1.0.0",
"Monai.Deploy.WorkflowManager.TaskManager.API": "1.0.0"
}
},
"monai.deploy.workflowmanager.taskmanager.email": {
"type": "Project",
"dependencies": {
"Monai.Deploy.WorkflowManager.Configuration": "1.0.0",
"Monai.Deploy.WorkflowManager.Shared": "1.0.0",
"Monai.Deploy.WorkflowManager.TaskManager.API": "1.0.0",
"fo-dicom": "5.0.3"
}
},
"monai.deploy.workflowmanager.taskmanager.email": {
Expand All @@ -1985,4 +1994,4 @@
}
}
}
}
}
2 changes: 1 addition & 1 deletion src/WorkflowManager/WorkflowManager/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ namespace Monai.Deploy.WorkflowManager
{
#pragma warning disable SA1600 // Elements should be documented

internal class Program
public class Program
{
protected Program()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,80 +12,68 @@
# See the License for the specific language governing permissions and
# limitations under the License.

@IntergrationTests
@IntegrationTests
Feature: ClinicalReview

Integration tests for the clinical review plugin

@ClinicalReviewPlugin
Scenario: Clincial review task dispatch event triggers a clinical review request event with all patient details
Given I have a bucket in MinIO bucket1
When A Task Dispatch event is published Task_Dispatch_Clinical_Review_Full_Patient_Details
Then A Clincial Review Request event is published

@ClinicalReviewPlugin
Scenario: Clincial review task dispatch event triggers a clinical review request event with partial patient details
Given I have a bucket in MinIO bucket1
When A Task Dispatch event is published Task_Dispatch_Clinical_Review_Partial_Patient_Details
Then A Clincial Review Request event is published

@ClinicalReviewPlugin
Scenario: Clincial review task dispatch event triggers a clinical review request event with no patient details
Given I have a bucket in MinIO bucket1
When A Task Dispatch event is published Task_Dispatch_Clinical_Review_No_Patient_Details
Then A Clincial Review Request event is published

@ClinicalReviewPlugin
Scenario: Clincial review task dispatch event triggers a clinical review request event with multiple files
Given I have a bucket in MinIO bucket1
When A Task Dispatch event is published Task_Dispatch_Clinical_Review_Multi_File
Then A Clincial Review Request event is published

@ClinicalReviewPlugin
Scenario: Clincial review task dispatch event triggers clincial review event with single reviewer role
Given I have a bucket in MinIO bucket1
When A Task Dispatch event is published Task_Dispatch_Clinical_Reviewer_Role_Single_Role
Then A Clincial Review Request event is published

@ClinicalReviewPlugin
Scenario: Clincial review task dispatch event triggers clincial review event with default reviewer role
Given I have a bucket in MinIO bucket1
When A Task Dispatch event is published Task_Dispatch_Clinical_Reviewer_Role_Mutiple_Roles
Then A Clincial Review Request event is published

@ClinicalReviewPlugin
Scenario: Clincial review task dispatch event triggers clincial review event with mutiple reviewer roles
Given I have a bucket in MinIO bucket1
When A Task Dispatch event is published Task_Dispatch_Clinical_Reviewer_Role_Default_Role
Then A Clincial Review Request event is published

@ClinicalReviewPlugin
Scenario: Clincial review task dispatch event triggers clincial review event with application name
Given I have a bucket in MinIO bucket1
When A Task Dispatch event is published Task_Dispatch_Clinical_Review_Application_Name
Then A Clincial Review Request event is published

@ClinicalReviewPlugin
Scenario: Clincial review task dispatch event triggers clincial review event with application version
Given I have a bucket in MinIO bucket1
When A Task Dispatch event is published Task_Dispatch_Clinical_Review_Application_Version
Then A Clincial Review Request event is published

@ClinicalReviewPlugin
Scenario: Clincial review task dispatch event triggers clincial review event with QA mode
Given I have a bucket in MinIO bucket1
When A Task Dispatch event is published Task_Dispatch_Clinical_Review_QA_Mode
Then A Clincial Review Request event is published

@ClinicalReviewPlugin
Scenario: Clincial review task dispatch event triggers clincial review event with reviewed execution Id
Given I have a bucket in MinIO bucket1
When A Task Dispatch event is published Task_Dispatch_Clinical_Review_Reviewed_Execution_Id
Then A Clincial Review Request event is published

@ClinicalReviewPlugin
Scenario Outline: Clincial review task dispatch event triggers clincial review event with notifications
Given I have a bucket in MinIO bucket1
When A Task Dispatch event is published <testData>
Then A Clincial Review Request event is published
Examples:
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# Copyright 2023 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.

@IntegrationTests
Feature: EmialNotification

Integration tests for the email plugin

@EmailPlugin
Scenario: Email task dispatch event triggers an email request event with all relevant args
Given I have an input DICOM file saved in MinIO for TaskDispatch Task_Dispatch_Email_All
When A Task Dispatch event is published Task_Dispatch_Email_All
Then An email request event is published

@EmailPlugin
Scenario: Email task dispatch event triggers an email request event with only emails arg
Given I have an input DICOM file saved in MinIO for TaskDispatch Task_Dispatch_Email_Emails
When A Task Dispatch event is published Task_Dispatch_Email_Emails
Then An email request event is published

@EmailPlugin
Scenario: Email task dispatch event triggers an email request event with only roles arg
Given I have an input DICOM file saved in MinIO for TaskDispatch Task_Dispatch_Email_Roles
When A Task Dispatch event is published Task_Dispatch_Email_Roles
Then An email request event is published
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,11 @@ Integration tests for testing TaskUpdateEvents from TaskManager

@TaskDispatch_TaskUpdate
Scenario: TaskUpdateEvent is published with status Accepted after receiving a valid TaskDispatchEvent
Given I have a bucket in MinIO bucket1
When A Task Dispatch event is published Task_Dispatch_Accepted
Then A Task Update event with status Accepted is published with Task Dispatch details

@TaskDispatch_TaskUpdate
Scenario Outline: TaskUpdateEvent is published with status Failed after receiving an invalid TaskDispatchEvent
Given I have a bucket in MinIO bucket1
When A Task Dispatch event is published <TaskDispatchEvent>
Then A Task Update event with status Failed is published with Task Dispatch details
Examples:
Expand All @@ -39,7 +37,6 @@ Scenario Outline: TaskUpdateEvent is published with status Failed after receivin
@Ignore
@TaskCallback_TaskUpdate
Scenario Outline: TaskUpdateEvent is published with correct status upon receiving a valid TaskCallbackEvent
Given I have a bucket in MinIO bucket1
And I have Task Dispatch Info saved in Mongo Task_Dispatch_Basic_Clinical_Review
When A Task Callback event is published <taskCallbackEvent>
Then A Task Update event with status <status> is published with Task Callback details
Expand Down
23 changes: 17 additions & 6 deletions tests/IntegrationTests/TaskManager.IntegrationTests/Hooks.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@
* limitations under the License.
*/

using Microsoft.AspNetCore.Mvc.Testing;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.Hosting;
using Monai.Deploy.WorkflowManager.TaskManager.IntegrationTests.POCO;
using Monai.Deploy.WorkflowManager.TaskManager.IntegrationTests.Support;
using Polly;
Expand All @@ -42,12 +42,13 @@ public Hooks(IObjectContainer objectContainer)
private static RabbitPublisher? TaskCallbackPublisher { get; set; }
private static RabbitConsumer? TaskUpdateConsumer { get; set; }
public static RabbitConsumer? ClinicalReviewConsumer { get; private set; }
public static RabbitConsumer? EmailConsumer { get; private set; }
private static MinioClientUtil? MinioClient { get; set; }
private static MongoClientUtil? MongoClient { get; set; }
public static AsyncRetryPolicy RetryPolicy { get; private set; }
private IObjectContainer ObjectContainer { get; set; }
private static IHost? Host { get; set; }
private static HttpClient? HttpClient { get; set; }
private static WebApplicationFactory<Program>? WebApplicationFactory { get; set; }

/// <summary>
/// Runs before all tests to create static implementions of Rabbit and Mongo clients as well as starting the WorkflowManager using WebApplicationFactory.
Expand All @@ -70,6 +71,7 @@ public static void Init()
TestExecutionConfig.RabbitConfig.TaskCallbackQueue = "md.tasks.callback";
TestExecutionConfig.RabbitConfig.TaskUpdateQueue = "md.tasks.update";
TestExecutionConfig.RabbitConfig.ClinicalReviewQueue = "aide.clinical_review.request";
TestExecutionConfig.RabbitConfig.EmailQueue = "aide.notification_email.request";
TestExecutionConfig.RabbitConfig.TaskCancellationQueue = "md.tasks.cancellation";

TestExecutionConfig.MongoConfig.ConnectionString = config.GetValue<string>("WorkloadManagerDatabase:ConnectionString");
Expand All @@ -87,11 +89,12 @@ public static void Init()

RabbitConnectionFactory.DeleteAllQueues();

WebApplicationFactory = WebAppFactory.GetWebApplicationFactory();
HttpClient = WebApplicationFactory?.CreateClient();

RetryPolicy = Policy.Handle<Exception>().WaitAndRetryAsync(retryCount: 20, sleepDurationProvider: _ => TimeSpan.FromMilliseconds(500));
MongoClient = new MongoClientUtil();
HttpClient = new HttpClient();
MinioClient = new MinioClientUtil();
Host = TaskManagerStartup.StartTaskManager();

RabbitConnectionFactory.SetRabbitConnection();
}
Expand All @@ -116,7 +119,7 @@ public static async Task CheckTaskManagerConsumersStarted()
{
await RetryPolicy.ExecuteAsync(async () =>
{
var response = await TaskManagerStartup.GetQueueStatus(HttpClient, TestExecutionConfig.RabbitConfig.VirtualHost, TestExecutionConfig.RabbitConfig.TaskDispatchQueue);
var response = await WebAppFactory.GetQueueStatus(HttpClient, TestExecutionConfig.RabbitConfig.VirtualHost, TestExecutionConfig.RabbitConfig.TaskDispatchQueue);
var content = response.Content.ReadAsStringAsync().Result;
if (content.Contains("error"))
Expand All @@ -133,6 +136,13 @@ await RetryPolicy.ExecuteAsync(async () =>
TaskCallbackPublisher = new RabbitPublisher(TestExecutionConfig.RabbitConfig.Exchange, TestExecutionConfig.RabbitConfig.TaskCallbackQueue);
TaskUpdateConsumer = new RabbitConsumer(TestExecutionConfig.RabbitConfig.Exchange, TestExecutionConfig.RabbitConfig.TaskUpdateQueue);
ClinicalReviewConsumer = new RabbitConsumer(TestExecutionConfig.RabbitConfig.Exchange, TestExecutionConfig.RabbitConfig.ClinicalReviewQueue);
EmailConsumer = new RabbitConsumer(TestExecutionConfig.RabbitConfig.Exchange, TestExecutionConfig.RabbitConfig.EmailQueue);
}

[BeforeTestRun(Order = 3)]
public static async Task CreateBucket()
{
await MinioClient.CreateBucket(TestExecutionConfig.MinioConfig.Bucket);
}

/// <summary>
Expand All @@ -145,6 +155,7 @@ public void SetUp(ScenarioContext scenarioContext, ISpecFlowOutputHelper outputH
ObjectContainer.RegisterInstanceAs(TaskCallbackPublisher, "TaskCallbackPublisher");
ObjectContainer.RegisterInstanceAs(TaskUpdateConsumer, "TaskUpdateConsumer");
ObjectContainer.RegisterInstanceAs(ClinicalReviewConsumer, "ClinicalReviewConsumer");
ObjectContainer.RegisterInstanceAs(EmailConsumer, "EmailConsumer");
ObjectContainer.RegisterInstanceAs(MinioClient);
var dataHelper = new DataHelper(ObjectContainer);
ObjectContainer.RegisterInstanceAs(dataHelper);
Expand All @@ -162,7 +173,7 @@ public void SetUp(ScenarioContext scenarioContext, ISpecFlowOutputHelper outputH
public static void TearDownRabbit()
{
RabbitConnectionFactory.DeleteAllQueues();
Host?.StopAsync();
WebApplicationFactory?.Dispose();
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@ public static class RabbitConfig

public static string ClinicalReviewQueue { get; set; }

public static string EmailQueue { get; set; }

public static object TaskCancellationQueue { get; set; }
}

Expand Down
Loading

0 comments on commit 77fb6b8

Please sign in to comment.