Skip to content

Commit 706e6fc

Browse files
committed
Cleanup minio after scenario
Signed-off-by: Victor Chang <[email protected]>
1 parent 9da286b commit 706e6fc

File tree

3 files changed

+32
-6
lines changed

3 files changed

+32
-6
lines changed

tests/Integration.Test/Common/MinioDataSink.cs

Lines changed: 29 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,10 +37,7 @@ public MinioDataClient(Configurations configurations, InformaticsGatewayConfigur
3737

3838
public async Task SendAsync(DataProvider dataProvider, params object[] args)
3939
{
40-
var minioClient = new MinioClient()
41-
.WithEndpoint(_options.Storage.Settings["endpoint"])
42-
.WithCredentials(_options.Storage.Settings["accessKey"], _options.Storage.Settings["accessToken"])
43-
.Build();
40+
var minioClient = CreateMinioClient();
4441

4542
var stopwatch = new Stopwatch();
4643
stopwatch.Start();
@@ -64,5 +61,33 @@ public async Task SendAsync(DataProvider dataProvider, params object[] args)
6461
stopwatch.Stop();
6562
_outputHelper.WriteLine($"Time to upload to Minio={0}s...", stopwatch.Elapsed.TotalSeconds);
6663
}
64+
65+
private MinioClient CreateMinioClient() => new MinioClient()
66+
.WithEndpoint(_options.Storage.Settings["endpoint"])
67+
.WithCredentials(_options.Storage.Settings["accessKey"], _options.Storage.Settings["accessToken"])
68+
.Build();
69+
70+
internal async Task CleanBucketAsync()
71+
{
72+
var stopwatch = new Stopwatch();
73+
stopwatch.Start();
74+
var minioClient = CreateMinioClient();
75+
var toBeRemoved = new List<string>();
76+
var listObjectArgs = new ListObjectsArgs()
77+
.WithBucket(_options.Storage.StorageServiceBucketName)
78+
.WithRecursive(true);
79+
var objects = minioClient.ListObjectsAsync(listObjectArgs);
80+
objects.Subscribe((item) =>
81+
{
82+
toBeRemoved.Add(item.Key);
83+
});
84+
var deletObjectsArgs = new RemoveObjectsArgs()
85+
.WithBucket(_options.Storage.StorageServiceBucketName)
86+
.WithObjects(toBeRemoved);
87+
await minioClient.RemoveObjectsAsync(deletObjectsArgs).ConfigureAwait(false);
88+
89+
stopwatch.Stop();
90+
_outputHelper.WriteLine($"Cleaned up {0} objects from Minio in {1}s...", toBeRemoved.Count, stopwatch.Elapsed.TotalSeconds);
91+
}
6792
}
6893
}

tests/Integration.Test/Hooks/TestHooks.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -179,6 +179,7 @@ public static void Shtudown()
179179
[AfterScenario]
180180
public static void ClearTestData()
181181
{
182+
s_minioSink.CleanBucketAsync();
182183
RabbitConnectionFactory.PurgeAllQueues(s_options.Value.Messaging);
183184
}
184185

tests/Integration.Test/study.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22
"MR": {
33
"SeriesMin": 1,
44
"SeriesMax": 2,
5-
"InstanceMin": 32,
6-
"InstanceMax": 64,
5+
"InstanceMin": 64,
6+
"InstanceMax": 128,
77
"SizeMin": 0.36,
88
"SizeMax": 2
99
},

0 commit comments

Comments
 (0)