2
0
mirror of synced 2025-02-01 19:26:30 +00:00

53 lines
1.6 KiB
C#
Raw Normal View History

2024-03-15 13:50:39 +01:00
using CodexPlugin;
2023-04-14 14:53:39 +02:00
using NUnit.Framework;
2023-09-08 10:21:40 +02:00
using Utils;
2023-04-14 14:53:39 +02:00
namespace CodexTests.BasicTests
2023-04-14 14:53:39 +02:00
{
[TestFixture]
public class TwoClientTests : CodexDistTest
2023-04-14 14:53:39 +02:00
{
2024-03-14 14:30:00 +01: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 14:53:39 +02:00
}
[Test]
public void TwoClientsTwoLocationsTest()
{
2023-09-25 08:47:19 +02: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 13:50:39 +01: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 14:53:39 +02:00
2024-03-14 14:30:00 +01:00
PerformTwoClientTest(uploader, downloader);
2023-04-14 14:53:39 +02:00
}
2024-03-14 14:30:00 +01:00
private void PerformTwoClientTest(ICodexNode uploader, ICodexNode downloader)
2023-05-04 08:25:48 +02:00
{
2024-03-14 14:30:00 +01:00
PerformTwoClientTest(uploader, downloader, 10.MB());
2023-05-04 08:25:48 +02:00
}
2024-03-14 14:30:00 +01:00
private void PerformTwoClientTest(ICodexNode uploader, ICodexNode downloader, ByteSize size)
2023-04-14 14:53:39 +02:00
{
2023-05-04 08:25:48 +02:00
var testFile = GenerateTestFile(size);
2023-04-14 14:53:39 +02:00
2024-03-14 14:30:00 +01:00
var contentId = uploader.UploadFile(testFile);
2023-04-14 14:53:39 +02:00
2024-03-14 14:30:00 +01:00
var downloadedFile = downloader.DownloadContent(contentId);
2023-04-14 14:53:39 +02:00
testFile.AssertIsEqual(downloadedFile);
2024-03-14 14:30:00 +01:00
CheckLogForErrors(uploader, downloader);
2023-04-14 14:53:39 +02:00
}
}
}