2023-09-20 08:59:52 +00:00
|
|
|
using CodexPlugin;
|
2023-10-09 14:59:52 +00:00
|
|
|
using CodexTests;
|
2023-04-20 13:58:47 +00:00
|
|
|
using DistTestCore;
|
2023-09-11 08:43:27 +00:00
|
|
|
using FileUtils;
|
2023-04-19 10:34:46 +00:00
|
|
|
using NUnit.Framework;
|
2023-09-08 08:21:40 +00:00
|
|
|
using Utils;
|
2023-04-27 13:55:33 +00:00
|
|
|
|
2023-09-20 08:59:52 +00:00
|
|
|
namespace CodexLongTests.BasicTests
|
2023-04-19 10:34:46 +00:00
|
|
|
{
|
|
|
|
[TestFixture]
|
2023-09-20 08:59:52 +00:00
|
|
|
public class UploadTests : CodexDistTest
|
2023-04-19 10:34:46 +00:00
|
|
|
{
|
2023-04-27 13:55:33 +00:00
|
|
|
[TestCase(3, 50)]
|
2023-04-28 05:22:17 +00:00
|
|
|
[TestCase(5, 75)]
|
2023-04-27 13:55:33 +00:00
|
|
|
[TestCase(10, 25)]
|
|
|
|
[UseLongTimeouts]
|
|
|
|
public void ParallelUpload(int numberOfNodes, int filesizeMb)
|
2023-04-20 10:43:25 +00:00
|
|
|
{
|
2023-09-20 08:59:52 +00:00
|
|
|
var group = AddCodex(numberOfNodes);
|
|
|
|
var host = AddCodex();
|
2023-04-20 10:43:25 +00:00
|
|
|
|
2023-04-25 11:43:51 +00:00
|
|
|
foreach (var node in group)
|
2023-04-20 10:43:25 +00:00
|
|
|
{
|
2023-04-25 11:43:51 +00:00
|
|
|
host.ConnectToPeer(node);
|
2023-04-20 10:43:25 +00:00
|
|
|
}
|
2023-04-25 11:43:51 +00:00
|
|
|
|
2023-09-20 08:59:52 +00:00
|
|
|
var testfiles = new List<TrackedFile>();
|
2023-04-25 11:43:51 +00:00
|
|
|
var contentIds = new List<Task<ContentId>>();
|
|
|
|
|
|
|
|
for (int i = 0; i < group.Count(); i++)
|
2023-04-20 10:43:25 +00:00
|
|
|
{
|
2023-04-27 13:55:33 +00:00
|
|
|
testfiles.Add(GenerateTestFile(filesizeMb.MB()));
|
2023-04-25 11:43:51 +00:00
|
|
|
var n = i;
|
|
|
|
contentIds.Add(Task.Run(() => { return host.UploadFile(testfiles[n]); }));
|
2023-04-20 10:43:25 +00:00
|
|
|
}
|
2023-09-20 08:59:52 +00:00
|
|
|
var downloads = new List<Task<TrackedFile?>>();
|
2023-04-25 11:43:51 +00:00
|
|
|
for (int i = 0; i < group.Count(); i++)
|
2023-04-20 10:43:25 +00:00
|
|
|
{
|
2023-04-25 11:43:51 +00: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 10:43:25 +00:00
|
|
|
}
|
2023-04-19 10:34:46 +00:00
|
|
|
}
|
|
|
|
}
|
2023-05-04 09:34:43 +00:00
|
|
|
}
|