Performance tests
This commit is contained in:
parent
ae5309c2b6
commit
8d2d2d6197
@ -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)
|
||||
|
@ -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);
|
||||
}
|
||||
|
||||
|
80
ContinuousTests/Tests/PerformanceTests.cs
Normal file
80
ContinuousTests/Tests/PerformanceTests.cs
Normal 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;
|
||||
}
|
||||
}
|
||||
}
|
@ -16,7 +16,7 @@ namespace ContinuousTests.Tests
|
||||
|
||||
var dl = DownloadContent(Nodes[1], cid!);
|
||||
|
||||
dl.AssertIsEqual(file);
|
||||
file.AssertIsEqual(dl);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user