2023-04-12 14:06:04 +00:00
|
|
|
|
using DistTestCore.Codex;
|
2023-04-14 08:51:35 +00:00
|
|
|
|
using DistTestCore.Marketplace;
|
2023-04-12 14:12:04 +00:00
|
|
|
|
using KubernetesWorkflow;
|
2023-04-12 14:06:04 +00:00
|
|
|
|
|
|
|
|
|
namespace DistTestCore
|
|
|
|
|
{
|
2023-04-13 07:33:10 +00:00
|
|
|
|
public interface ICodexSetup
|
2023-04-12 14:06:04 +00:00
|
|
|
|
{
|
2023-04-13 07:33:10 +00:00
|
|
|
|
ICodexSetup At(Location location);
|
|
|
|
|
ICodexSetup WithLogLevel(CodexLogLevel level);
|
2023-04-12 14:06:04 +00:00
|
|
|
|
//ICodexStartupConfig WithBootstrapNode(IOnlineCodexNode node);
|
2023-04-13 07:33:10 +00:00
|
|
|
|
ICodexSetup WithStorageQuota(ByteSize storageQuota);
|
|
|
|
|
ICodexSetup EnableMetrics();
|
2023-04-14 08:51:35 +00:00
|
|
|
|
ICodexSetup EnableMarketplace(int initialBalance);
|
2023-04-12 14:06:04 +00:00
|
|
|
|
ICodexNodeGroup BringOnline();
|
|
|
|
|
}
|
2023-04-12 14:12:04 +00:00
|
|
|
|
|
2023-04-13 07:33:10 +00:00
|
|
|
|
public class CodexSetup : CodexStartupConfig, ICodexSetup
|
2023-04-12 14:06:04 +00:00
|
|
|
|
{
|
|
|
|
|
private readonly CodexStarter starter;
|
|
|
|
|
|
|
|
|
|
public int NumberOfNodes { get; }
|
|
|
|
|
|
2023-04-13 07:33:10 +00:00
|
|
|
|
public CodexSetup(CodexStarter starter, int numberOfNodes)
|
2023-04-12 14:06:04 +00:00
|
|
|
|
{
|
|
|
|
|
this.starter = starter;
|
|
|
|
|
NumberOfNodes = numberOfNodes;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public ICodexNodeGroup BringOnline()
|
|
|
|
|
{
|
|
|
|
|
return starter.BringOnline(this);
|
|
|
|
|
}
|
|
|
|
|
|
2023-04-13 07:33:10 +00:00
|
|
|
|
public ICodexSetup At(Location location)
|
2023-04-12 14:06:04 +00:00
|
|
|
|
{
|
|
|
|
|
Location = location;
|
|
|
|
|
return this;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//public ICodexSetupConfig WithBootstrapNode(IOnlineCodexNode node)
|
|
|
|
|
//{
|
|
|
|
|
// BootstrapNode = node;
|
|
|
|
|
// return this;
|
|
|
|
|
//}
|
|
|
|
|
|
2023-04-13 07:33:10 +00:00
|
|
|
|
public ICodexSetup WithLogLevel(CodexLogLevel level)
|
2023-04-12 14:06:04 +00:00
|
|
|
|
{
|
|
|
|
|
LogLevel = level;
|
|
|
|
|
return this;
|
|
|
|
|
}
|
|
|
|
|
|
2023-04-13 07:33:10 +00:00
|
|
|
|
public ICodexSetup WithStorageQuota(ByteSize storageQuota)
|
2023-04-12 14:06:04 +00:00
|
|
|
|
{
|
|
|
|
|
StorageQuota = storageQuota;
|
|
|
|
|
return this;
|
|
|
|
|
}
|
|
|
|
|
|
2023-04-13 07:33:10 +00:00
|
|
|
|
public ICodexSetup EnableMetrics()
|
2023-04-12 14:06:04 +00:00
|
|
|
|
{
|
|
|
|
|
MetricsEnabled = true;
|
|
|
|
|
return this;
|
|
|
|
|
}
|
|
|
|
|
|
2023-04-14 08:51:35 +00:00
|
|
|
|
public ICodexSetup EnableMarketplace(int initialBalance)
|
|
|
|
|
{
|
|
|
|
|
MarketplaceConfig = new MarketplaceInitialConfig(initialBalance);
|
|
|
|
|
return this;
|
|
|
|
|
}
|
2023-04-12 14:06:04 +00:00
|
|
|
|
|
|
|
|
|
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}";
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|