cs-codex-dist-tests/DistTestCore/CodexSetupConfig.cs

84 lines
2.4 KiB
C#
Raw Normal View History

2023-04-12 14:06:04 +00:00
using DistTestCore.Codex;
2023-04-12 14:12:04 +00:00
using KubernetesWorkflow;
2023-04-12 14:06:04 +00:00
namespace DistTestCore
{
public interface ICodexSetupConfig
{
ICodexSetupConfig At(Location location);
ICodexSetupConfig WithLogLevel(CodexLogLevel level);
//ICodexStartupConfig WithBootstrapNode(IOnlineCodexNode node);
ICodexSetupConfig WithStorageQuota(ByteSize storageQuota);
ICodexSetupConfig EnableMetrics();
//ICodexSetupConfig EnableMarketplace(int initialBalance);
ICodexNodeGroup BringOnline();
}
2023-04-12 14:12:04 +00:00
public class CodexSetupConfig : CodexStartupConfig, ICodexSetupConfig
2023-04-12 14:06:04 +00:00
{
private readonly CodexStarter starter;
public int NumberOfNodes { get; }
public CodexSetupConfig(CodexStarter starter, int numberOfNodes)
{
this.starter = starter;
NumberOfNodes = numberOfNodes;
}
public ICodexNodeGroup BringOnline()
{
return starter.BringOnline(this);
}
public ICodexSetupConfig At(Location location)
{
Location = location;
return this;
}
//public ICodexSetupConfig WithBootstrapNode(IOnlineCodexNode node)
//{
// BootstrapNode = node;
// return this;
//}
public ICodexSetupConfig WithLogLevel(CodexLogLevel level)
{
LogLevel = level;
return this;
}
public ICodexSetupConfig WithStorageQuota(ByteSize storageQuota)
{
StorageQuota = storageQuota;
return this;
}
public ICodexSetupConfig EnableMetrics()
{
MetricsEnabled = true;
return this;
}
//public ICodexSetupConfig EnableMarketplace(int initialBalance)
//{
// MarketplaceConfig = new MarketplaceInitialConfig(initialBalance);
// return this;
//}
public string Describe()
{
var args = string.Join(',', DescribeArgs());
return $"{NumberOfNodes} CodexNodes with [{args}]";
}
private IEnumerable<string> DescribeArgs()
{
if (LogLevel != null) yield return $"LogLevel={LogLevel}";
//if (BootstrapNode != null) yield return "BootstrapNode=set-not-shown-here";
if (StorageQuota != null) yield return $"StorageQuote={StorageQuota.SizeInBytes}";
}
}
}