2023-09-20 08:59:52 +00:00
|
|
|
|
using CodexPlugin;
|
2023-10-09 14:59:52 +00:00
|
|
|
|
using CodexTests;
|
2023-09-20 08:59:52 +00:00
|
|
|
|
using DistTestCore;
|
2023-03-21 12:20:21 +00:00
|
|
|
|
using NUnit.Framework;
|
2023-06-07 07:59:00 +00:00
|
|
|
|
using NUnit.Framework.Interfaces;
|
2023-09-08 08:21:40 +00:00
|
|
|
|
using Utils;
|
2023-03-21 12:20:21 +00:00
|
|
|
|
|
2023-09-20 08:59:52 +00:00
|
|
|
|
namespace CodexLongTests.BasicTests
|
2023-03-21 12:20:21 +00:00
|
|
|
|
{
|
|
|
|
|
[TestFixture]
|
2023-09-20 08:59:52 +00:00
|
|
|
|
public class LargeFileTests : CodexDistTest
|
2023-03-21 12:20:21 +00:00
|
|
|
|
{
|
2023-06-07 07:59:00 +00:00
|
|
|
|
#region Abort test run after first failure
|
|
|
|
|
|
|
|
|
|
private bool stop;
|
|
|
|
|
|
|
|
|
|
[SetUp]
|
|
|
|
|
public void SetUp()
|
|
|
|
|
{
|
|
|
|
|
if (stop)
|
|
|
|
|
{
|
|
|
|
|
Assert.Inconclusive("Previous test failed");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[TearDown]
|
|
|
|
|
public void TearDown()
|
|
|
|
|
{
|
|
|
|
|
if (TestContext.CurrentContext.Result.Outcome.Status == TestStatus.Failed)
|
|
|
|
|
{
|
|
|
|
|
stop = true;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
[TestCase( 1 * 1)] // 1 MB
|
|
|
|
|
[TestCase( 1 * 10)]
|
|
|
|
|
[TestCase( 1 * 100)]
|
|
|
|
|
[TestCase( 1 * 1024)] // 1 GB
|
|
|
|
|
[TestCase( 1024 * 10)]
|
|
|
|
|
[TestCase( 1024 * 100)]
|
|
|
|
|
[TestCase( 1024 * 1024)] // 1 TB :O
|
2023-06-07 06:30:10 +00:00
|
|
|
|
[UseLongTimeouts]
|
2023-06-07 07:59:00 +00:00
|
|
|
|
public void DownloadCorrectnessTest(long size)
|
2023-03-21 12:20:21 +00:00
|
|
|
|
{
|
2023-06-07 07:32:56 +00:00
|
|
|
|
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
|
|
|
|
|
2024-05-09 07:32:48 +00:00
|
|
|
|
var node = StartCodex(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
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|