Wires dashboard into deployer
This commit is contained in:
parent
fc3f424208
commit
f1131abf79
|
@ -84,7 +84,7 @@ namespace CodexNetDeployer
|
||||||
var marketplaceConfig = new MarketplaceInitialConfig(100000.Eth(), 0.TestTokens(), validatorsLeft > 0);
|
var marketplaceConfig = new MarketplaceInitialConfig(100000.Eth(), 0.TestTokens(), validatorsLeft > 0);
|
||||||
marketplaceConfig.AccountIndexOverride = i;
|
marketplaceConfig.AccountIndexOverride = i;
|
||||||
codexStart.MarketplaceConfig = marketplaceConfig;
|
codexStart.MarketplaceConfig = marketplaceConfig;
|
||||||
codexStart.MetricsEnabled = config.RecordMetrics;
|
codexStart.MetricsMode = config.Metrics;
|
||||||
|
|
||||||
if (config.BlockTTL != Configuration.SecondsIn1Day)
|
if (config.BlockTTL != Configuration.SecondsIn1Day)
|
||||||
{
|
{
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
using ArgsUniform;
|
using ArgsUniform;
|
||||||
using DistTestCore.Codex;
|
using DistTestCore.Codex;
|
||||||
|
using DistTestCore.Metrics;
|
||||||
|
|
||||||
namespace CodexNetDeployer
|
namespace CodexNetDeployer
|
||||||
{
|
{
|
||||||
|
@ -43,8 +44,8 @@ namespace CodexNetDeployer
|
||||||
[Uniform("block-ttl", "bt", "BLOCKTTL", false, "Block timeout in seconds. Default is 24 hours.")]
|
[Uniform("block-ttl", "bt", "BLOCKTTL", false, "Block timeout in seconds. Default is 24 hours.")]
|
||||||
public int BlockTTL { get; set; } = SecondsIn1Day;
|
public int BlockTTL { get; set; } = SecondsIn1Day;
|
||||||
|
|
||||||
[Uniform("record-metrics", "rm", "RECORDMETRICS", false, "If true, metrics will be collected for all Codex nodes.")]
|
[Uniform("metrics", "m", "METRICS", false, "[None*, Record, Dashboard]. Determines if metrics will be recorded and if a dashboard service will be created.")]
|
||||||
public bool RecordMetrics { get; set; } = false;
|
public MetricsMode Metrics { get; set; } = MetricsMode.None;
|
||||||
|
|
||||||
[Uniform("teststype-podlabel", "ttpl", "TESTSTYPE-PODLABEL", false, "Each kubernetes pod will be created with a label 'teststype' with value 'continuous'. " +
|
[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.")]
|
"set this option to override the label value.")]
|
||||||
|
|
|
@ -27,7 +27,7 @@ namespace CodexNetDeployer
|
||||||
// We trick the Geth companion node into unlocking all of its accounts, by saying we want to start 999 codex nodes.
|
// 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);
|
var setup = new CodexSetup(999, config.CodexLogLevel);
|
||||||
setup.WithStorageQuota(config.StorageQuota!.Value.MB()).EnableMarketplace(0.TestTokens());
|
setup.WithStorageQuota(config.StorageQuota!.Value.MB()).EnableMarketplace(0.TestTokens());
|
||||||
setup.MetricsEnabled = config.RecordMetrics;
|
setup.MetricsMode = config.Metrics;
|
||||||
|
|
||||||
Log("Creating Geth instance and deploying contracts...");
|
Log("Creating Geth instance and deploying contracts...");
|
||||||
var gethStarter = new GethStarter(lifecycle);
|
var gethStarter = new GethStarter(lifecycle);
|
||||||
|
@ -52,9 +52,9 @@ namespace CodexNetDeployer
|
||||||
if (container != null) codexContainers.Add(container);
|
if (container != null) codexContainers.Add(container);
|
||||||
}
|
}
|
||||||
|
|
||||||
var prometheusContainer = StartMetricsService(lifecycle, setup, codexContainers);
|
var (prometheusContainer, grafanaStartInfo) = StartMetricsService(lifecycle, setup, codexContainers);
|
||||||
|
|
||||||
return new CodexDeployment(gethResults, codexContainers.ToArray(), prometheusContainer, CreateMetadata());
|
return new CodexDeployment(gethResults, codexContainers.ToArray(), prometheusContainer, grafanaStartInfo, CreateMetadata());
|
||||||
}
|
}
|
||||||
|
|
||||||
private TestLifecycle CreateTestLifecycle()
|
private TestLifecycle CreateTestLifecycle()
|
||||||
|
@ -74,13 +74,19 @@ namespace CodexNetDeployer
|
||||||
return new TestLifecycle(log, lifecycleConfig, timeset, config.TestsTypePodLabel, string.Empty);
|
return new TestLifecycle(log, lifecycleConfig, timeset, config.TestsTypePodLabel, string.Empty);
|
||||||
}
|
}
|
||||||
|
|
||||||
private RunningContainer? StartMetricsService(TestLifecycle lifecycle, CodexSetup setup, List<RunningContainer> codexContainers)
|
private (RunningContainer?, GrafanaStartInfo?) StartMetricsService(TestLifecycle lifecycle, CodexSetup setup, List<RunningContainer> codexContainers)
|
||||||
{
|
{
|
||||||
if (!setup.MetricsEnabled) return null;
|
if (setup.MetricsMode == DistTestCore.Metrics.MetricsMode.None) return (null, null);
|
||||||
|
|
||||||
Log("Starting metrics service...");
|
Log("Starting metrics service...");
|
||||||
var runningContainers = new[] { new RunningContainers(null!, null!, codexContainers.ToArray()) };
|
var runningContainers = new[] { new RunningContainers(null!, null!, codexContainers.ToArray()) };
|
||||||
return lifecycle.PrometheusStarter.CollectMetricsFor(runningContainers).Containers.Single();
|
var prometheusContainer = lifecycle.PrometheusStarter.CollectMetricsFor(runningContainers).Containers.Single();
|
||||||
|
|
||||||
|
if (setup.MetricsMode == DistTestCore.Metrics.MetricsMode.Record) return (prometheusContainer, null);
|
||||||
|
|
||||||
|
Log("Starting dashboard service...");
|
||||||
|
var grafanaStartInfo = lifecycle.GrafanaStarter.StartDashboard(prometheusContainer);
|
||||||
|
return (prometheusContainer, grafanaStartInfo);
|
||||||
}
|
}
|
||||||
|
|
||||||
private string? GetKubeConfig(string kubeConfigFile)
|
private string? GetKubeConfig(string kubeConfigFile)
|
||||||
|
|
|
@ -10,4 +10,4 @@ dotnet run \
|
||||||
--max-collateral=1024 \
|
--max-collateral=1024 \
|
||||||
--max-duration=3600000 \
|
--max-duration=3600000 \
|
||||||
--block-ttl=300 \
|
--block-ttl=300 \
|
||||||
--record-metrics=true
|
--metrics=Dashboard
|
||||||
|
|
|
@ -51,7 +51,7 @@ namespace DistTestCore.Codex
|
||||||
{
|
{
|
||||||
AddEnvVar("CODEX_BLOCK_TTL", config.BlockTTL.ToString()!);
|
AddEnvVar("CODEX_BLOCK_TTL", config.BlockTTL.ToString()!);
|
||||||
}
|
}
|
||||||
if (config.MetricsEnabled)
|
if (config.MetricsMode != Metrics.MetricsMode.None)
|
||||||
{
|
{
|
||||||
AddEnvVar("CODEX_METRICS", "true");
|
AddEnvVar("CODEX_METRICS", "true");
|
||||||
AddEnvVar("CODEX_METRICS_ADDRESS", "0.0.0.0");
|
AddEnvVar("CODEX_METRICS_ADDRESS", "0.0.0.0");
|
||||||
|
|
|
@ -5,17 +5,19 @@ namespace DistTestCore.Codex
|
||||||
{
|
{
|
||||||
public class CodexDeployment
|
public class CodexDeployment
|
||||||
{
|
{
|
||||||
public CodexDeployment(GethStartResult gethStartResult, RunningContainer[] codexContainers, RunningContainer? prometheusContainer, DeploymentMetadata metadata)
|
public CodexDeployment(GethStartResult gethStartResult, RunningContainer[] codexContainers, RunningContainer? prometheusContainer, GrafanaStartInfo? grafanaStartInfo, DeploymentMetadata metadata)
|
||||||
{
|
{
|
||||||
GethStartResult = gethStartResult;
|
GethStartResult = gethStartResult;
|
||||||
CodexContainers = codexContainers;
|
CodexContainers = codexContainers;
|
||||||
PrometheusContainer = prometheusContainer;
|
PrometheusContainer = prometheusContainer;
|
||||||
|
GrafanaStartInfo = grafanaStartInfo;
|
||||||
Metadata = metadata;
|
Metadata = metadata;
|
||||||
}
|
}
|
||||||
|
|
||||||
public GethStartResult GethStartResult { get; }
|
public GethStartResult GethStartResult { get; }
|
||||||
public RunningContainer[] CodexContainers { get; }
|
public RunningContainer[] CodexContainers { get; }
|
||||||
public RunningContainer? PrometheusContainer { get; }
|
public RunningContainer? PrometheusContainer { get; }
|
||||||
|
public GrafanaStartInfo? GrafanaStartInfo { get; }
|
||||||
public DeploymentMetadata Metadata { get; }
|
public DeploymentMetadata Metadata { get; }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
using DistTestCore.Marketplace;
|
using DistTestCore.Marketplace;
|
||||||
|
using DistTestCore.Metrics;
|
||||||
using KubernetesWorkflow;
|
using KubernetesWorkflow;
|
||||||
|
|
||||||
namespace DistTestCore.Codex
|
namespace DistTestCore.Codex
|
||||||
|
@ -14,7 +15,7 @@ namespace DistTestCore.Codex
|
||||||
public Location Location { get; set; }
|
public Location Location { get; set; }
|
||||||
public CodexLogLevel LogLevel { get; }
|
public CodexLogLevel LogLevel { get; }
|
||||||
public ByteSize? StorageQuota { get; set; }
|
public ByteSize? StorageQuota { get; set; }
|
||||||
public bool MetricsEnabled { get; set; }
|
public MetricsMode MetricsMode { get; set; }
|
||||||
public MarketplaceInitialConfig? MarketplaceConfig { get; set; }
|
public MarketplaceInitialConfig? MarketplaceConfig { get; set; }
|
||||||
public string? BootstrapSpr { get; set; }
|
public string? BootstrapSpr { get; set; }
|
||||||
public int? BlockTTL { get; set; }
|
public int? BlockTTL { get; set; }
|
||||||
|
|
|
@ -59,7 +59,7 @@ namespace DistTestCore
|
||||||
|
|
||||||
public ICodexSetup EnableMetrics()
|
public ICodexSetup EnableMetrics()
|
||||||
{
|
{
|
||||||
MetricsEnabled = true;
|
MetricsMode = Metrics.MetricsMode.Record;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -68,9 +68,15 @@ namespace DistTestCore
|
||||||
|
|
||||||
private IMetricsAccessFactory CollectMetrics(CodexSetup codexSetup, RunningContainers[] containers)
|
private IMetricsAccessFactory CollectMetrics(CodexSetup codexSetup, RunningContainers[] containers)
|
||||||
{
|
{
|
||||||
if (!codexSetup.MetricsEnabled) return new MetricsUnavailableAccessFactory();
|
if (codexSetup.MetricsMode == MetricsMode.None) return new MetricsUnavailableAccessFactory();
|
||||||
|
|
||||||
var runningContainers = lifecycle.PrometheusStarter.CollectMetricsFor(containers);
|
var runningContainers = lifecycle.PrometheusStarter.CollectMetricsFor(containers);
|
||||||
|
|
||||||
|
if (codexSetup.MetricsMode == MetricsMode.Dashboard)
|
||||||
|
{
|
||||||
|
var info = lifecycle.GrafanaStarter.StartDashboard(runningContainers.Containers.First());
|
||||||
|
}
|
||||||
|
|
||||||
return new CodexNodeMetricsAccessFactory(lifecycle, runningContainers);
|
return new CodexNodeMetricsAccessFactory(lifecycle, runningContainers);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,9 @@
|
||||||
|
namespace DistTestCore.Metrics
|
||||||
|
{
|
||||||
|
public enum MetricsMode
|
||||||
|
{
|
||||||
|
None,
|
||||||
|
Record,
|
||||||
|
Dashboard
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue