Restores full-connectivity tests.

This commit is contained in:
benbierens 2023-09-13 14:24:43 +02:00
parent 84dd514517
commit ec5aebb47b
No known key found for this signature in database
GPG Key ID: FE44815D96D0A1AA
8 changed files with 80 additions and 57 deletions

View File

@ -110,7 +110,7 @@ namespace DistTestCore
/// </summary>
public void ScopedTestFiles(Action action)
{
Get().ScopedTestFiles(action);
Get().GetFileManager().ScopedFiles(action);
}
//public IOnlineCodexNode SetupCodexBootstrapNode()
@ -183,16 +183,6 @@ namespace DistTestCore
GetTestLog().Debug(msg);
}
//public PeerConnectionTestHelpers CreatePeerConnectionTestHelpers()
//{
// return new PeerConnectionTestHelpers(GetTestLog());
//}
//public PeerDownloadTestHelpers CreatePeerDownloadTestHelpers()
//{
// return new PeerDownloadTestHelpers(GetTestLog(), Get().FileManager);
//}
public void Measure(string name, Action action)
{
Stopwatch.Measure(Get().Log, name, action);
@ -203,7 +193,7 @@ namespace DistTestCore
// return new CodexSetup(numberOfNodes, configuration.GetCodexLogLevel());
//}
private TestLifecycle Get()
protected TestLifecycle Get()
{
lock (lifecycleLock)
{

View File

@ -40,9 +40,9 @@ namespace DistTestCore
return entryPoint.Tools.GetFileManager().GenerateFile(size, label);
}
public void ScopedTestFiles(Action action)
public IFileManager GetFileManager()
{
entryPoint.Tools.GetFileManager().ScopedFiles(action);
return entryPoint.Tools.GetFileManager();
}
//public IDownloadedLog DownloadLog(RunningContainer container, int? tailLines = null)

View File

@ -1,45 +1,26 @@
using CodexPlugin;
using DistTestCore;
using DistTestCore.Helpers;
using NUnit.Framework;
namespace Tests
{
public class AutoBootstrapDistTest : DistTest
public class AutoBootstrapDistTest : CodexDistTest
{
public IOnlineCodexNode AddCodex()
{
return AddCodex(s => { });
}
public IOnlineCodexNode AddCodex(Action<ICodexSetup> setup)
{
return Ci.SetupCodexNode(s =>
{
setup(s);
s.WithBootstrapNode(BootstrapNode);
});
}
public ICodexNodeGroup AddCodex(int numberOfNodes)
{
return Ci.SetupCodexNodes(numberOfNodes, s => s.WithBootstrapNode(BootstrapNode));
}
public ICodexNodeGroup AddCodex(int numberOfNodes, Action<ICodexSetup> setup)
{
return Ci.SetupCodexNodes(numberOfNodes, s =>
{
setup(s);
s.WithBootstrapNode(BootstrapNode);
});
}
private readonly List<IOnlineCodexNode> onlineCodexNodes = new List<IOnlineCodexNode>();
[SetUp]
public void SetUpBootstrapNode()
{
BootstrapNode = Ci.SetupCodexNode(s => s.WithName("BOOTSTRAP"));
BootstrapNode = AddCodex(s => s.WithName("BOOTSTRAP"));
onlineCodexNodes.Add(BootstrapNode);
}
protected IOnlineCodexNode BootstrapNode { get; private set; } = null!;
protected override void OnCodexSetup(ICodexSetup setup)
{
if (BootstrapNode != null) setup.WithBootstrapNode(BootstrapNode);
}
protected IOnlineCodexNode? BootstrapNode { get; private set; }
}
}

56
Tests/CodexDistTest.cs Normal file
View File

@ -0,0 +1,56 @@
using CodexPlugin;
using DistTestCore;
using DistTestCore.Helpers;
namespace Tests
{
public class CodexDistTest : DistTest
{
private readonly List<IOnlineCodexNode> onlineCodexNodes = new List<IOnlineCodexNode>();
public IOnlineCodexNode AddCodex()
{
return AddCodex(s => { });
}
public IOnlineCodexNode AddCodex(Action<ICodexSetup> setup)
{
return AddCodex(1, setup)[0];
}
public ICodexNodeGroup AddCodex(int numberOfNodes)
{
return AddCodex(numberOfNodes, s => { });
}
public ICodexNodeGroup AddCodex(int numberOfNodes, Action<ICodexSetup> setup)
{
var group = Ci.SetupCodexNodes(numberOfNodes, s =>
{
setup(s);
OnCodexSetup(s);
});
onlineCodexNodes.AddRange(group);
return group;
}
public PeerConnectionTestHelpers CreatePeerConnectionTestHelpers()
{
return new PeerConnectionTestHelpers(GetTestLog());
}
public PeerDownloadTestHelpers CreatePeerDownloadTestHelpers()
{
return new PeerDownloadTestHelpers(GetTestLog(), Get().GetFileManager());
}
public IEnumerable<IOnlineCodexNode> GetAllOnlineCodexNodes()
{
return onlineCodexNodes;
}
protected virtual void OnCodexSetup(ICodexSetup setup)
{
}
}
}

View File

@ -1,6 +1,4 @@
using CodexPlugin;
using DistTestCore;
using NUnit.Framework;
using NUnit.Framework;
using Utils;
namespace Tests.DownloadConnectivityTests
@ -11,7 +9,7 @@ namespace Tests.DownloadConnectivityTests
[Test]
public void MetricsDoesNotInterfereWithPeerDownload()
{
//AddCodex(2, s => s.EnableMetrics());
AddCodex(2, s => s.EnableMetrics());
AssertAllNodesConnected();
}
@ -37,7 +35,7 @@ namespace Tests.DownloadConnectivityTests
private void AssertAllNodesConnected(int sizeMBs = 10)
{
//CreatePeerDownloadTestHelpers().AssertFullDownloadInterconnectivity(GetAllOnlineCodexNodes(), sizeMBs.MB());
CreatePeerDownloadTestHelpers().AssertFullDownloadInterconnectivity(GetAllOnlineCodexNodes(), sizeMBs.MB());
}
}
}

