cs-codex-dist-tests/CodexDistTestCore/OfflineCodexNodes.cs

68 lines
1.9 KiB
C#
Raw Normal View History

2023-03-21 12:20:21 +00:00
namespace CodexDistTestCore
{
2023-03-21 14:17:48 +00:00
public interface IOfflineCodexNodes
{
2023-03-21 14:17:48 +00:00
IOfflineCodexNodes WithLogLevel(CodexLogLevel level);
IOfflineCodexNodes WithBootstrapNode(IOnlineCodexNode node);
IOfflineCodexNodes WithStorageQuota(ByteSize storageQuota);
IOnlineCodexNodes BringOnline();
}
public enum CodexLogLevel
{
Trace,
Debug,
Info,
Warn,
Error
}
2023-03-21 14:17:48 +00:00
public class OfflineCodexNodes : IOfflineCodexNodes
{
private readonly IK8sManager k8SManager;
2023-03-21 14:17:48 +00:00
public int NumberOfNodes { get; }
public CodexLogLevel? LogLevel { get; private set; }
public IOnlineCodexNode? BootstrapNode { get; private set; }
public ByteSize? StorageQuota { get; private set; }
2023-03-21 14:17:48 +00:00
public OfflineCodexNodes(IK8sManager k8SManager, int numberOfNodes)
{
this.k8SManager = k8SManager;
2023-03-21 14:17:48 +00:00
NumberOfNodes = numberOfNodes;
}
2023-03-21 14:17:48 +00:00
public IOnlineCodexNodes BringOnline()
{
return k8SManager.BringOnline(this);
}
2023-03-21 14:17:48 +00:00
public IOfflineCodexNodes WithBootstrapNode(IOnlineCodexNode node)
{
BootstrapNode = node;
return this;
}
2023-03-21 14:17:48 +00:00
public IOfflineCodexNodes WithLogLevel(CodexLogLevel level)
{
LogLevel = level;
return this;
}
2023-03-21 14:17:48 +00:00
public IOfflineCodexNodes WithStorageQuota(ByteSize storageQuota)
{
StorageQuota = storageQuota;
return this;
}
2023-03-20 10:37:02 +00:00
public string Describe()
{
var result = "";
if (LogLevel != null) result += $"LogLevel={LogLevel},";
if (BootstrapNode != null) result += "BootstrapNode=set,";
if (StorageQuota != null) result += $"StorageQuote={StorageQuota.SizeInBytes},";
2023-03-20 10:37:02 +00:00
return result;
}
}
}