2
0
mirror of synced 2025-01-13 01:54:07 +00:00

46 lines
1.4 KiB
C#
Raw Normal View History

2023-04-20 15:58:47 +02:00
using DistTestCore;
2023-04-19 12:34:46 +02:00
using NUnit.Framework;
2023-06-01 12:27:54 +02:00
namespace TestsLong.BasicTests
2023-04-19 12:34:46 +02:00
{
[TestFixture]
public class UploadTests : DistTest
{
[TestCase(3, 50)]
2023-04-28 07:22:17 +02:00
[TestCase(5, 75)]
[TestCase(10, 25)]
[UseLongTimeouts]
public void ParallelUpload(int numberOfNodes, int filesizeMb)
2023-04-20 12:43:25 +02:00
{
2023-04-26 15:32:27 +02:00
var group = SetupCodexNodes(numberOfNodes);
var host = SetupCodexNode();
2023-04-20 12:43:25 +02:00
2023-04-25 13:43:51 +02:00
foreach (var node in group)
2023-04-20 12:43:25 +02:00
{
2023-04-25 13:43:51 +02:00
host.ConnectToPeer(node);
2023-04-20 12:43:25 +02:00
}
2023-04-25 13:43:51 +02:00
2023-04-20 12:43:25 +02:00
var testfiles = new List<TestFile>();
2023-04-25 13:43:51 +02:00
var contentIds = new List<Task<ContentId>>();
for (int i = 0; i < group.Count(); i++)
2023-04-20 12:43:25 +02:00
{
testfiles.Add(GenerateTestFile(filesizeMb.MB()));
2023-04-25 13:43:51 +02:00
var n = i;
contentIds.Add(Task.Run(() => { return host.UploadFile(testfiles[n]); }));
2023-04-20 12:43:25 +02:00
}
2023-04-25 13:43:51 +02:00
var downloads = new List<Task<TestFile?>>();
for (int i = 0; i < group.Count(); i++)
2023-04-20 12:43:25 +02:00
{
2023-04-25 13:43:51 +02:00
var n = i;
downloads.Add(Task.Run(() => { return group[n].DownloadContent(contentIds[n].Result); }));
}
Task.WaitAll(downloads.ToArray());
for (int i = 0; i < group.Count(); i++)
{
testfiles[i].AssertIsEqual(downloads[i].Result);
2023-04-20 12:43:25 +02:00
}
2023-04-19 12:34:46 +02:00
}
}
}