2023-09-12 15:43:30 +02:00
|
|
|
|
using CodexPlugin;
|
|
|
|
|
using DistTestCore;
|
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
|
|
|
|
|
2023-10-09 16:59:52 +02:00
|
|
|
|
namespace CodexTests.BasicTests
|
2023-04-14 14:53:39 +02:00
|
|
|
|
{
|
|
|
|
|
[TestFixture]
|
|
|
|
|
public class TwoClientTests : DistTest
|
|
|
|
|
{
|
2023-05-05 08:35:13 +02:00
|
|
|
|
[Test]
|
2023-08-28 11:16:58 +02:00
|
|
|
|
public void TwoClientTest()
|
2023-04-14 14:53:39 +02:00
|
|
|
|
{
|
2023-09-20 12:02:32 +02:00
|
|
|
|
var group = Ci.StartCodexNodes(2);
|
2023-04-14 14:53:39 +02:00
|
|
|
|
|
|
|
|
|
var primary = group[0];
|
|
|
|
|
var secondary = group[1];
|
|
|
|
|
|
2023-05-05 08:35:13 +02:00
|
|
|
|
PerformTwoClientTest(primary, secondary);
|
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;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var primary = Ci.StartCodexNode(s => s.At(locations.Get(0)));
|
|
|
|
|
var secondary = Ci.StartCodexNode(s => s.At(locations.Get(1)));
|
2023-04-14 14:53:39 +02:00
|
|
|
|
|
|
|
|
|
PerformTwoClientTest(primary, secondary);
|
|
|
|
|
}
|
|
|
|
|
|
2023-09-19 11:51:59 +02:00
|
|
|
|
private void PerformTwoClientTest(ICodexNode primary, ICodexNode secondary)
|
2023-05-04 08:25:48 +02:00
|
|
|
|
{
|
|
|
|
|
PerformTwoClientTest(primary, secondary, 1.MB());
|
|
|
|
|
}
|
|
|
|
|
|
2023-09-19 11:51:59 +02:00
|
|
|
|
private void PerformTwoClientTest(ICodexNode primary, ICodexNode secondary, ByteSize size)
|
2023-04-14 14:53:39 +02:00
|
|
|
|
{
|
|
|
|
|
primary.ConnectToPeer(secondary);
|
|
|
|
|
|
2023-05-04 08:25:48 +02:00
|
|
|
|
var testFile = GenerateTestFile(size);
|
2023-04-14 14:53:39 +02:00
|
|
|
|
|
|
|
|
|
var contentId = primary.UploadFile(testFile);
|
|
|
|
|
|
|
|
|
|
var downloadedFile = secondary.DownloadContent(contentId);
|
|
|
|
|
|
|
|
|
|
testFile.AssertIsEqual(downloadedFile);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|