Performance tests

This commit is contained in:
benbierens 2023-06-21 11:45:45 +02:00
parent ae5309c2b6
commit 8d2d2d6197
No known key found for this signature in database
GPG Key ID: FE44815D96D0A1AA
4 changed files with 91 additions and 2 deletions

View File

@ -12,7 +12,15 @@ namespace ContinuousTests
public void Run()
{
var config = configLoader.Load();
var config = //configLoader.Load();
new Configuration
{
CodexUrls =new[] { "http://localhost:8080", "http://localhost:8081" },
LogPath = "logs",
KeepPassedTestLogs = false,
SleepSecondsPerAllTests = 1,
SleepSecondsPerSingleTest = 1,
};
StartupChecks(config);
while (true)

View File

@ -38,6 +38,7 @@ namespace ContinuousTests
private CodexNode[] CreateRandomNodes(int number, BaseLog testLog)
{
var urls = SelectRandomUrls(number);
testLog.Log("Selected nodes: " + string.Join(",", urls));
return codexNodeFactory.Create(urls, testLog, test.TimeSet);
}

View File

@ -0,0 +1,80 @@
using DistTestCore;
using DistTestCore.Codex;
using NUnit.Framework;
namespace ContinuousTests.Tests
{
public class UploadPerformanceTest : PerformanceTest
{
public override int RequiredNumberOfNodes => 1;
public override void Run()
{
UploadTest(100, Nodes[0]);
}
}
public class DownloadLocalPerformanceTest : PerformanceTest
{
public override int RequiredNumberOfNodes => 1;
public override void Run()
{
DownloadTest(100, Nodes[0], Nodes[0]);
}
}
public class DownloadRemotePerformanceTest : PerformanceTest
{
public override int RequiredNumberOfNodes => 2;
public override void Run()
{
DownloadTest(100, Nodes[0], Nodes[1]);
}
}
public abstract class PerformanceTest : ContinuousTest
{
public void UploadTest(int megabytes, CodexNode uploadNode)
{
var file = FileManager.GenerateTestFile(megabytes.MB());
var time = Measure(() =>
{
UploadFile(uploadNode, file);
});
var timePerMB = time / megabytes;
Assert.That(timePerMB, Is.LessThan(CodexContainerRecipe.MaxUploadTimePerMegabyte), "MaxUploadTimePerMegabyte performance threshold breached.");
}
public void DownloadTest(int megabytes, CodexNode uploadNode, CodexNode downloadNode)
{
var file = FileManager.GenerateTestFile(megabytes.MB());
var cid = UploadFile(uploadNode, file);
Assert.That(cid, Is.Not.Null);
TestFile? result = null;
var time = Measure(() =>
{
result = DownloadContent(downloadNode, cid!);
});
file.AssertIsEqual(result);
var timePerMB = time / megabytes;
Assert.That(timePerMB, Is.LessThan(CodexContainerRecipe.MaxDownloadTimePerMegabyte), "MaxDownloadTimePerMegabyte performance threshold breached.");
}
private static TimeSpan Measure(Action action)
{
var start = DateTime.UtcNow;
action();
return DateTime.UtcNow - start;
}
}
}

View File

@ -16,7 +16,7 @@ namespace ContinuousTests.Tests
var dl = DownloadContent(Nodes[1], cid!);
dl.AssertIsEqual(file);
file.AssertIsEqual(dl);
}
}
}