2023-04-17 05:56:08 +00:00
|
|
|
|
using DistTestCore;
|
2023-06-07 06:30:10 +00:00
|
|
|
|
using DistTestCore.Codex;
|
2023-03-21 12:20:21 +00:00
|
|
|
|
using NUnit.Framework;
|
|
|
|
|
|
2023-04-12 11:53:55 +00:00
|
|
|
|
namespace TestsLong.BasicTests
|
2023-03-21 12:20:21 +00:00
|
|
|
|
{
|
|
|
|
|
[TestFixture]
|
2023-03-23 11:35:03 +00:00
|
|
|
|
public class LargeFileTests : DistTest
|
2023-03-21 12:20:21 +00:00
|
|
|
|
{
|
2023-06-07 06:30:10 +00:00
|
|
|
|
[Test]
|
|
|
|
|
[Combinatorial]
|
|
|
|
|
[UseLongTimeouts]
|
|
|
|
|
public void DownloadCorrectnessTest(
|
|
|
|
|
[Values(1, 10, 100, 1024)] int sizeInMB,
|
|
|
|
|
[Values(1, 10, 100, 1024)] int multiplier)
|
2023-03-21 12:20:21 +00:00
|
|
|
|
{
|
2023-06-07 07:32:56 +00:00
|
|
|
|
long size = (sizeInMB * multiplier);
|
|
|
|
|
var sizeMB = size.MB();
|
2023-03-21 12:20:21 +00:00
|
|
|
|
|
2023-06-07 07:32:56 +00:00
|
|
|
|
var expectedFile = GenerateTestFile(sizeMB);
|
2023-03-21 12:20:21 +00:00
|
|
|
|
|
2023-06-07 07:32:56 +00:00
|
|
|
|
var node = SetupCodexNode(s => s.WithStorageQuota((size + 10).MB()));
|
2023-03-21 12:20:21 +00:00
|
|
|
|
|
2023-06-07 06:30:10 +00:00
|
|
|
|
var uploadStart = DateTime.UtcNow;
|
|
|
|
|
var cid = node.UploadFile(expectedFile);
|
|
|
|
|
var downloadStart = DateTime.UtcNow;
|
|
|
|
|
var actualFile = node.DownloadContent(cid);
|
|
|
|
|
var downloadFinished = DateTime.UtcNow;
|
|
|
|
|
|
|
|
|
|
expectedFile.AssertIsEqual(actualFile);
|
|
|
|
|
AssertTimeConstraint(uploadStart, downloadStart, downloadFinished, size);
|
|
|
|
|
}
|
|
|
|
|
|
2023-06-07 07:32:56 +00:00
|
|
|
|
private void AssertTimeConstraint(DateTime uploadStart, DateTime downloadStart, DateTime downloadFinished, long size)
|
2023-06-07 06:30:10 +00:00
|
|
|
|
{
|
2023-06-07 07:32:56 +00:00
|
|
|
|
float sizeInMB = size;
|
2023-06-07 06:30:10 +00:00
|
|
|
|
var uploadTimePerMB = (uploadStart - downloadStart) / sizeInMB;
|
|
|
|
|
var downloadTimePerMB = (downloadStart - downloadFinished) / sizeInMB;
|
|
|
|
|
|
|
|
|
|
Assert.That(uploadTimePerMB, Is.LessThan(CodexContainerRecipe.MaxUploadTimePerMegabyte),
|
|
|
|
|
"MaxUploadTimePerMegabyte performance threshold breached.");
|
|
|
|
|
|
|
|
|
|
Assert.That(downloadTimePerMB, Is.LessThan(CodexContainerRecipe.MaxDownloadTimePerMegabyte),
|
|
|
|
|
"MaxDownloadTimePerMegabyte performance threshold breached.");
|
2023-03-21 12:20:21 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|