2024-11-21 09:46:11 +00:00
|
|
|
|
using CodexPlugin;
|
|
|
|
|
using CodexTests;
|
|
|
|
|
using NUnit.Framework;
|
|
|
|
|
using System;
|
2024-11-21 09:03:09 +00:00
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
using System.Text;
|
|
|
|
|
using System.Threading.Tasks;
|
2024-11-21 09:46:11 +00:00
|
|
|
|
using Utils;
|
2024-11-21 09:03:09 +00:00
|
|
|
|
|
|
|
|
|
namespace CodexReleaseTests.DataTests
|
|
|
|
|
{
|
2024-11-21 09:46:11 +00:00
|
|
|
|
[TestFixture]
|
|
|
|
|
public class TwoClientTests : CodexDistTest
|
2024-11-21 09:03:09 +00:00
|
|
|
|
{
|
2024-11-21 09:46:11 +00:00
|
|
|
|
[Test]
|
|
|
|
|
public void TwoClientTest()
|
|
|
|
|
{
|
|
|
|
|
var uploader = StartCodex(s => s.WithName("Uploader"));
|
|
|
|
|
var downloader = StartCodex(s => s.WithName("Downloader").WithBootstrapNode(uploader));
|
|
|
|
|
|
|
|
|
|
PerformTwoClientTest(uploader, downloader);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
|
public void TwoClientsTwoLocationsTest()
|
|
|
|
|
{
|
|
|
|
|
var locations = Ci.GetKnownLocations();
|
|
|
|
|
if (locations.NumberOfLocations < 2)
|
|
|
|
|
{
|
|
|
|
|
Assert.Inconclusive("Two-locations test requires 2 nodes to be available in the cluster.");
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
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)));
|
|
|
|
|
|
|
|
|
|
PerformTwoClientTest(uploader, downloader);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void PerformTwoClientTest(ICodexNode uploader, ICodexNode downloader)
|
|
|
|
|
{
|
|
|
|
|
PerformTwoClientTest(uploader, downloader, 10.MB());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void PerformTwoClientTest(ICodexNode uploader, ICodexNode downloader, ByteSize size)
|
|
|
|
|
{
|
|
|
|
|
var testFile = GenerateTestFile(size);
|
|
|
|
|
|
|
|
|
|
var contentId = uploader.UploadFile(testFile);
|
|
|
|
|
AssertNodesContainFile(contentId, uploader);
|
|
|
|
|
|
|
|
|
|
var downloadedFile = downloader.DownloadContent(contentId);
|
|
|
|
|
AssertNodesContainFile(contentId, uploader, downloader);
|
|
|
|
|
|
|
|
|
|
testFile.AssertIsEqual(downloadedFile);
|
|
|
|
|
CheckLogForErrors(uploader, downloader);
|
|
|
|
|
}
|
2024-11-21 09:03:09 +00:00
|
|
|
|
}
|
|
|
|
|
}
|