cs-codex-dist-tests/Tests/CodexTests/BasicTests/TwoClientTests.cs

53 lines
1.6 KiB
C#
Raw Normal View History

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
namespace CodexTests.BasicTests
2023-04-14 12:53:39 +00:00
{
[TestFixture]
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
}
}
}