Skip to content

Commit 6706175

Browse files
committed
Add debug logs
Signed-off-by: Victor Chang <[email protected]>
1 parent c003116 commit 6706175

File tree

8 files changed

+66
-13
lines changed

8 files changed

+66
-13
lines changed

src/Api/BaseApplicationEntity.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,5 +51,10 @@ public void SetDefaultValues()
5151
if (string.IsNullOrWhiteSpace(Name))
5252
Name = AeTitle;
5353
}
54+
55+
public override string ToString()
56+
{
57+
return $"Name: {Name}/AET: {AeTitle}/Host: {HostIp}";
58+
}
5459
}
5560
}

src/Api/MonaiApplicationEntity.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,5 +113,10 @@ public void SetDefaultValues()
113113

114114
AllowedSopClasses ??= new List<string>();
115115
}
116+
117+
public override string ToString()
118+
{
119+
return $"Name: {Name}/AET: {AeTitle}";
120+
}
116121
}
117122
}

src/Api/Rest/InferenceRequest.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
using System.Collections.Generic;
2020
using System.Linq;
2121
using System.Text.Json.Serialization;
22+
using System.Xml.Linq;
2223
using Ardalis.GuardClauses;
2324
using Monai.Deploy.InformaticsGateway.Common;
2425

@@ -384,5 +385,10 @@ private static void CheckDicomWebConnectionDetails(string source, List<string> e
384385
errors.Add($"The provided URI '{connection.Uri}' is not well formed.");
385386
}
386387
}
388+
389+
public override string ToString()
390+
{
391+
return $"InferenceRequestId: {InferenceRequestId}/TransactionId: {TransactionId}";
392+
}
387393
}
388394
}

src/Api/Storage/Payload.cs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,9 @@
1818
using System.Collections.Generic;
1919
using System.Diagnostics;
2020
using System.Linq;
21+
using System.Transactions;
2122
using Ardalis.GuardClauses;
23+
using Monai.Deploy.InformaticsGateway.Api.Rest;
2224

2325
namespace Monai.Deploy.InformaticsGateway.Api.Storage
2426
{
@@ -122,6 +124,11 @@ protected virtual void Dispose(bool disposing)
122124
}
123125
}
124126

127+
public override string ToString()
128+
{
129+
return $"PayloadId: {PayloadId}/Key: {Key}";
130+
}
131+
125132
public void Dispose()
126133
{
127134
// Do not change this code. Put cleanup code in 'Dispose(bool disposing)' method

src/Database/Api/StorageMetadataWrapper.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
using System.Text.Json;
1818
using System.Text.Json.Serialization;
1919
using Ardalis.GuardClauses;
20+
using Microsoft.EntityFrameworkCore.Metadata.Internal;
2021
using Monai.Deploy.InformaticsGateway.Api;
2122
using Monai.Deploy.InformaticsGateway.Api.Storage;
2223

@@ -81,5 +82,10 @@ public FileStorageMetadata GetObject()
8182
return JsonSerializer.Deserialize(Value, type) as FileStorageMetadata;
8283
#pragma warning restore CS8603 // Possible null reference return.
8384
}
85+
86+
public override string ToString()
87+
{
88+
return $"Identity: {Identity}";
89+
}
8490
}
8591
}

tests/Integration.Test/Drivers/EfDataProvider.cs

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -56,14 +56,26 @@ private string ConvertToFullPath(string connectionString)
5656

