2024-05-07 08:15:02 +00:00
|
|
|
using CodexPlugin;
|
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]
|
2024-05-07 08:15:02 +00:00
|
|
|
public class DownloadTests : AutoBootstrapDistTest
|
2023-04-26 12:59:26 +00:00
|
|
|
{
|
2024-05-07 08:15:02 +00:00
|
|
|
[Test]
|
|
|
|
[Combinatorial]
|
2023-04-27 13:55:33 +00:00
|
|
|
[UseLongTimeouts]
|
2024-05-07 08:15:02 +00:00
|
|
|
public void ParallelDownload(
|
|
|
|
[Values(1, 3, 5)] int numberOfFiles,
|
|
|
|
[Values(10, 50, 100)] int filesizeMb)
|
2023-04-26 12:59:26 +00:00
|
|
|
{
|
2023-09-20 08:59:52 +00:00
|
|
|
var host = AddCodex();
|
2024-05-07 08:15:02 +00:00
|
|
|
var client = AddCodex();
|
2023-04-26 12:59:26 +00:00
|
|
|
|
2024-05-07 08:15:02 +00:00
|
|
|
var testfiles = new List<TrackedFile>();
|
|
|
|
var contentIds = new List<ContentId>();
|
|
|
|
var downloadedFiles = new List<TrackedFile?>();
|
|
|
|
|
|
|
|
for (int i = 0; i < numberOfFiles; i++)
|
2023-04-26 12:59:26 +00:00
|
|
|
{
|
2024-05-07 08:15:02 +00:00
|
|
|
testfiles.Add(GenerateTestFile(filesizeMb.MB()));
|
|
|
|
contentIds.Add(new ContentId());
|
|
|
|
downloadedFiles.Add(null);
|
2023-04-26 12:59:26 +00:00
|
|
|
}
|
|
|
|
|
2024-05-07 08:15:02 +00:00
|
|
|
for (int i = 0; i < numberOfFiles; i++)
|
|
|
|
{
|
|
|
|
contentIds[i] = host.UploadFile(testfiles[i]);
|
|
|
|
}
|
2023-06-01 10:27:54 +00:00
|
|
|
|
2024-05-07 08:15:02 +00:00
|
|
|
var downloadTasks = new List<Task>();
|
|
|
|
for (int i = 0; i < numberOfFiles; i++)
|
2023-04-26 12:59:26 +00:00
|
|
|
{
|
2024-05-07 08:15:02 +00:00
|
|
|
downloadTasks.Add(Task.Run(() => { downloadedFiles[i] = client.DownloadContent(contentIds[i]); }));
|
2023-04-26 12:59:26 +00:00
|
|
|
}
|
|
|
|
|
2024-05-07 08:15:02 +00:00
|
|
|
Task.WaitAll(downloadTasks.ToArray());
|
|
|
|
|
|
|
|
for (int i = 0; i < numberOfFiles; i++)
|
2023-04-26 12:59:26 +00:00
|
|
|
{
|
2024-05-07 08:15:02 +00:00
|
|
|
testfiles[i].AssertIsEqual(downloadedFiles[i]);
|
2023-04-26 12:59:26 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2023-05-04 09:34:43 +00:00
|
|
|
}
|