cs-codex-dist-tests/Tests/CodexLongTests/BasicTests/UploadTests.cs

48 lines
1.3 KiB
C#
Raw Normal View History

2023-09-20 08:59:52 +00:00
using CodexPlugin;
using CodexTests;
2023-04-20 13:58:47 +00:00
using DistTestCore;
using FileUtils;
2023-04-19 10:34:46 +00:00
using NUnit.Framework;
2023-09-08 08:21:40 +00:00
using Utils;
2023-09-20 08:59:52 +00:00
namespace CodexLongTests.BasicTests
2023-04-19 10:34:46 +00:00
{
[TestFixture]
2024-05-07 08:15:02 +00:00
public class UploadTests : AutoBootstrapDistTest
2023-04-19 10:34:46 +00:00
{
2024-05-07 08:15:02 +00:00
[Test]
[Combinatorial]
[UseLongTimeouts]
2024-05-07 08:15:02 +00:00
public void ParallelUpload(
[Values(1, 3, 5)] int numberOfFiles,
[Values(10, 50, 100)] int filesizeMb)
2023-04-20 10:43:25 +00:00
{
2024-05-09 07:32:48 +00:00
var host = StartCodex();
var client = StartCodex();
2023-04-25 11:43:51 +00:00
2023-09-20 08:59:52 +00:00
var testfiles = new List<TrackedFile>();
2024-05-07 08:15:02 +00:00
var contentIds = new List<ContentId>();
2023-04-25 11:43:51 +00:00
2024-05-07 08:15:02 +00:00
for (int i = 0; i < numberOfFiles; i++)
2023-04-20 10:43:25 +00:00
{
testfiles.Add(GenerateTestFile(filesizeMb.MB()));
2024-05-07 08:15:02 +00:00
contentIds.Add(new ContentId());
2023-04-20 10:43:25 +00:00
}
2024-05-07 08:15:02 +00:00
var uploadTasks = new List<Task>();
for (int i = 0; i < numberOfFiles; i++)
2023-04-20 10:43:25 +00:00
{
2024-05-07 08:15:02 +00:00
uploadTasks.Add(Task.Run(() => { contentIds[i] = host.UploadFile(testfiles[i]); }));
2023-04-25 11:43:51 +00:00
}
2024-05-07 08:15:02 +00:00
Task.WaitAll(uploadTasks.ToArray());
for (int i = 0; i < numberOfFiles; i++)
2023-04-25 11:43:51 +00:00
{
2024-05-07 08:15:02 +00:00
var downloaded = client.DownloadContent(contentIds[i]);
testfiles[i].AssertIsEqual(downloaded);
2023-04-20 10:43:25 +00:00
}
2023-04-19 10:34:46 +00:00
}
}
}