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

41 lines
1.6 KiB
C#
Raw Normal View History

2023-04-14 07:54:07 +00:00
using KubernetesWorkflow;
namespace DistTestCore.Marketplace
{
2023-04-18 11:22:41 +00:00
public class GethBootstrapNodeStarter : BaseStarter
2023-04-14 07:54:07 +00:00
{
public GethBootstrapNodeStarter(TestLifecycle lifecycle, WorkflowCreator workflowCreator)
2023-04-18 11:22:41 +00:00
: base(lifecycle, workflowCreator)
2023-04-14 07:54:07 +00:00
{
}
public GethBootstrapNodeInfo StartGethBootstrapNode()
{
2023-04-18 11:22:41 +00:00
LogStart("Starting Geth bootstrap node...");
2023-04-14 07:54:07 +00:00
var startupConfig = CreateBootstrapStartupConfig();
var workflow = workflowCreator.CreateWorkflow();
var containers = workflow.Start(1, Location.Unspecified, new GethContainerRecipe(), startupConfig);
if (containers.Containers.Length != 1) throw new InvalidOperationException("Expected 1 Geth bootstrap node to be created. Test infra failure.");
var bootstrapContainer = containers.Containers[0];
2023-04-14 07:54:07 +00:00
2023-04-25 11:38:26 +00:00
var extractor = new ContainerInfoExtractor(lifecycle.Log, workflow, bootstrapContainer);
2023-05-03 08:21:15 +00:00
var accounts = extractor.ExtractAccounts();
var pubKey = extractor.ExtractPubKey();
var discoveryPort = bootstrapContainer.Recipe.GetPortByTag(GethContainerRecipe.DiscoveryPortTag);
2023-05-03 08:21:15 +00:00
var result = new GethBootstrapNodeInfo(containers, accounts, pubKey, discoveryPort);
2023-04-14 07:54:07 +00:00
2023-05-03 08:21:15 +00:00
LogEnd($"Geth bootstrap node started with account '{result.Account.Account}'");
2023-04-14 07:54:07 +00:00
2023-05-03 08:21:15 +00:00
return result;
2023-04-14 07:54:07 +00:00
}
private StartupConfig CreateBootstrapStartupConfig()
{
var config = new StartupConfig();
2023-05-03 08:21:15 +00:00
config.Add(new GethStartupConfig(true, null!, 0, 0));
2023-04-14 07:54:07 +00:00
return config;
}
}
}