MDF split tests into different files

This commit is contained in:
Corbo12 2023-04-26 14:59:26 +02:00
parent 5d5b08e084
commit aed3edaf6a
2 changed files with 51 additions and 61 deletions

View File

@ -0,0 +1,51 @@
using DistTestCore;
using KubernetesWorkflow;
using NUnit.Framework;
namespace Tests.ParallelTests
{
[TestFixture]
public class DownloadTests : DistTest
{
[Test]
public void ThreeNodeDownloads()
{
ParallelDownload(3, 5000.MB());
}
[Test]
public void FiveNodeDownloads()
{
ParallelDownload(5, 1000.MB());
}
[Test]
public void TenNodeDownloads()
{
ParallelDownload(10, 256.MB());
}
void ParallelDownload(int numberOfNodes, ByteSize filesize)
{
var group = SetupCodexNodes(numberOfNodes).BringOnline();
var host = SetupCodexNodes(1).BringOnline()[0];
foreach (var node in group)
{
host.ConnectToPeer(node);
}
var testFile = GenerateTestFile(filesize);
var contentId = host.UploadFile(testFile);
var list = new List<Task<TestFile?>>();
foreach (var node in group)
{
list.Add(Task.Run(() => { return node.DownloadContent(contentId); }));
}
Task.WaitAll(list.ToArray());
foreach (var task in list)
{
testFile.AssertIsEqual(task.Result);
}
}
}
}

View File

@ -3,52 +3,6 @@ using KubernetesWorkflow;
using NUnit.Framework;
namespace Tests.ParallelTests
{
[TestFixture]
public class DownloadTests : DistTest
{
[Test]
public void ThreeNodeDownloads()
{
ParallelDownload(3, 5000.MB());
}
[Test]
public void FiveNodeDownloads()
{
ParallelDownload(5, 1000.MB());
}
[Test]
public void TenNodeDownloads()
{
ParallelDownload(10, 256.MB());
}
void ParallelDownload(int numberOfNodes, ByteSize filesize)
{
var group = SetupCodexNodes(numberOfNodes).BringOnline();
var host = SetupCodexNodes(1).BringOnline()[0];
foreach (var node in group)
{
host.ConnectToPeer(node);
}
var testFile = GenerateTestFile(filesize);
var contentId = host.UploadFile(testFile);
var list = new List<Task<TestFile?>>();
foreach (var node in group)
{
list.Add(Task.Run(() => { return node.DownloadContent(contentId); }));
}
Task.WaitAll(list.ToArray());
foreach (var task in list)
{
testFile.AssertIsEqual(task.Result);
}
}
}
[TestFixture]
public class UploadTests : DistTest
{
@ -99,19 +53,4 @@ namespace Tests.ParallelTests
}
}
}
[TestFixture]
public class MixedTests : DistTest
{
[Test]
public void OneDownloadOneUpload()
{
}
public void ThreeDownloadTwoUpload()
{
}
public void FiveDownloadFiveUpload()
{
}
}
}