Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
75 changes: 0 additions & 75 deletions docker-compose/MinIO/docker-compose.yml

This file was deleted.

14 changes: 0 additions & 14 deletions docker-compose/MongoDB/docker-compose.yml

This file was deleted.

19 changes: 0 additions & 19 deletions docker-compose/RabbitMQ/docker-compose.yml

This file was deleted.

30 changes: 12 additions & 18 deletions tests/IntegrationTests/TaskManager.IntegrationTests/Hooks.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
using Microsoft.Extensions.Hosting;
using Monai.Deploy.WorkflowManager.IntegrationTests.Support;
using Monai.Deploy.WorkflowManager.TaskManager.IntegrationTests.Support;
using Polly;
using Polly.Retry;

namespace Monai.Deploy.WorkflowManager.TaskManager.IntegrationTests
{
Expand All @@ -30,6 +32,7 @@ public Hooks(IObjectContainer objectContainer)
private static RabbitConsumer? TaskUpdateConsumer { get; set; }
public static RabbitConsumer? ClinicalReviewConsumer { get; private set; }
private static MinioClientUtil? MinioClient { 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; }
Expand Down Expand Up @@ -65,6 +68,7 @@ public static void Init()
Host = TaskManagerStartup.StartTaskManager();
HttpClient = new HttpClient();
MinioClient = new MinioClientUtil();
RetryPolicy = Policy.Handle<Exception>().WaitAndRetryAsync(retryCount: 20, sleepDurationProvider: _ => TimeSpan.FromMilliseconds(500));
}

// <summary>
Expand All @@ -75,30 +79,20 @@ public static void Init()
[BeforeTestRun(Order = 1)]
public static async Task CheckTaskManagerConsumersStarted()
{
var response = await TaskManagerStartup.GetConsumers(HttpClient);
var content = response.Content.ReadAsStringAsync().Result;

for (var i = 1; i <= 10; i++)
await RetryPolicy.ExecuteAsync(async () =>
{
if (string.IsNullOrEmpty(content) || content == "[]")
var response = await TaskManagerStartup.GetQueueStatus(HttpClient, TestExecutionConfig.RabbitConfig.VirtualHost, TestExecutionConfig.RabbitConfig.TaskDispatchQueue);
var content = response.Content.ReadAsStringAsync().Result;

if (content.Contains("error"))
{
Debug.Write($"Task Manager not started. Recheck times {i}");
response = await TaskManagerStartup.GetConsumers(HttpClient);
content = response.Content.ReadAsStringAsync().Result;
throw new Exception("Task Manager not started!");
}
else
{
Debug.Write("Task Manager started. Integration tests will begin!");
break;
}

if (i == 10)
{
throw new Exception("Task Manager not started! Integration tests will not continue");
Console.WriteLine("Task Manager started. Integration Tests will begin.");
}

Thread.Sleep(1000);
}
});

TaskDispatchPublisher = new RabbitPublisher(RabbitConnectionFactory.GetConnectionFactory(), TestExecutionConfig.RabbitConfig.Exchange, TestExecutionConfig.RabbitConfig.TaskDispatchQueue);
TaskCallbackPublisher = new RabbitPublisher(RabbitConnectionFactory.GetConnectionFactory(), TestExecutionConfig.RabbitConfig.Exchange, TestExecutionConfig.RabbitConfig.TaskCallbackQueue);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,13 +101,13 @@ public static IHost StartTaskManager()
return host;
}

public static async Task<HttpResponseMessage> GetConsumers(HttpClient httpClient)
public static async Task<HttpResponseMessage> GetQueueStatus(HttpClient httpClient, string vhost, string queue)
{
var svcCredentials = Convert.ToBase64String(Encoding.ASCII.GetBytes(TestExecutionConfig.RabbitConfig.User + ":" + TestExecutionConfig.RabbitConfig.Password));

httpClient.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Basic", svcCredentials);

return await httpClient.GetAsync($"http://{TestExecutionConfig.RabbitConfig.Host}:{TestExecutionConfig.RabbitConfig.Port}/api/consumers");
return await httpClient.GetAsync($"http://{TestExecutionConfig.RabbitConfig.Host}:{TestExecutionConfig.RabbitConfig.Port}/api/queues/{vhost}/{queue}");
}
}
}
30 changes: 12 additions & 18 deletions tests/IntegrationTests/WorkflowExecutor.IntegrationTests/Hooks.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
using Microsoft.Extensions.Hosting;
using Monai.Deploy.WorkflowManager.IntegrationTests.POCO;
using Monai.Deploy.WorkflowManager.IntegrationTests.Support;
using Polly;
using Polly.Retry;

namespace Monai.Deploy.WorkflowManagerIntegrationTests
{
Expand All @@ -26,6 +28,7 @@ public Hooks(IObjectContainer objectContainer)
}

private static HttpClient? HttpClient { get; set; }
public static AsyncRetryPolicy RetryPolicy { get; private set; }
private static RabbitPublisher? WorkflowPublisher { get; set; }
private static RabbitConsumer? TaskDispatchConsumer { get; set; }
private static RabbitPublisher? TaskUpdatePublisher { get; set; }
Expand Down Expand Up @@ -75,6 +78,7 @@ public static void Init()
MinioClient = new MinioClientUtil();
Host = WorkflowExecutorStartup.StartWorkflowExecutor();
HttpClient = new HttpClient();
RetryPolicy = Policy.Handle<Exception>().WaitAndRetryAsync(retryCount: 20, sleepDurationProvider: _ => TimeSpan.FromMilliseconds(500));
}

/// <summary>
Expand All @@ -85,30 +89,20 @@ public static void Init()
[BeforeTestRun(Order = 1)]
public static async Task CheckWorkflowConsumerStarted()
{
var response = await WorkflowExecutorStartup.GetConsumers(HttpClient);
var content = response.Content.ReadAsStringAsync().Result;

for (var i = 1; i <= 10; i++)
await RetryPolicy.ExecuteAsync(async () =>
{
if (string.IsNullOrEmpty(content) || content == "[]")
var response = await WorkflowExecutorStartup.GetQueueStatus(HttpClient, TestExecutionConfig.RabbitConfig.VirtualHost, TestExecutionConfig.RabbitConfig.TaskUpdateQueue);
var content = response.Content.ReadAsStringAsync().Result;

if (content.Contains("error"))
{
Debug.Write($"Workflow consumer not started. Recheck times {i}");
response = await WorkflowExecutorStartup.GetConsumers(HttpClient);
content = response.Content.ReadAsStringAsync().Result;
throw new Exception("Workflow Executor not started!");
}
else
{
Debug.Write("Consumer started. Integration tests will begin!");
break;
Console.WriteLine("Workfow Executor started. Integration Tests will begin.");
}

if (i == 10)
{
throw new Exception("Workflow Mangaer Consumer not started! Integration tests will not continue");
}

Thread.Sleep(1000);
}
});

WorkflowPublisher = new RabbitPublisher(RabbitConnectionFactory.GetConnectionFactory(), TestExecutionConfig.RabbitConfig.Exchange, TestExecutionConfig.RabbitConfig.WorkflowRequestQueue);
TaskDispatchConsumer = new RabbitConsumer(RabbitConnectionFactory.GetConnectionFactory(), TestExecutionConfig.RabbitConfig.Exchange, TestExecutionConfig.RabbitConfig.TaskDispatchQueue);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -114,13 +114,13 @@ public static IHost StartWorkflowExecutor()
return host;
}

public static async Task<HttpResponseMessage> GetConsumers(HttpClient httpClient)
public static async Task<HttpResponseMessage> GetQueueStatus(HttpClient httpClient, string vhost, string queue)
{
var svcCredentials = Convert.ToBase64String(Encoding.ASCII.GetBytes(TestExecutionConfig.RabbitConfig.User + ":" + TestExecutionConfig.RabbitConfig.Password));

httpClient.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Basic", svcCredentials);

return await httpClient.GetAsync($"http://{TestExecutionConfig.RabbitConfig.Host}:{TestExecutionConfig.RabbitConfig.Port}/api/consumers");
return await httpClient.GetAsync($"http://{TestExecutionConfig.RabbitConfig.Host}:{TestExecutionConfig.RabbitConfig.Port}/api/queues/{vhost}/{queue}");
}
}
}

This file was deleted.