2023-09-12 13:43:30 +00:00
|
|
|
|
using CodexPlugin;
|
2024-09-24 08:10:59 +00:00
|
|
|
|
using DistTestCore;
|
2023-09-12 13:43:30 +00:00
|
|
|
|
using NUnit.Framework;
|
|
|
|
|
|
2023-10-09 14:59:52 +00:00
|
|
|
|
namespace CodexTests
|
2023-09-12 13:43:30 +00:00
|
|
|
|
{
|
2023-09-13 12:24:43 +00:00
|
|
|
|
public class AutoBootstrapDistTest : CodexDistTest
|
2023-09-12 13:43:30 +00:00
|
|
|
|
{
|
2024-09-24 08:10:59 +00:00
|
|
|
|
private readonly Dictionary<TestLifecycle, ICodexNode> bootstrapNodes = new Dictionary<TestLifecycle, ICodexNode>();
|
|
|
|
|
|
2023-09-13 12:24:43 +00:00
|
|
|
|
[SetUp]
|
|
|
|
|
public void SetUpBootstrapNode()
|
2023-09-12 13:43:30 +00:00
|
|
|
|
{
|
2024-09-24 08:10:59 +00:00
|
|
|
|
var tl = Get();
|
|
|
|
|
if (!bootstrapNodes.ContainsKey(tl))
|
|
|
|
|
{
|
|
|
|
|
bootstrapNodes.Add(tl, StartCodex(s => s.WithName("BOOTSTRAP_" + tl.TestNamespace)));
|
|
|
|
|
}
|
2023-09-12 13:43:30 +00:00
|
|
|
|
}
|
|
|
|
|
|
2023-09-28 12:23:48 +00:00
|
|
|
|
[TearDown]
|
|
|
|
|
public void TearDownBootstrapNode()
|
|
|
|
|
{
|
2024-09-24 08:10:59 +00:00
|
|
|
|
bootstrapNodes.Remove(Get());
|
2023-09-28 12:23:48 +00:00
|
|
|
|
}
|
|
|
|
|
|
2023-09-13 12:24:43 +00:00
|
|
|
|
protected override void OnCodexSetup(ICodexSetup setup)
|
2023-09-12 13:43:30 +00:00
|
|
|
|
{
|
2024-09-24 08:10:59 +00:00
|
|
|
|
var node = BootstrapNode;
|
|
|
|
|
if (node != null) setup.WithBootstrapNode(node);
|
2023-09-12 13:43:30 +00:00
|
|
|
|
}
|
|
|
|
|
|
2024-09-24 08:10:59 +00:00
|
|
|
|
protected ICodexNode? BootstrapNode
|
|
|
|
|
{
|
|
|
|
|
get
|
|
|
|
|
{
|
|
|
|
|
var tl = Get();
|
|
|
|
|
if (bootstrapNodes.TryGetValue(tl, out var node))
|
|
|
|
|
{
|
|
|
|
|
return node;
|
|
|
|
|
}
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
}
|
2023-09-12 13:43:30 +00:00
|
|
|
|
}
|
|
|
|
|
}
|