2023-03-21 14:44:21 +00:00
|
|
|
|
using k8s.Models;
|
|
|
|
|
|
|
|
|
|
namespace CodexDistTestCore
|
2023-03-21 14:17:48 +00:00
|
|
|
|
{
|
|
|
|
|
public interface IOnlineCodexNodes
|
|
|
|
|
{
|
|
|
|
|
IOfflineCodexNodes BringOffline();
|
|
|
|
|
IOnlineCodexNode this[int index] { get; }
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public class OnlineCodexNodes : IOnlineCodexNodes
|
|
|
|
|
{
|
|
|
|
|
private readonly IK8sManager k8SManager;
|
|
|
|
|
|
2023-03-21 14:44:21 +00:00
|
|
|
|
public OnlineCodexNodes(int orderNumber, OfflineCodexNodes origin, IK8sManager k8SManager, OnlineCodexNode[] nodes)
|
2023-03-21 14:17:48 +00:00
|
|
|
|
{
|
2023-03-21 14:44:21 +00:00
|
|
|
|
OrderNumber = orderNumber;
|
|
|
|
|
Origin = origin;
|
2023-03-21 14:17:48 +00:00
|
|
|
|
this.k8SManager = k8SManager;
|
2023-03-21 14:44:21 +00:00
|
|
|
|
Nodes = nodes;
|
2023-03-21 14:17:48 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public IOnlineCodexNode this[int index]
|
|
|
|
|
{
|
|
|
|
|
get
|
|
|
|
|
{
|
2023-03-21 14:44:21 +00:00
|
|
|
|
return Nodes[index];
|
2023-03-21 14:17:48 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2023-03-21 14:44:21 +00:00
|
|
|
|
public int OrderNumber { get; }
|
|
|
|
|
public OfflineCodexNodes Origin { get; }
|
|
|
|
|
public OnlineCodexNode[] Nodes { get; }
|
|
|
|
|
public V1Deployment? Deployment { get; set; }
|
|
|
|
|
public V1Service? Service { get; set; }
|
|
|
|
|
public List<string> ActivePodNames { get; } = new List<string>();
|
|
|
|
|
|
2023-03-21 14:17:48 +00:00
|
|
|
|
public IOfflineCodexNodes BringOffline()
|
|
|
|
|
{
|
|
|
|
|
return k8SManager.BringOffline(this);
|
|
|
|
|
}
|
2023-03-21 14:44:21 +00:00
|
|
|
|
|
|
|
|
|
public CodexNodeContainer[] GetContainers()
|
|
|
|
|
{
|
|
|
|
|
return Nodes.Select(n => n.Container).ToArray();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public V1ObjectMeta GetServiceMetadata()
|
|
|
|
|
{
|
|
|
|
|
return new V1ObjectMeta
|
|
|
|
|
{
|
|
|
|
|
Name = "codex-test-entrypoint-" + OrderNumber,
|
|
|
|
|
NamespaceProperty = K8sManager.K8sNamespace
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public V1ObjectMeta GetDeploymentMetadata()
|
|
|
|
|
{
|
|
|
|
|
return new V1ObjectMeta
|
|
|
|
|
{
|
|
|
|
|
Name = "codex-test-node-" + OrderNumber,
|
|
|
|
|
NamespaceProperty = K8sManager.K8sNamespace
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public Dictionary<string, string> GetSelector()
|
|
|
|
|
{
|
|
|
|
|
return new Dictionary<string, string> { { "codex-test-node", "dist-test-" + OrderNumber } };
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public string Describe()
|
|
|
|
|
{
|
|
|
|
|
return $"CodexNode{OrderNumber}-{Origin.Describe()}";
|
|
|
|
|
}
|
2023-03-21 14:17:48 +00:00
|
|
|
|
}
|
|
|
|
|
}
|