cs-codex-dist-tests/DistTestCore/Marketplace/GethCompanionNodeStarter.cs

42 lines
1.8 KiB
C#
Raw Normal View History

2023-04-14 07:54:07 +00:00
using KubernetesWorkflow;
namespace DistTestCore.Marketplace
{
2023-04-18 11:45:48 +00:00
public class GethCompanionNodeStarter : BaseStarter
2023-04-14 07:54:07 +00:00
{
public GethCompanionNodeStarter(TestLifecycle lifecycle, WorkflowCreator workflowCreator)
2023-04-18 11:45:48 +00:00
: base(lifecycle, workflowCreator)
2023-04-14 07:54:07 +00:00
{
}
public GethCompanionNodeInfo[] StartCompanionNodesFor(CodexSetup codexSetup, GethBootstrapNodeInfo bootstrapNode)
{
2023-04-18 11:45:48 +00:00
LogStart($"Initializing companions for {codexSetup.NumberOfNodes} Codex nodes.");
2023-04-14 07:54:07 +00:00
var startupConfig = CreateCompanionNodeStartupConfig(bootstrapNode);
var workflow = workflowCreator.CreateWorkflow();
var containers = workflow.Start(codexSetup.NumberOfNodes, Location.Unspecified, new GethContainerRecipe(), startupConfig);
if (containers.Containers.Length != codexSetup.NumberOfNodes) throw new InvalidOperationException("Expected a Geth companion node to be created for each Codex node. Test infra failure.");
2023-04-18 11:45:48 +00:00
LogEnd("Initialized companion nodes.");
2023-04-14 07:54:07 +00:00
return containers.Containers.Select(c => CreateCompanionInfo(workflow, c)).ToArray();
}
private GethCompanionNodeInfo CreateCompanionInfo(StartupWorkflow workflow, RunningContainer container)
{
var extractor = new ContainerInfoExtractor(workflow, container);
2023-04-14 07:54:07 +00:00
var account = extractor.ExtractAccount();
return new GethCompanionNodeInfo(container, account);
}
private StartupConfig CreateCompanionNodeStartupConfig(GethBootstrapNodeInfo bootstrapNode)
{
var config = new StartupConfig();
config.Add(new GethStartupConfig(false, bootstrapNode.GenesisJsonBase64, bootstrapNode));
2023-04-14 07:54:07 +00:00
return config;
}
}
}