2023-10-09 14:59:52 +00:00
|
|
|
using CodexTests;
|
2023-04-26 12:59:26 +00:00
|
|
|
using DistTestCore;
|
2023-09-11 08:43:27 +00:00
|
|
|
using FileUtils;
|
2023-04-26 12:59:26 +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-26 12:59:26 +00:00
|
|
|
{
|
|
|
|
[TestFixture]
|
2023-09-20 08:59:52 +00:00
|
|
|
public class DownloadTests : CodexDistTest
|
2023-04-26 12:59:26 +00:00
|
|
|
{
|
2023-05-01 09:14:42 +00:00
|
|
|
[TestCase(3, 500)]
|
|
|
|
[TestCase(5, 100)]
|
2023-04-28 05:22:17 +00:00
|
|
|
[TestCase(10, 256)]
|
2023-04-27 13:55:33 +00:00
|
|
|
[UseLongTimeouts]
|
|
|
|
public void ParallelDownload(int numberOfNodes, int filesizeMb)
|
2023-04-26 12:59:26 +00:00
|
|
|
{
|
2023-09-20 08:59:52 +00:00
|
|
|
var group = AddCodex(numberOfNodes);
|
|
|
|
var host = AddCodex();
|
2023-04-26 12:59:26 +00:00
|
|
|
|
|
|
|
foreach (var node in group)
|
|
|
|
{
|
|
|
|
host.ConnectToPeer(node);
|
|
|
|
}
|
|
|
|
|
2023-04-27 13:55:33 +00:00
|
|
|
var testFile = GenerateTestFile(filesizeMb.MB());
|
2023-04-26 12:59:26 +00:00
|
|
|
var contentId = host.UploadFile(testFile);
|
2023-09-20 08:59:52 +00:00
|
|
|
var list = new List<Task<TrackedFile?>>();
|
2023-06-01 10:27:54 +00:00
|
|
|
|
2023-04-26 12:59:26 +00:00
|
|
|
foreach (var node in group)
|
|
|
|
{
|
|
|
|
list.Add(Task.Run(() => { return node.DownloadContent(contentId); }));
|
|
|
|
}
|
|
|
|
|
|
|
|
Task.WaitAll(list.ToArray());
|
|
|
|
foreach (var task in list)
|
|
|
|
{
|
|
|
|
testFile.AssertIsEqual(task.Result);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2023-05-04 09:34:43 +00:00
|
|
|
}
|