5757
public void ClearAllData()
5858
{
59+
_outputHelper.WriteLine("Removing data from the database.");
5960
_dbContext.Database.EnsureCreated();
60-
_dbContext.RemoveRange(_dbContext.DestinationApplicationEntities);
61-
_dbContext.RemoveRange(_dbContext.SourceApplicationEntities);
62-
_dbContext.RemoveRange(_dbContext.MonaiApplicationEntities);
63-
_dbContext.RemoveRange(_dbContext.Payloads);
64-
_dbContext.RemoveRange(_dbContext.InferenceRequests);
65-
_dbContext.RemoveRange(_dbContext.StorageMetadataWrapperEntities);
61+
DumpAndClear("DestinationApplicationEntities", _dbContext.DestinationApplicationEntities.ToList());
62+
DumpAndClear("SourceApplicationEntities", _dbContext.SourceApplicationEntities.ToList());
63+
DumpAndClear("MonaiApplicationEntities", _dbContext.MonaiApplicationEntities.ToList());
64+
DumpAndClear("Payloads", _dbContext.Payloads.ToList());
65+
DumpAndClear("InferenceRequests", _dbContext.InferenceRequests.ToList());
66+
DumpAndClear("StorageMetadataWrapperEntities", _dbContext.StorageMetadataWrapperEntities.ToList());
6667
_dbContext.SaveChanges();
68+
_outputHelper.WriteLine("All data removed from the database.");
69+
}
70+
71+
private void DumpAndClear<T>(string name, List<T> items) where T : class
72+
{
73+
_outputHelper.WriteLine($"==={name}===");
74+
foreach (var item in items)
75+
{
76+
_outputHelper.WriteLine(item.ToString());
77+
}
78+
_dbContext.Set<T>().RemoveRange(items);
6779
}
6880

6981
public async Task<string> InjectAcrRequest()
@@ -89,6 +101,7 @@ public async Task<string> InjectAcrRequest()
89101
_dbContext.Add(request);
90102
await _dbContext.SaveChangesAsync();
91103
_outputHelper.WriteLine($"Injected ACR request {request.TransactionId}");
104+
Console.WriteLine($"Injected ACR request {request.TransactionId}");
92105
return request.TransactionId;
93106
}
94107
}

tests/Integration.Test/Drivers/MongoDBDataProvider.cs

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -67,22 +67,31 @@ public MongoDBDataProvider(ISpecFlowOutputHelper outputHelper, Configurations co
6767

6868
public void ClearAllData()
6969
{
70-
Clear(_infereRequestCollection);
71-
Clear(_payloadCollection);
72-
Clear(_storageMetadataWrapperCollection);
73-
Clear(_sourceApplicationEntityCollection);
74-
Clear(_destinationApplicationEntityCollection);
75-
Clear(_monaiApplicationEntityCollection);
70+
_outputHelper.WriteLine("Removing data from the database.");
71+
DumpClear(_infereRequestCollection);
72+
DumpClear(_payloadCollection);
73+
DumpClear(_storageMetadataWrapperCollection);
74+
DumpClear(_sourceApplicationEntityCollection);
75+
DumpClear(_destinationApplicationEntityCollection);
76+
DumpClear(_monaiApplicationEntityCollection);
77+
_outputHelper.WriteLine("All data removed from the database.");
7678
}
7779

78-
private void Clear<T>(IMongoCollection<T> collection)
80+
private void DumpClear<T>(IMongoCollection<T> collection)
7981
{
82+
_outputHelper.WriteLine($"==={collection.CollectionNamespace.FullName}===");
83+
foreach (var item in collection.AsQueryable())
84+
{
85+
_outputHelper.WriteLine(item.ToString());
86+
}
87+
8088
collection.DeleteMany("{ }");
8189

8290
if (collection.Find("{ }").CountDocuments() > 0)
8391
{
8492
throw new Exception("Failed to delete documents");
8593
}
94+
_outputHelper.WriteLine($"Data removed from the collection {collection.CollectionNamespace.FullName}.");
8695
}
8796

8897
public async Task<string> InjectAcrRequest()
@@ -108,6 +117,7 @@ public async Task<string> InjectAcrRequest()
108117

109118
await _infereRequestCollection.InsertOneAsync(request).ConfigureAwait(false);
110119
_outputHelper.WriteLine($"Injected ACR request {request.TransactionId}");
120+
Console.WriteLine($"Injected ACR request {request.TransactionId}");
111121
return request.TransactionId;
112122
}
113123
}

tests/Integration.Test/Hooks/TestHooks.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -185,6 +185,7 @@ public static void Shtudown()
185185
s_rabbitMqConnectionFactory.Dispose();
186186
}
187187

188+
188189
[AfterTestRun(Order = 0)]
189190
[AfterScenario]
190191
public static void ClearTestData(ISpecFlowOutputHelper outputHelper)

0 commit comments

Comments
 (0)