Sets up transient node test

This commit is contained in:
benbierens 2023-06-28 12:01:20 +02:00
parent 9a3f45e60d
commit 11269d1c21
No known key found for this signature in database
GPG Key ID: FE44815D96D0A1AA
4 changed files with 60 additions and 8 deletions

View File

@ -1,7 +1,6 @@
using DistTestCore; using DistTestCore;
using DistTestCore.Codex; using DistTestCore.Codex;
using Logging; using Logging;
using Utils;
namespace ContinuousTests namespace ContinuousTests
{ {
@ -31,7 +30,7 @@ namespace ContinuousTests
if (nodes != null) if (nodes != null)
{ {
NodeRunner = new NodeRunner(Nodes.ToList().PickOneRandom(), configuration, TimeSet, Log, CustomK8sNamespace, EthereumAccountIndex); NodeRunner = new NodeRunner(Nodes, configuration, TimeSet, Log, CustomK8sNamespace, EthereumAccountIndex);
} }
else else
{ {

View File

@ -28,7 +28,7 @@ namespace ContinuousTests
{ {
overviewLog.Log("Launching test-loop for " + t.Name); overviewLog.Log("Launching test-loop for " + t.Name);
t.Begin(); t.Begin();
Thread.Sleep(TimeSpan.FromMinutes(5)); Thread.Sleep(TimeSpan.FromSeconds(15));
} }
overviewLog.Log("All test-loops launched."); overviewLog.Log("All test-loops launched.");

View File

@ -4,21 +4,22 @@ using DistTestCore;
using KubernetesWorkflow; using KubernetesWorkflow;
using NUnit.Framework; using NUnit.Framework;
using Logging; using Logging;
using Utils;
namespace ContinuousTests namespace ContinuousTests
{ {
public class NodeRunner public class NodeRunner
{ {
private readonly CodexNode bootstrapNode; private readonly CodexNode[] nodes;
private readonly Configuration config; private readonly Configuration config;
private readonly ITimeSet timeSet; private readonly ITimeSet timeSet;
private readonly BaseLog log; private readonly BaseLog log;
private readonly string customNamespace; private readonly string customNamespace;
private readonly int ethereumAccountIndex; private readonly int ethereumAccountIndex;
public NodeRunner(CodexNode bootstrapNode, Configuration config, ITimeSet timeSet, BaseLog log, string customNamespace, int ethereumAccountIndex) public NodeRunner(CodexNode[] nodes, Configuration config, ITimeSet timeSet, BaseLog log, string customNamespace, int ethereumAccountIndex)
{ {
this.bootstrapNode = bootstrapNode; this.nodes = nodes;
this.config = config; this.config = config;
this.timeSet = timeSet; this.timeSet = timeSet;
this.log = log; this.log = log;
@ -28,10 +29,15 @@ namespace ContinuousTests
public void RunNode(Action<CodexAccess, MarketplaceAccess> operation) public void RunNode(Action<CodexAccess, MarketplaceAccess> operation)
{ {
RunNode(operation, 0.TestTokens()); RunNode(nodes.ToList().PickOneRandom(), operation, 0.TestTokens());
} }
public void RunNode(Action<CodexAccess, MarketplaceAccess> operation, TestToken mintTestTokens) public void RunNode(CodexNode bootstrapNode, Action<CodexAccess, MarketplaceAccess> operation)
{
RunNode(bootstrapNode, operation, 0.TestTokens());
}
public void RunNode(CodexNode bootstrapNode, Action<CodexAccess, MarketplaceAccess> operation, TestToken mintTestTokens)
{ {
var (workflowCreator, lifecycle) = CreateFacilities(); var (workflowCreator, lifecycle) = CreateFacilities();
var flow = workflowCreator.CreateWorkflow(); var flow = workflowCreator.CreateWorkflow();

View File

@ -0,0 +1,47 @@
using DistTestCore;
using DistTestCore.Codex;
using NUnit.Framework;
namespace ContinuousTests.Tests
{
public class TransientNodeTest : ContinuousTest
{
public override int RequiredNumberOfNodes => 3;
public override TimeSpan RunTestEvery => TimeSpan.FromMinutes(10);
public override TestFailMode TestFailMode => TestFailMode.StopAfterFirstFailure;
public override string CustomK8sNamespace => nameof(TransientNodeTest).ToLowerInvariant();
public override int EthereumAccountIndex => 201;
private TestFile file = null!;
private ContentId cid = null!;
private CodexNode UploadBootstapNode { get { return Nodes[0]; } }
private CodexNode DownloadBootstapNode { get { return Nodes[1]; } }
private CodexNode IntermediateNode { get { return Nodes[2]; } }
[TestMoment(t: 0)]
public void UploadWithTransientNode()
{
file = FileManager.GenerateTestFile(10.MB());
NodeRunner.RunNode(UploadBootstapNode, (codexAccess, marketplaceAccess) =>
{
cid = UploadFile(codexAccess.Node, file)!;
Assert.That(cid, Is.Not.Null);
var resultFile = DownloadContent(IntermediateNode, cid);
file.AssertIsEqual(resultFile);
});
}
[TestMoment(t: MinuteFive)]
public void DownloadWithTransientNode()
{
NodeRunner.RunNode(DownloadBootstapNode, (codexAccess, marketplaceAccess) =>
{
var resultFile = DownloadContent(codexAccess.Node, cid);
file.AssertIsEqual(resultFile);
});
}
}
}