From 18e59f34902928e7e6aaa2d194f5187ae10b9556 Mon Sep 17 00:00:00 2001 From: Corbo12 Date: Wed, 19 Apr 2023 12:34:46 +0200 Subject: [PATCH] ADD Parallel download Tests --- .gitignore | 1 + Tests/BasicTests/ParallelTests.cs | 84 +++++++++++++++++++++++++++++++ 2 files changed, 85 insertions(+) create mode 100644 Tests/BasicTests/ParallelTests.cs diff --git a/.gitignore b/.gitignore index 63bc327..c134fee 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ .vs obj bin +.vscode \ No newline at end of file diff --git a/Tests/BasicTests/ParallelTests.cs b/Tests/BasicTests/ParallelTests.cs new file mode 100644 index 0000000..e0f48de --- /dev/null +++ b/Tests/BasicTests/ParallelTests.cs @@ -0,0 +1,84 @@ +using CodexDistTestCore; +using CodexDistTestCore.Config; +using NUnit.Framework; + +namespace Tests.ParallelTests +{ + [TestFixture] + public class DownloadTests : DistTest + { + [Test] + public void TwoNodeDownloads() + { + ParallelDownload(2, 64.MB()); + } + [Test] + public void FiveNodeDownloads() + { + ParallelDownload(5, 1000.MB()); + } + [Test] + public void TenNodeDownloads() + { + ParallelDownload(10, 16.MB()); + } + public void download(ContentId contentId, CodexDistTestCore.IOnlineCodexNode node, TestFile testFile) + { + var downloadedFile = node.DownloadContent(contentId); + testFile.AssertIsEqual(downloadedFile); + } + + void ParallelDownload(int numberOfNodes, ByteSize filesize) + { + var group = SetupCodexNodes(numberOfNodes).EnableMetrics().BringOnline(); + + var host = group[0]; + + for (int i = 1; i < numberOfNodes; i++) + { + host.ConnectToPeer(group[i]); + } + + var testFile = GenerateTestFile(filesize); + + var contentId = host.UploadFile(testFile); + + for (int i = 1; i < numberOfNodes; i++) + { + new Task(() => { download(contentId, group[i], testFile); }).Start(); + } + Task.WaitAll(); + } + } + + [TestFixture] + public class UploadTests : DistTest + { + [Test] + public void TwoNodeUploads() + { + } + + public void FiveNodeUploads() + { + } + public void TenNodeUploads() + { + } + } + [TestFixture] + public class MixedTests : DistTest + { + [Test] + public void OneDownloadOneUpload() + { + } + + public void ThreeDownloadTwoUpload() + { + } + public void FiveDownloadFiveUpload() + { + } + } +} \ No newline at end of file