diff --git a/ContinuousTests/ContinuousTestRunner.cs b/ContinuousTests/ContinuousTestRunner.cs index c829a1c3..cb6bc3fc 100644 --- a/ContinuousTests/ContinuousTestRunner.cs +++ b/ContinuousTests/ContinuousTestRunner.cs @@ -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) diff --git a/ContinuousTests/SingleTestRun.cs b/ContinuousTests/SingleTestRun.cs index e7c39a7e..978f4bdd 100644 --- a/ContinuousTests/SingleTestRun.cs +++ b/ContinuousTests/SingleTestRun.cs @@ -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); } diff --git a/ContinuousTests/Tests/PerformanceTests.cs b/ContinuousTests/Tests/PerformanceTests.cs new file mode 100644 index 00000000..f0ee853f --- /dev/null +++ b/ContinuousTests/Tests/PerformanceTests.cs @@ -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; + } + } +} diff --git a/ContinuousTests/Tests/TwoClientTest.cs b/ContinuousTests/Tests/TwoClientTest.cs index c38bc922..07fa8686 100644 --- a/ContinuousTests/Tests/TwoClientTest.cs +++ b/ContinuousTests/Tests/TwoClientTest.cs @@ -16,7 +16,7 @@ namespace ContinuousTests.Tests var dl = DownloadContent(Nodes[1], cid!); - dl.AssertIsEqual(file); + file.AssertIsEqual(dl); } } }