2023-04-20 13:58:47 +00:00
|
|
|
using DistTestCore;
|
|
|
|
using KubernetesWorkflow;
|
2023-04-19 10:34:46 +00:00
|
|
|
using NUnit.Framework;
|
|
|
|
namespace Tests.ParallelTests
|
|
|
|
{
|
|
|
|
[TestFixture]
|
|
|
|
public class DownloadTests : DistTest
|
|
|
|
{
|
|
|
|
[Test]
|
|
|
|
public void TwoNodeDownloads()
|
|
|
|
{
|
2023-04-20 12:16:04 +00:00
|
|
|
ParallelDownload(3, 64.MB());
|
2023-04-19 10:34:46 +00:00
|
|
|
}
|
|
|
|
[Test]
|
2023-04-20 12:16:04 +00:00
|
|
|
public void FourNodeDownloads()
|
2023-04-19 10:34:46 +00:00
|
|
|
{
|
|
|
|
ParallelDownload(5, 1000.MB());
|
|
|
|
}
|
|
|
|
[Test]
|
2023-04-20 12:16:04 +00:00
|
|
|
public void NineNodeDownloads()
|
2023-04-19 10:34:46 +00:00
|
|
|
{
|
|
|
|
ParallelDownload(10, 16.MB());
|
|
|
|
}
|
2023-04-20 13:58:47 +00:00
|
|
|
public void download(ContentId contentId, IOnlineCodexNode node, TestFile testFile)
|
2023-04-19 10:34:46 +00:00
|
|
|
{
|
|
|
|
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++)
|
|
|
|
{
|
2023-04-20 12:16:04 +00:00
|
|
|
// new Task(() => { download(contentId, group[i], testFile); }).Start();
|
|
|
|
download(contentId, group[i], testFile);
|
2023-04-19 10:34:46 +00:00
|
|
|
}
|
2023-04-20 12:16:04 +00:00
|
|
|
// Task.WaitAll();
|
2023-04-19 10:34:46 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
[TestFixture]
|
|
|
|
public class UploadTests : DistTest
|
|
|
|
{
|
|
|
|
[Test]
|
2023-04-20 12:16:04 +00:00
|
|
|
public void ThreeNodeUploads()
|
2023-04-19 10:34:46 +00:00
|
|
|
{
|
2023-04-20 12:16:04 +00:00
|
|
|
ParallelUpload(3, 64.MB());
|
2023-04-19 10:34:46 +00:00
|
|
|
}
|
2023-04-20 10:43:25 +00:00
|
|
|
[Test]
|
2023-04-19 10:34:46 +00:00
|
|
|
public void FiveNodeUploads()
|
|
|
|
{
|
2023-04-20 10:43:25 +00:00
|
|
|
ParallelUpload(5, 1000.MB());
|
2023-04-19 10:34:46 +00:00
|
|
|
}
|
2023-04-20 10:43:25 +00:00
|
|
|
[Test]
|
2023-04-19 10:34:46 +00:00
|
|
|
public void TenNodeUploads()
|
|
|
|
{
|
2023-04-20 10:43:25 +00:00
|
|
|
ParallelUpload(10, 16.MB());
|
|
|
|
}
|
|
|
|
void ParallelUpload(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 testfiles = new List<TestFile>();
|
|
|
|
var contentIds = new List<ContentId>();
|
|
|
|
for (int i = 1; i < numberOfNodes; i++)
|
|
|
|
{
|
|
|
|
testfiles.Add(GenerateTestFile(filesize));
|
2023-04-20 12:16:04 +00:00
|
|
|
// new Task(() => { upload(host, testfiles[i - 1], contentIds, i - 1); }).Start();
|
|
|
|
upload(host, testfiles[i - 1], contentIds, i - 1);
|
2023-04-20 10:43:25 +00:00
|
|
|
}
|
2023-04-20 12:16:04 +00:00
|
|
|
// Task.WaitAll();
|
2023-04-20 10:43:25 +00:00
|
|
|
for (int i = 0; i < testfiles.Count; i++)
|
|
|
|
{
|
2023-04-20 12:16:04 +00:00
|
|
|
// new Task(() => { download(contentIds[i], group[i + 1], testfiles[i]); }).Start();
|
|
|
|
download(contentIds[i], group[i + 1], testfiles[i]);
|
2023-04-20 10:43:25 +00:00
|
|
|
}
|
2023-04-20 12:16:04 +00:00
|
|
|
// Task.WaitAll();
|
2023-04-20 10:43:25 +00:00
|
|
|
}
|
|
|
|
|
2023-04-20 13:58:47 +00:00
|
|
|
void download(ContentId contentId, IOnlineCodexNode node, TestFile testFile)
|
2023-04-20 10:43:25 +00:00
|
|
|
{
|
|
|
|
var downloadedFile = node.DownloadContent(contentId);
|
|
|
|
testFile.AssertIsEqual(downloadedFile);
|
|
|
|
}
|
2023-04-20 13:58:47 +00:00
|
|
|
void upload(IOnlineCodexNode host, TestFile testfile, List<ContentId> contentIds, int pos)
|
2023-04-20 10:43:25 +00:00
|
|
|
{
|
|
|
|
contentIds[pos] = host.UploadFile(testfile);
|
2023-04-19 10:34:46 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
[TestFixture]
|
|
|
|
public class MixedTests : DistTest
|
|
|
|
{
|
|
|
|
[Test]
|
|
|
|
public void OneDownloadOneUpload()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
public void ThreeDownloadTwoUpload()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
public void FiveDownloadFiveUpload()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|