View File

@ -10,10 +10,10 @@ namespace DistTestCore.Helpers
{
private readonly FullConnectivityHelper helper;
private readonly ILog log;
private readonly FileManager fileManager;
private readonly IFileManager fileManager;
private ByteSize testFileSize;
public PeerDownloadTestHelpers(ILog log, FileManager fileManager)
public PeerDownloadTestHelpers(ILog log, IFileManager fileManager)
{
helper = new FullConnectivityHelper(log, this);
testFileSize = 1.MB();

View File

@ -1,11 +1,10 @@
using CodexPlugin;
using DistTestCore;
using NUnit.Framework;
namespace Tests.PeerDiscoveryTests
{
[TestFixture]
public class LayeredDiscoveryTests : DistTest
public class LayeredDiscoveryTests : CodexDistTest
{
[Test]
public void TwoLayersTest()
@ -47,7 +46,7 @@ namespace Tests.PeerDiscoveryTests
private void AssertAllNodesConnected()
{
//CreatePeerConnectionTestHelpers().AssertFullyConnected(GetAllOnlineCodexNodes());
CreatePeerConnectionTestHelpers().AssertFullyConnected(GetAllOnlineCodexNodes());
}
}
}

View File

@ -1,5 +1,4 @@
using DistTestCore;
using NUnit.Framework;
using NUnit.Framework;
namespace Tests.PeerDiscoveryTests
{
@ -45,7 +44,7 @@ namespace Tests.PeerDiscoveryTests
private void AssertAllNodesConnected()
{
//CreatePeerConnectionTestHelpers().AssertFullyConnected(GetAllOnlineCodexNodes());
CreatePeerConnectionTestHelpers().AssertFullyConnected(GetAllOnlineCodexNodes());
}
}
}