2023-04-12 14:12:04 +00:00
|
|
|
|
using DistTestCore.Codex;
|
|
|
|
|
using KubernetesWorkflow;
|
2023-04-12 14:06:04 +00:00
|
|
|
|
|
|
|
|
|
namespace DistTestCore
|
|
|
|
|
{
|
|
|
|
|
public class CodexStarter
|
|
|
|
|
{
|
|
|
|
|
private readonly WorkflowCreator workflowCreator;
|
2023-04-13 07:33:10 +00:00
|
|
|
|
private readonly TestLifecycle lifecycle;
|
2023-04-12 14:06:04 +00:00
|
|
|
|
|
2023-04-13 07:33:10 +00:00
|
|
|
|
public CodexStarter(TestLifecycle lifecycle, Configuration configuration)
|
2023-04-12 14:06:04 +00:00
|
|
|
|
{
|
|
|
|
|
workflowCreator = new WorkflowCreator(configuration.GetK8sConfiguration());
|
2023-04-13 07:33:10 +00:00
|
|
|
|
this.lifecycle = lifecycle;
|
2023-04-12 14:06:04 +00:00
|
|
|
|
}
|
|
|
|
|
|
2023-04-13 07:33:10 +00:00
|
|
|
|
public ICodexNodeGroup BringOnline(CodexSetup codexSetup)
|
2023-04-12 14:06:04 +00:00
|
|
|
|
{
|
2023-04-13 09:07:36 +00:00
|
|
|
|
var workflow = CreateWorkflow();
|
2023-04-12 14:12:04 +00:00
|
|
|
|
var startupConfig = new StartupConfig();
|
2023-04-13 07:33:10 +00:00
|
|
|
|
startupConfig.Add(codexSetup);
|
2023-04-12 14:06:04 +00:00
|
|
|
|
|
2023-04-13 07:33:10 +00:00
|
|
|
|
var runningContainers = workflow.Start(codexSetup.NumberOfNodes, codexSetup.Location, new CodexContainerRecipe(), startupConfig);
|
2023-04-12 14:12:04 +00:00
|
|
|
|
|
2023-04-13 07:33:10 +00:00
|
|
|
|
return new CodexNodeGroup(lifecycle, codexSetup, runningContainers);
|
2023-04-12 14:06:04 +00:00
|
|
|
|
}
|
|
|
|
|
|
2023-04-13 09:07:36 +00:00
|
|
|
|
public void BringOffline(RunningContainers runningContainers)
|
|
|
|
|
{
|
|
|
|
|
var workflow = CreateWorkflow();
|
|
|
|
|
workflow.Stop(runningContainers);
|
|
|
|
|
}
|
|
|
|
|
|
2023-04-12 14:06:04 +00:00
|
|
|
|
public void DeleteAllResources()
|
|
|
|
|
{
|
2023-04-13 09:07:36 +00:00
|
|
|
|
var workflow = CreateWorkflow();
|
2023-04-12 14:06:04 +00:00
|
|
|
|
workflow.DeleteAllResources();
|
|
|
|
|
}
|
2023-04-13 09:07:36 +00:00
|
|
|
|
|
|
|
|
|
private StartupWorkflow CreateWorkflow()
|
|
|
|
|
{
|
|
|
|
|
return workflowCreator.CreateWorkflow();
|
|
|
|
|
}
|
2023-04-12 14:06:04 +00:00
|
|
|
|
}
|
|
|
|
|
}
|