2023-03-21 12:20:21 +00:00
|
|
|
|
using CodexDistTestCore;
|
2023-03-17 10:43:29 +00:00
|
|
|
|
using NUnit.Framework;
|
|
|
|
|
|
2023-03-21 12:20:21 +00:00
|
|
|
|
namespace Tests.BasicTests
|
2023-03-17 10:43:29 +00:00
|
|
|
|
{
|
|
|
|
|
[TestFixture]
|
2023-03-21 12:20:21 +00:00
|
|
|
|
public class SimpleTests : DistTest
|
2023-03-17 10:43:29 +00:00
|
|
|
|
{
|
|
|
|
|
[Test]
|
|
|
|
|
public void GetDebugInfo()
|
|
|
|
|
{
|
2023-03-21 07:30:40 +00:00
|
|
|
|
var dockerImage = new CodexDockerImage();
|
|
|
|
|
|
2023-03-21 14:17:48 +00:00
|
|
|
|
var node = SetupCodexNodes(1).BringOnline()[0];
|
2023-03-17 10:43:29 +00:00
|
|
|
|
|
|
|
|
|
var debugInfo = node.GetDebugInfo();
|
|
|
|
|
|
|
|
|
|
Assert.That(debugInfo.spr, Is.Not.Empty);
|
2023-03-21 07:30:40 +00:00
|
|
|
|
Assert.That(debugInfo.codex.revision, Is.EqualTo(dockerImage.GetExpectedImageRevision()));
|
2023-03-17 10:43:29 +00:00
|
|
|
|
}
|
2023-03-20 08:23:32 +00:00
|
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
|
public void OneClientTest()
|
|
|
|
|
{
|
2023-03-21 14:17:48 +00:00
|
|
|
|
var primary = SetupCodexNodes(1)
|
2023-03-22 10:27:51 +00:00
|
|
|
|
.WithLogLevel(CodexLogLevel.Trace)
|
|
|
|
|
.WithStorageQuota(2.MB())
|
|
|
|
|
.BringOnline()[0];
|
2023-03-20 08:23:32 +00:00
|
|
|
|
|
2023-03-21 08:20:09 +00:00
|
|
|
|
var testFile = GenerateTestFile(1.MB());
|
2023-03-20 08:23:32 +00:00
|
|
|
|
|
|
|
|
|
var contentId = primary.UploadFile(testFile);
|
|
|
|
|
|
|
|
|
|
var downloadedFile = primary.DownloadContent(contentId);
|
|
|
|
|
|
|
|
|
|
testFile.AssertIsEqual(downloadedFile);
|
|
|
|
|
}
|
|
|
|
|
|
2023-03-22 10:27:51 +00:00
|
|
|
|
[Test]
|
|
|
|
|
public void TwoClientOnePodTest()
|
|
|
|
|
{
|
|
|
|
|
var group = SetupCodexNodes(2)
|
|
|
|
|
.WithLogLevel(CodexLogLevel.Trace)
|
|
|
|
|
.WithStorageQuota(2.MB())
|
|
|
|
|
.BringOnline();
|
2023-03-19 09:49:03 +00:00
|
|
|
|
|
2023-03-22 10:27:51 +00:00
|
|
|
|
var primary = group[0];
|
|
|
|
|
var secondary = group[1];
|
2023-03-19 09:49:03 +00:00
|
|
|
|
|
2023-03-22 13:49:01 +00:00
|
|
|
|
PerformTwoClientTest(primary, secondary);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
|
public void TwoClientTwoPodTest()
|
|
|
|
|
{
|
|
|
|
|
var primary = SetupCodexNodes(1)
|
|
|
|
|
.WithStorageQuota(2.MB())
|
|
|
|
|
.BringOnline()[0];
|
|
|
|
|
|
|
|
|
|
var secondary = SetupCodexNodes(1)
|
|
|
|
|
.WithStorageQuota(2.MB())
|
|
|
|
|
.BringOnline()[0];
|
|
|
|
|
|
|
|
|
|
PerformTwoClientTest(primary, secondary);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void PerformTwoClientTest(IOnlineCodexNode primary, IOnlineCodexNode secondary)
|
|
|
|
|
{
|
2023-03-22 10:27:51 +00:00
|
|
|
|
primary.ConnectToPeer(secondary);
|
2023-03-19 09:49:03 +00:00
|
|
|
|
|
2023-03-22 10:27:51 +00:00
|
|
|
|
var testFile = GenerateTestFile(1.MB());
|
2023-03-19 09:49:03 +00:00
|
|
|
|
|
2023-03-22 10:27:51 +00:00
|
|
|
|
var contentId = primary.UploadFile(testFile);
|
2023-03-19 09:49:03 +00:00
|
|
|
|
|
2023-03-22 10:27:51 +00:00
|
|
|
|
var downloadedFile = secondary.DownloadContent(contentId);
|
|
|
|
|
|
|
|
|
|
testFile.AssertIsEqual(downloadedFile);
|
|
|
|
|
}
|
2023-03-17 10:43:29 +00:00
|
|
|
|
}
|
|
|
|
|
}
|