cs-codex-dist-tests/CodexNetDeployer/Deployer.cs

64 lines
2.0 KiB
C#
Raw Normal View History

2023-06-22 08:17:12 +00:00
using DistTestCore;
namespace CodexNetDeployer
{
public class Deployer
{
private readonly Configuration config;
public Deployer(Configuration config)
{
this.config = config;
}
public void Deploy()
2023-06-22 08:33:21 +00:00
{
Log("Initializing...");
var starter = CreateStarter();
Log("Preparing configuration...");
var setup = new CodexSetup(config.NumberOfCodexNodes!.Value, config.CodexLogLevel);
Log("Creating resources...");
var group = (CodexNodeGroup) starter.BringOnline(setup);
var containers = group.Containers;
foreach (var container in containers.Containers)
{
var pod = container.Pod.PodInfo;
Log($"Container '{container.Name}' online. Pod: '{pod.Name}@{pod.Ip}' on '{pod.K8SNodeName}'.");
}
}
private CodexStarter CreateStarter()
2023-06-22 08:17:12 +00:00
{
var log = new NullLog();
var lifecycleConfig = new DistTestCore.Configuration
(
kubeConfigFile: config.KubeConfigFile,
logPath: "null",
logDebug: false,
dataFilesPath: "notUsed",
2023-06-22 08:33:21 +00:00
codexLogLevel: config.CodexLogLevel,
2023-06-22 08:17:12 +00:00
runnerLocation: config.RunnerLocation
);
var timeset = new DefaultTimeSet();
var kubeConfig = new KubernetesWorkflow.Configuration(
k8sNamespacePrefix: config.KubeNamespace,
kubeConfigFile: config.KubeConfigFile,
operationTimeout: timeset.K8sOperationTimeout(),
retryDelay: timeset.WaitForK8sServiceDelay());
var lifecycle = new TestLifecycle(log, lifecycleConfig, timeset);
var workflowCreator = new KubernetesWorkflow.WorkflowCreator(log, kubeConfig);
2023-06-22 08:33:21 +00:00
return new CodexStarter(lifecycle, workflowCreator);
}
private void Log(string msg)
{
Console.WriteLine(msg);
2023-06-22 08:17:12 +00:00
}
}
}