2024-03-15 12:50:39 +00:00
|
|
|
|
using CodexPlugin;
|
2023-04-14 12:53:39 +00:00
|
|
|
|
using NUnit.Framework;
|
2023-09-08 08:21:40 +00:00
|
|
|
|
using Utils;
|
2023-04-14 12:53:39 +00:00
|
|
|
|
|
2023-10-09 14:59:52 +00:00
|
|
|
|
namespace CodexTests.BasicTests
|
2023-04-14 12:53:39 +00:00
|
|
|
|
{
|
|
|
|
|
[TestFixture]
|
2023-12-12 13:18:26 +00:00
|
|
|
|
public class TwoClientTests : CodexDistTest
|
2023-04-14 12:53:39 +00:00
|
|
|
|
{
|
2024-03-14 13:30:00 +00:00
|
|
|
|
[Test]
|
|
|
|
|
public void TwoClientTest()
|
|
|
|
|
{
|
|
|
|
|
var uploader = AddCodex(s => s.WithName("Uploader"));
|
|
|
|
|
var downloader = AddCodex(s => s.WithName("Downloader").WithBootstrapNode(uploader));
|
|
|
|
|
|
|
|
|
|
PerformTwoClientTest(uploader, downloader);
|
2023-04-14 12:53:39 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
|
public void TwoClientsTwoLocationsTest()
|
|
|
|
|
{
|
2023-09-25 06:47:19 +00:00
|
|
|
|
var locations = Ci.GetKnownLocations();
|
|
|
|
|
if (locations.NumberOfLocations < 2)
|
|
|
|
|
{
|
|
|
|
|
Assert.Inconclusive("Two-locations test requires 2 nodes to be available in the cluster.");
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2024-03-15 12:50:39 +00:00
|
|
|
|
var uploader = Ci.StartCodexNode(s => s.WithName("Uploader").At(locations.Get(0)));
|
|
|
|
|
var downloader = Ci.StartCodexNode(s => s.WithName("Downloader").WithBootstrapNode(uploader).At(locations.Get(1)));
|
2023-04-14 12:53:39 +00:00
|
|
|
|
|
2024-03-14 13:30:00 +00:00
|
|
|
|
PerformTwoClientTest(uploader, downloader);
|
2023-04-14 12:53:39 +00:00
|
|
|
|
}
|
|
|
|
|
|
2024-03-14 13:30:00 +00:00
|
|
|
|
private void PerformTwoClientTest(ICodexNode uploader, ICodexNode downloader)
|
2023-05-04 06:25:48 +00:00
|
|
|
|
{
|
2024-03-14 13:30:00 +00:00
|
|
|
|
PerformTwoClientTest(uploader, downloader, 10.MB());
|
2023-05-04 06:25:48 +00:00
|
|
|
|
}
|
|
|
|
|
|
2024-03-14 13:30:00 +00:00
|
|
|
|
private void PerformTwoClientTest(ICodexNode uploader, ICodexNode downloader, ByteSize size)
|
2023-04-14 12:53:39 +00:00
|
|
|
|
{
|
2023-05-04 06:25:48 +00:00
|
|
|
|
var testFile = GenerateTestFile(size);
|
2023-04-14 12:53:39 +00:00
|
|
|
|
|
2024-03-14 13:30:00 +00:00
|
|
|
|
var contentId = uploader.UploadFile(testFile);
|
2023-04-14 12:53:39 +00:00
|
|
|
|
|
2024-03-14 13:30:00 +00:00
|
|
|
|
var downloadedFile = downloader.DownloadContent(contentId);
|
2023-04-14 12:53:39 +00:00
|
|
|
|
|
|
|
|
|
testFile.AssertIsEqual(downloadedFile);
|
2024-03-14 13:30:00 +00:00
|
|
|
|
CheckLogForErrors(uploader, downloader);
|
2023-04-14 12:53:39 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|