Restores CodexNetDeployer
This commit is contained in:
parent
bf4c8d8026
commit
75369d68f7
|
@ -1,22 +1,21 @@
|
|||
using KubernetesWorkflow;
|
||||
using GethPlugin;
|
||||
using KubernetesWorkflow;
|
||||
|
||||
namespace CodexPlugin
|
||||
{
|
||||
public class CodexDeployment
|
||||
{
|
||||
public CodexDeployment(/*GethStartResult gethStartResult,*/ RunningContainer[] codexContainers, RunningContainer? prometheusContainer, /*GrafanaStartInfo? grafanaStartInfo,*/ DeploymentMetadata metadata)
|
||||
public CodexDeployment(RunningContainer[] codexContainers, GethDeployment gethDeployment, RunningContainer? prometheusContainer, DeploymentMetadata metadata)
|
||||
{
|
||||
//GethStartResult = gethStartResult;
|
||||
CodexContainers = codexContainers;
|
||||
GethDeployment = gethDeployment;
|
||||
PrometheusContainer = prometheusContainer;
|
||||
//GrafanaStartInfo = grafanaStartInfo;
|
||||
Metadata = metadata;
|
||||
}
|
||||
|
||||
//public GethStartResult GethStartResult { get; }
|
||||
public RunningContainer[] CodexContainers { get; }
|
||||
public GethDeployment GethDeployment { get; }
|
||||
public RunningContainer? PrometheusContainer { get; }
|
||||
//public GrafanaStartInfo? GrafanaStartInfo { get; }
|
||||
public DeploymentMetadata Metadata { get; }
|
||||
}
|
||||
|
||||
|
|
|
@ -31,7 +31,7 @@ namespace CodexPlugin
|
|||
{
|
||||
}
|
||||
|
||||
public RunningContainers[] StartCodexNodes(int numberOfNodes, Action<ICodexSetup> setup)
|
||||
public RunningContainers[] DeployCodexNodes(int numberOfNodes, Action<ICodexSetup> setup)
|
||||
{
|
||||
var codexSetup = GetSetup(numberOfNodes, setup);
|
||||
return codexStarter.BringOnline(codexSetup);
|
||||
|
|
|
@ -5,9 +5,9 @@ namespace CodexPlugin
|
|||
{
|
||||
public static class CoreInterfaceExtensions
|
||||
{
|
||||
public static RunningContainers[] StartCodexNodes(this CoreInterface ci, int number, Action<ICodexSetup> setup)
|
||||
public static RunningContainers[] DeployCodexNodes(this CoreInterface ci, int number, Action<ICodexSetup> setup)
|
||||
{
|
||||
return Plugin(ci).StartCodexNodes(number, setup);
|
||||
return Plugin(ci).DeployCodexNodes(number, setup);
|
||||
}
|
||||
|
||||
public static ICodexNodeGroup WrapCodexContainers(this CoreInterface ci, RunningContainers[] containers)
|
||||
|
@ -15,27 +15,27 @@ namespace CodexPlugin
|
|||
return Plugin(ci).WrapCodexContainers(ci, containers);
|
||||
}
|
||||
|
||||
public static ICodexNode SetupCodexNode(this CoreInterface ci)
|
||||
public static ICodexNode StartCodexNode(this CoreInterface ci)
|
||||
{
|
||||
return ci.SetupCodexNodes(1)[0];
|
||||
return ci.StartCodexNodes(1)[0];
|
||||
}
|
||||
|
||||
public static ICodexNode SetupCodexNode(this CoreInterface ci, Action<ICodexSetup> setup)
|
||||
public static ICodexNode StartCodexNode(this CoreInterface ci, Action<ICodexSetup> setup)
|
||||
{
|
||||
return ci.SetupCodexNodes(1, setup)[0];
|
||||
return ci.StartCodexNodes(1, setup)[0];
|
||||
}
|
||||
|
||||
public static ICodexNodeGroup SetupCodexNodes(this CoreInterface ci, int number, Action<ICodexSetup> setup)
|
||||
public static ICodexNodeGroup StartCodexNodes(this CoreInterface ci, int number, Action<ICodexSetup> setup)
|
||||
{
|
||||
var rc = ci.StartCodexNodes(number, setup);
|
||||
var rc = ci.DeployCodexNodes(number, setup);
|
||||
var result = ci.WrapCodexContainers(rc);
|
||||
Plugin(ci).WireUpMarketplace(result, setup);
|
||||
return result;
|
||||
}
|
||||
|
||||
public static ICodexNodeGroup SetupCodexNodes(this CoreInterface ci, int number)
|
||||
public static ICodexNodeGroup StartCodexNodes(this CoreInterface ci, int number)
|
||||
{
|
||||
return ci.SetupCodexNodes(number, s => { });
|
||||
return ci.StartCodexNodes(number, s => { });
|
||||
}
|
||||
|
||||
private static CodexPlugin Plugin(CoreInterface ci)
|
||||
|
|
|
@ -8,7 +8,7 @@ namespace CodexPlugin
|
|||
{
|
||||
public interface IMarketplaceAccess
|
||||
{
|
||||
string MakeStorageAvailable(ByteSize size, TestToken minPricePerBytePerSecond, TestToken maxCollateral, TimeSpan maxDuration);
|
||||
string MakeStorageAvailable(ByteSize size, TestToken minPriceForTotalSpace, TestToken maxCollateral, TimeSpan maxDuration);
|
||||
StoragePurchaseContract RequestStorage(ContentId contentId, TestToken pricePerSlotPerSecond, TestToken requiredCollateral, uint minRequiredNumberOfNodes, int proofProbability, TimeSpan duration);
|
||||
}
|
||||
|
||||
|
|
|
@ -61,7 +61,7 @@ namespace Tests.BasicTests
|
|||
AssertBalance(geth, contracts, seller, Is.EqualTo(sellerInitialBalance));
|
||||
seller.Marketplace.MakeStorageAvailable(
|
||||
size: 10.GB(),
|
||||
minPricePerBytePerSecond: 1.TestTokens(),
|
||||
minPriceForTotalSpace: 1.TestTokens(),
|
||||
maxCollateral: 20.TestTokens(),
|
||||
maxDuration: TimeSpan.FromMinutes(3));
|
||||
|
||||
|
|
|
@ -17,7 +17,7 @@ namespace Tests.BasicTests
|
|||
[Test]
|
||||
public void SetUpANodeAndWait()
|
||||
{
|
||||
node = Ci.SetupCodexNode();
|
||||
node = Ci.StartCodexNode();
|
||||
|
||||
Time.WaitUntil(() => node == null, TimeSpan.FromMinutes(5), TimeSpan.FromSeconds(5));
|
||||
}
|
||||
|
@ -25,7 +25,7 @@ namespace Tests.BasicTests
|
|||
[Test]
|
||||
public void ForeignNodeConnects()
|
||||
{
|
||||
var myNode = Ci.SetupCodexNode();
|
||||
var myNode = Ci.StartCodexNode();
|
||||
|
||||
Time.WaitUntil(() => node != null, TimeSpan.FromMinutes(1), TimeSpan.FromSeconds(5));
|
||||
|
||||
|
|
|
@ -11,7 +11,7 @@ namespace Tests.BasicTests
|
|||
[Test]
|
||||
public void OneClientTest()
|
||||
{
|
||||
var primary = Ci.SetupCodexNode();
|
||||
var primary = Ci.StartCodexNode();
|
||||
|
||||
PerformOneClientTest(primary);
|
||||
}
|
||||
|
@ -19,11 +19,11 @@ namespace Tests.BasicTests
|
|||
[Test]
|
||||
public void RestartTest()
|
||||
{
|
||||
var primary = Ci.SetupCodexNode();
|
||||
var primary = Ci.StartCodexNode();
|
||||
|
||||
primary.Stop();
|
||||
|
||||
primary = Ci.SetupCodexNode();
|
||||
primary = Ci.StartCodexNode();
|
||||
|
||||
PerformOneClientTest(primary);
|
||||
}
|
||||
|
|
|
@ -12,7 +12,7 @@ namespace Tests.BasicTests
|
|||
[Test]
|
||||
public void TwoClientTest()
|
||||
{
|
||||
var group = Ci.SetupCodexNodes(2);
|
||||
var group = Ci.StartCodexNodes(2);
|
||||
|
||||
var primary = group[0];
|
||||
var secondary = group[1];
|
||||
|
@ -23,8 +23,8 @@ namespace Tests.BasicTests
|
|||
[Test]
|
||||
public void TwoClientsTwoLocationsTest()
|
||||
{
|
||||
var primary = Ci.SetupCodexNode(s => s.At(Location.One));
|
||||
var secondary = Ci.SetupCodexNode(s => s.At(Location.Two));
|
||||
var primary = Ci.StartCodexNode(s => s.At(Location.One));
|
||||
var secondary = Ci.StartCodexNode(s => s.At(Location.Two));
|
||||
|
||||
PerformTwoClientTest(primary, secondary);
|
||||
}
|
||||
|
|
|
@ -29,7 +29,7 @@ namespace Tests
|
|||
|
||||
public ICodexNodeGroup AddCodex(int numberOfNodes, Action<ICodexSetup> setup)
|
||||
{
|
||||
var group = Ci.SetupCodexNodes(numberOfNodes, s =>
|
||||
var group = Ci.StartCodexNodes(numberOfNodes, s =>
|
||||
{
|
||||
setup(s);
|
||||
OnCodexSetup(s);
|
||||
|
|
|
@ -9,10 +9,10 @@ namespace Tests.PeerDiscoveryTests
|
|||
[Test]
|
||||
public void TwoLayersTest()
|
||||
{
|
||||
var root = Ci.SetupCodexNode();
|
||||
var l1Source = Ci.SetupCodexNode(s => s.WithBootstrapNode(root));
|
||||
var l1Node = Ci.SetupCodexNode(s => s.WithBootstrapNode(root));
|
||||
var l2Target = Ci.SetupCodexNode(s => s.WithBootstrapNode(l1Node));
|
||||
var root = Ci.StartCodexNode();
|
||||
var l1Source = Ci.StartCodexNode(s => s.WithBootstrapNode(root));
|
||||
var l1Node = Ci.StartCodexNode(s => s.WithBootstrapNode(root));
|
||||
var l2Target = Ci.StartCodexNode(s => s.WithBootstrapNode(l1Node));
|
||||
|
||||
AssertAllNodesConnected();
|
||||
}
|
||||
|
@ -20,11 +20,11 @@ namespace Tests.PeerDiscoveryTests
|
|||
[Test]
|
||||
public void ThreeLayersTest()
|
||||
{
|
||||
var root = Ci.SetupCodexNode();
|
||||
var l1Source = Ci.SetupCodexNode(s => s.WithBootstrapNode(root));
|
||||
var l1Node = Ci.SetupCodexNode(s => s.WithBootstrapNode(root));
|
||||
var l2Node = Ci.SetupCodexNode(s => s.WithBootstrapNode(l1Node));
|
||||
var l3Target = Ci.SetupCodexNode(s => s.WithBootstrapNode(l2Node));
|
||||
var root = Ci.StartCodexNode();
|
||||
var l1Source = Ci.StartCodexNode(s => s.WithBootstrapNode(root));
|
||||
var l1Node = Ci.StartCodexNode(s => s.WithBootstrapNode(root));
|
||||
var l2Node = Ci.StartCodexNode(s => s.WithBootstrapNode(l1Node));
|
||||
var l3Target = Ci.StartCodexNode(s => s.WithBootstrapNode(l2Node));
|
||||
|
||||
AssertAllNodesConnected();
|
||||
}
|
||||
|
@ -35,10 +35,10 @@ namespace Tests.PeerDiscoveryTests
|
|||
[TestCase(20)]
|
||||
public void NodeChainTest(int chainLength)
|
||||
{
|
||||
var node = Ci.SetupCodexNode();
|
||||
var node = Ci.StartCodexNode();
|
||||
for (var i = 1; i < chainLength; i++)
|
||||
{
|
||||
node = Ci.SetupCodexNode(s => s.WithBootstrapNode(node));
|
||||
node = Ci.StartCodexNode(s => s.WithBootstrapNode(node));
|
||||
}
|
||||
|
||||
AssertAllNodesConnected();
|
||||
|
|
|
@ -8,8 +8,10 @@
|
|||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\ArgsUniform\ArgsUniform.csproj" />
|
||||
<ProjectReference Include="..\DistTestCore\DistTestCore.csproj" />
|
||||
<ProjectReference Include="..\..\Framework\ArgsUniform\ArgsUniform.csproj" />
|
||||
<ProjectReference Include="..\..\Framework\Core\Core.csproj" />
|
||||
<ProjectReference Include="..\..\ProjectPlugins\CodexPlugin\CodexPlugin.csproj" />
|
||||
<ProjectReference Include="..\..\Tests\CodexTests\CodexTests.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
using DistTestCore;
|
||||
using DistTestCore.Codex;
|
||||
using DistTestCore.Marketplace;
|
||||
using KubernetesWorkflow;
|
||||
using CodexContractsPlugin;
|
||||
using CodexPlugin;
|
||||
using Core;
|
||||
using GethPlugin;
|
||||
using Utils;
|
||||
|
||||
namespace CodexNetDeployer
|
||||
|
@ -9,49 +9,49 @@ namespace CodexNetDeployer
|
|||
public class CodexNodeStarter
|
||||
{
|
||||
private readonly Configuration config;
|
||||
private readonly TestLifecycle lifecycle;
|
||||
private readonly GethStartResult gethResult;
|
||||
private readonly CoreInterface ci;
|
||||
private readonly IGethNode gethNode;
|
||||
private readonly ICodexContracts contracts;
|
||||
private string bootstrapSpr = "";
|
||||
private int validatorsLeft;
|
||||
|
||||
public CodexNodeStarter(Configuration config, TestLifecycle lifecycle, GethStartResult gethResult, int numberOfValidators)
|
||||
public CodexNodeStarter(Configuration config, CoreInterface ci, IGethNode gethNode, ICodexContracts contracts, int numberOfValidators)
|
||||
{
|
||||
this.config = config;
|
||||
this.lifecycle = lifecycle;
|
||||
this.gethResult = gethResult;
|
||||
this.ci = ci;
|
||||
this.gethNode = gethNode;
|
||||
this.contracts = contracts;
|
||||
validatorsLeft = numberOfValidators;
|
||||
}
|
||||
|
||||
public CodexNodeStartResult? Start(int i)
|
||||
{
|
||||
Console.Write($" - {i} = ");
|
||||
var workflow = lifecycle.WorkflowCreator.CreateWorkflow();
|
||||
var workflowStartup = new StartupConfig();
|
||||
workflowStartup.Add(gethResult);
|
||||
workflowStartup.Add(CreateCodexStartupConfig(bootstrapSpr, i, validatorsLeft));
|
||||
workflowStartup.NameOverride = GetCodexContainerName(i);
|
||||
|
||||
var containers = workflow.Start(1, Location.Unspecified, new CodexContainerRecipe(), workflowStartup);
|
||||
|
||||
var container = containers.Containers.First();
|
||||
var codexAccess = new CodexAccess(lifecycle.Log, container, lifecycle.TimeSet, lifecycle.Configuration.GetAddress(container));
|
||||
var account = gethResult.MarketplaceNetwork.Bootstrap.AllAccounts.Accounts[i];
|
||||
var tokenAddress = gethResult.MarketplaceNetwork.Marketplace.TokenAddress;
|
||||
var marketAccess = new MarketplaceAccess(lifecycle, gethResult.MarketplaceNetwork, account, codexAccess);
|
||||
var name = GetCodexContainerName(i);
|
||||
Console.Write($" - {i} ({name}) = ");
|
||||
|
||||
ICodexNode? codexNode = null;
|
||||
try
|
||||
{
|
||||
var debugInfo = codexAccess.GetDebugInfo();
|
||||
codexNode = ci.StartCodexNode(s =>
|
||||
{
|
||||
s.WithName(name);
|
||||
s.WithLogLevel(config.CodexLogLevel);
|
||||
s.WithStorageQuota(config.StorageQuota!.Value.MB());
|
||||
s.EnableMarketplace(gethNode, contracts, 100.Eth(), config.InitialTestTokens.TestTokens(), validatorsLeft > 0);
|
||||
s.EnableMetrics();
|
||||
|
||||
if (config.BlockTTL != Configuration.SecondsIn1Day) s.WithBlockTTL(TimeSpan.FromSeconds(config.BlockTTL));
|
||||
if (config.BlockMI != Configuration.TenMinutes) s.WithBlockMaintenanceInterval(TimeSpan.FromSeconds(config.BlockMI));
|
||||
if (config.BlockMN != 1000) s.WithBlockMaintenanceNumber(config.BlockMN);
|
||||
});
|
||||
|
||||
var debugInfo = codexNode.GetDebugInfo();
|
||||
if (!string.IsNullOrWhiteSpace(debugInfo.spr))
|
||||
{
|
||||
Console.Write("Online\t");
|
||||
|
||||
var interaction = gethResult.MarketplaceNetwork.Bootstrap.StartInteraction(lifecycle);
|
||||
interaction.MintTestTokens(new[] { account.Account }, config.InitialTestTokens, tokenAddress);
|
||||
Console.Write("Tokens minted\t");
|
||||
|
||||
var response = marketAccess.MakeStorageAvailable(
|
||||
totalSpace: config.StorageSell!.Value.MB(),
|
||||
var response = codexNode.Marketplace.MakeStorageAvailable(
|
||||
size: config.StorageSell!.Value.MB(),
|
||||
minPriceForTotalSpace: config.MinPrice.TestTokens(),
|
||||
maxCollateral: config.MaxCollateral.TestTokens(),
|
||||
maxDuration: TimeSpan.FromSeconds(config.MaxDuration));
|
||||
|
@ -62,7 +62,7 @@ namespace CodexNetDeployer
|
|||
|
||||
if (string.IsNullOrEmpty(bootstrapSpr)) bootstrapSpr = debugInfo.spr;
|
||||
validatorsLeft--;
|
||||
return new CodexNodeStartResult(workflow, container, codexAccess);
|
||||
return new CodexNodeStartResult(codexNode);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -71,8 +71,12 @@ namespace CodexNetDeployer
|
|||
Console.WriteLine("Exception:" + ex.ToString());
|
||||
}
|
||||
|
||||
Console.Write("Unknown failure. Downloading container log." + Environment.NewLine);
|
||||
lifecycle.DownloadLog(container);
|
||||
Console.WriteLine("Unknown failure.");
|
||||
if (codexNode != null)
|
||||
{
|
||||
Console.WriteLine("Downloading container log.");
|
||||
ci.DownloadLog(codexNode);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
@ -82,46 +86,15 @@ namespace CodexNetDeployer
|
|||
if (i == 0) return "BOOTSTRAP";
|
||||
return "CODEX" + i;
|
||||
}
|
||||
|
||||
private CodexStartupConfig CreateCodexStartupConfig(string bootstrapSpr, int i, int validatorsLeft)
|
||||
{
|
||||
var codexStart = new CodexStartupConfig(config.CodexLogLevel);
|
||||
|
||||
if (!string.IsNullOrEmpty(bootstrapSpr)) codexStart.BootstrapSpr = bootstrapSpr;
|
||||
codexStart.StorageQuota = config.StorageQuota!.Value.MB();
|
||||
var marketplaceConfig = new MarketplaceInitialConfig(100000.Eth(), 0.TestTokens(), validatorsLeft > 0);
|
||||
marketplaceConfig.AccountIndexOverride = i;
|
||||
codexStart.MarketplaceConfig = marketplaceConfig;
|
||||
codexStart.MetricsMode = config.Metrics;
|
||||
|
||||
if (config.BlockTTL != Configuration.SecondsIn1Day)
|
||||
{
|
||||
codexStart.BlockTTL = config.BlockTTL;
|
||||
}
|
||||
if (config.BlockMI != Configuration.TenMinutes)
|
||||
{
|
||||
codexStart.BlockMaintenanceInterval = TimeSpan.FromSeconds(config.BlockMI);
|
||||
}
|
||||
if (config.BlockMN != 1000)
|
||||
{
|
||||
codexStart.BlockMaintenanceNumber = config.BlockMN;
|
||||
}
|
||||
|
||||
return codexStart;
|
||||
}
|
||||
}
|
||||
|
||||
public class CodexNodeStartResult
|
||||
{
|
||||
public CodexNodeStartResult(StartupWorkflow workflow, RunningContainer container, CodexAccess access)
|
||||
public CodexNodeStartResult(ICodexNode codexNode)
|
||||
{
|
||||
Workflow = workflow;
|
||||
Container = container;
|
||||
Access = access;
|
||||
CodexNode = codexNode;
|
||||
}
|
||||
|
||||
public StartupWorkflow Workflow { get; }
|
||||
public RunningContainer Container { get; }
|
||||
public CodexAccess Access { get; }
|
||||
public ICodexNode CodexNode { get; }
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
using ArgsUniform;
|
||||
using DistTestCore.Codex;
|
||||
using DistTestCore.Metrics;
|
||||
using CodexPlugin;
|
||||
|
||||
namespace CodexNetDeployer
|
||||
{
|
||||
|
@ -51,8 +50,8 @@ namespace CodexNetDeployer
|
|||
[Uniform("block-mn", "bmn", "BLOCKMN", false, "Number of blocks maintained per interval. Default is 1000 blocks.")]
|
||||
public int BlockMN { get; set; } = 1000;
|
||||
|
||||
[Uniform("metrics", "m", "METRICS", false, "[None*, Record, Dashboard]. Determines if metrics will be recorded and if a dashboard service will be created.")]
|
||||
public MetricsMode Metrics { get; set; } = MetricsMode.None;
|
||||
[Uniform("metrics", "m", "METRICS", false, "[true, false]. Determines if metrics will be recorded. Default is false.")]
|
||||
public bool Metrics { get; set; } = false;
|
||||
|
||||
[Uniform("teststype-podlabel", "ttpl", "TESTSTYPE-PODLABEL", false, "Each kubernetes pod will be created with a label 'teststype' with value 'continuous'. " +
|
||||
"set this option to override the label value.")]
|
||||
|
|
|
@ -1,51 +1,58 @@
|
|||
using DistTestCore;
|
||||
using DistTestCore.Codex;
|
||||
using CodexContractsPlugin;
|
||||
using CodexPlugin;
|
||||
using Core;
|
||||
using GethPlugin;
|
||||
using KubernetesWorkflow;
|
||||
using Logging;
|
||||
using Utils;
|
||||
using MetricsPlugin;
|
||||
|
||||
namespace CodexNetDeployer
|
||||
{
|
||||
public class Deployer
|
||||
{
|
||||
private readonly Configuration config;
|
||||
private readonly DefaultTimeSet timeset;
|
||||
private readonly PeerConnectivityChecker peerConnectivityChecker;
|
||||
private readonly EntryPoint entryPoint;
|
||||
|
||||
public Deployer(Configuration config)
|
||||
{
|
||||
this.config = config;
|
||||
timeset = new DefaultTimeSet();
|
||||
peerConnectivityChecker = new PeerConnectivityChecker();
|
||||
|
||||
entryPoint = CreateEntryPoint(new NullLog());
|
||||
}
|
||||
|
||||
public void AnnouncePlugins()
|
||||
{
|
||||
var ep = CreateEntryPoint(new ConsoleLog());
|
||||
|
||||
Log("Using plugins:" + Environment.NewLine);
|
||||
ep.Announce();
|
||||
Log("");
|
||||
var metadata = ep.GetPluginMetadata();
|
||||
foreach (var entry in metadata)
|
||||
{
|
||||
Log($"{entry.Key} = {entry.Value}");
|
||||
}
|
||||
Log("");
|
||||
}
|
||||
|
||||
public CodexDeployment Deploy()
|
||||
{
|
||||
Log("Initializing...");
|
||||
var lifecycle = CreateTestLifecycle();
|
||||
var ci = entryPoint.CreateInterface();
|
||||
|
||||
Log("Preparing configuration...");
|
||||
// We trick the Geth companion node into unlocking all of its accounts, by saying we want to start 999 codex nodes.
|
||||
var setup = new CodexSetup(999, config.CodexLogLevel);
|
||||
setup.WithStorageQuota(config.StorageQuota!.Value.MB()).EnableMarketplace(0.TestTokens());
|
||||
setup.MetricsMode = config.Metrics;
|
||||
Log("Deploying Geth instance...");
|
||||
var gethDeployment = ci.DeployGeth(s => s.IsMiner());
|
||||
var gethNode = ci.WrapGethDeployment(gethDeployment);
|
||||
|
||||
Log("Creating Geth instance and deploying contracts...");
|
||||
var gethStarter = new GethStarter(lifecycle);
|
||||
var gethResults = gethStarter.BringOnlineMarketplaceFor(setup);
|
||||
|
||||
Log("Geth started. Codex contracts deployed.");
|
||||
Log("Warning: It can take up to 45 minutes for the Geth node to finish unlocking all if its 1000 preconfigured accounts.");
|
||||
|
||||
// It takes a second for the geth node to unlock a single account. Let's assume 3.
|
||||
// We can't start the codex nodes until their accounts are definitely unlocked. So
|
||||
// We wait:
|
||||
Thread.Sleep(TimeSpan.FromSeconds(3.0 * config.NumberOfCodexNodes!.Value));
|
||||
Log("Geth started. Deploying Codex contracts...");
|
||||
var contractsDeployment = ci.DeployCodexContracts(gethNode);
|
||||
var contracts = ci.WrapCodexContractsDeployment(contractsDeployment);
|
||||
Log("Codex contracts deployed.");
|
||||
|
||||
Log("Starting Codex nodes...");
|
||||
|
||||
// Each node must have its own IP, so it needs it own pod. Start them 1 at a time.
|
||||
var codexStarter = new CodexNodeStarter(config, lifecycle, gethResults, config.NumberOfValidators!.Value);
|
||||
var codexStarter = new CodexNodeStarter(config, ci, gethNode, contracts, config.NumberOfValidators!.Value);
|
||||
var startResults = new List<CodexNodeStartResult>();
|
||||
for (var i = 0; i < config.NumberOfCodexNodes; i++)
|
||||
{
|
||||
|
@ -53,47 +60,40 @@ namespace CodexNetDeployer
|
|||
if (result != null) startResults.Add(result);
|
||||
}
|
||||
|
||||
var (prometheusContainer, grafanaStartInfo) = StartMetricsService(lifecycle, setup, startResults.Select(r => r.Container));
|
||||
Log("Codex nodes started.");
|
||||
var metricsService = StartMetricsService(ci, startResults);
|
||||
|
||||
CheckPeerConnectivity(startResults);
|
||||
CheckContainerRestarts(startResults);
|
||||
|
||||
return new CodexDeployment(gethResults, startResults.Select(r => r.Container).ToArray(), prometheusContainer, grafanaStartInfo, CreateMetadata());
|
||||
var codexContainers = startResults.Select(s => s.CodexNode.Container).ToArray();
|
||||
return new CodexDeployment(codexContainers, gethDeployment, metricsService, CreateMetadata());
|
||||
}
|
||||
|
||||
private TestLifecycle CreateTestLifecycle()
|
||||
private EntryPoint CreateEntryPoint(ILog log)
|
||||
{
|
||||
var kubeConfig = GetKubeConfig(config.KubeConfigFile);
|
||||
|
||||
var lifecycleConfig = new DistTestCore.Configuration
|
||||
(
|
||||
kubeConfigFile: kubeConfig,
|
||||
logPath: "null",
|
||||
logDebug: false,
|
||||
dataFilesPath: "notUsed",
|
||||
codexLogLevel: config.CodexLogLevel,
|
||||
k8sNamespacePrefix: config.KubeNamespace
|
||||
);
|
||||
var configuration = new KubernetesWorkflow.Configuration(
|
||||
kubeConfig,
|
||||
operationTimeout: TimeSpan.FromSeconds(30),
|
||||
retryDelay: TimeSpan.FromSeconds(10),
|
||||
kubernetesNamespace: config.KubeNamespace);
|
||||
|
||||
var lifecycle = new TestLifecycle(new NullLog(), lifecycleConfig, timeset, string.Empty);
|
||||
DefaultContainerRecipe.TestsType = config.TestsTypePodLabel;
|
||||
DefaultContainerRecipe.ApplicationIds = lifecycle.GetApplicationIds();
|
||||
return lifecycle;
|
||||
return new EntryPoint(log, configuration, string.Empty);
|
||||
}
|
||||
|
||||
private (RunningContainer?, GrafanaStartInfo?) StartMetricsService(TestLifecycle lifecycle, CodexSetup setup, IEnumerable<RunningContainer> codexContainers)
|
||||
private RunningContainer? StartMetricsService(CoreInterface ci, List<CodexNodeStartResult> startResults)
|
||||
{
|
||||
if (setup.MetricsMode == DistTestCore.Metrics.MetricsMode.None) return (null, null);
|
||||
if (!config.Metrics) return null;
|
||||
|
||||
Log("Starting metrics service...");
|
||||
var runningContainers = new[] { new RunningContainers(null!, null!, codexContainers.ToArray()) };
|
||||
var prometheusContainer = lifecycle.PrometheusStarter.CollectMetricsFor(runningContainers).Containers.Single();
|
||||
|
||||
if (setup.MetricsMode == DistTestCore.Metrics.MetricsMode.Record) return (prometheusContainer, null);
|
||||
var runningContainer = ci.DeployMetricsCollector(startResults.Select(r => r.CodexNode).ToArray());
|
||||
|
||||
Log("Starting dashboard service...");
|
||||
var grafanaStartInfo = lifecycle.GrafanaStarter.StartDashboard(prometheusContainer, setup);
|
||||
return (prometheusContainer, grafanaStartInfo);
|
||||
Log("Metrics service started.");
|
||||
|
||||
return runningContainer;
|
||||
}
|
||||
|
||||
private string? GetKubeConfig(string kubeConfigFile)
|
||||
|
@ -106,7 +106,7 @@ namespace CodexNetDeployer
|
|||
{
|
||||
if (!config.CheckPeerConnection) return;
|
||||
|
||||
Log("Starting peer-connectivity check for deployed nodes...");
|
||||
Log("Starting peer connectivity check for deployed nodes...");
|
||||
peerConnectivityChecker.CheckConnectivity(codexContainers);
|
||||
Log("Check passed.");
|
||||
}
|
||||
|
@ -114,19 +114,21 @@ namespace CodexNetDeployer
|
|||
private void CheckContainerRestarts(List<CodexNodeStartResult> startResults)
|
||||
{
|
||||
var crashes = new List<RunningContainer>();
|
||||
Log("Starting container crash check...");
|
||||
foreach (var startResult in startResults)
|
||||
{
|
||||
var watcher = startResult.Workflow.CreateCrashWatcher(startResult.Container);
|
||||
if (watcher.HasContainerCrashed()) crashes.Add(startResult.Container);
|
||||
var watcher = startResult.CodexNode.Container.CrashWatcher;
|
||||
if (watcher == null) throw new Exception("Expected each CodexNode container to be created with a crash-watcher.");
|
||||
if (watcher.HasContainerCrashed()) crashes.Add(startResult.CodexNode.Container);
|
||||
}
|
||||
|
||||
if (!crashes.Any())
|
||||
{
|
||||
Log("Container restart check passed.");
|
||||
Log("Check passed.");
|
||||
}
|
||||
else
|
||||
{
|
||||
Log($"Deployment failed. The following containers have crashed: {string.Join(",", crashes.Select(c => c.Name))}");
|
||||
Log($"Check failed. The following containers have crashed: {string.Join(",", crashes.Select(c => c.Name))}");
|
||||
throw new Exception("Deployment failed: One or more containers crashed.");
|
||||
}
|
||||
}
|
||||
|
|
|
@ -9,9 +9,9 @@ namespace CodexNetDeployer
|
|||
{
|
||||
var log = new ConsoleLog();
|
||||
var checker = new PeerConnectionTestHelpers(log);
|
||||
var access = startResults.Select(r => r.Access);
|
||||
var nodes = startResults.Select(r => r.CodexNode);
|
||||
|
||||
checker.AssertFullyConnected(access);
|
||||
checker.AssertFullyConnected(nodes);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1,8 +1,5 @@
|
|||
using ArgsUniform;
|
||||
using CodexNetDeployer;
|
||||
using DistTestCore.Codex;
|
||||
using DistTestCore.Marketplace;
|
||||
using DistTestCore.Metrics;
|
||||
using Newtonsoft.Json;
|
||||
using Configuration = CodexNetDeployer.Configuration;
|
||||
|
||||
|
@ -26,12 +23,8 @@ public class Program
|
|||
return;
|
||||
}
|
||||
|
||||
Console.WriteLine("Using images:" + nl +
|
||||
$"\tCodex image: '{new CodexContainerRecipe().Image}'" + nl +
|
||||
$"\tCodexContracts image: '{new CodexContractsContainerRecipe().Image}'" + nl +
|
||||
$"\tPrometheus image: '{new PrometheusContainerRecipe().Image}'" + nl +
|
||||
$"\tGeth image: '{new GethContainerRecipe().Image}'" + nl +
|
||||
$"\tGrafana image: '{new GrafanaContainerRecipe().Image}'" + nl);
|
||||
var deployer = new Deployer(config);
|
||||
deployer.AnnouncePlugins();
|
||||
|
||||
if (!args.Any(a => a == "-y"))
|
||||
{
|
||||
|
@ -40,7 +33,6 @@ public class Program
|
|||
Console.WriteLine("I think so too.");
|
||||
}
|
||||
|
||||
var deployer = new Deployer(config);
|
||||
var deployment = deployer.Deploy();
|
||||
|
||||
Console.WriteLine("Writing codex-deployment.json...");
|
||||
|
|
|
@ -12,5 +12,5 @@ dotnet run \
|
|||
--block-ttl=180 \
|
||||
--block-mi=120 \
|
||||
--block-mn=10000 \
|
||||
--metrics=Dashboard \
|
||||
--metrics=true \
|
||||
--check-connect=1
|
||||
|
|
Loading…
Reference in New Issue