cs-codex-dist-tests/DistTestCore/TestLifecycle.cs

45 lines
1.4 KiB
C#
Raw Normal View History

using DistTestCore.CodexLogsAndMetrics;
2023-04-13 12:36:17 +00:00
using KubernetesWorkflow;
2023-04-13 09:30:19 +00:00
using Logging;
2023-04-12 11:53:55 +00:00
namespace DistTestCore
{
public class TestLifecycle
{
2023-04-13 12:36:17 +00:00
private readonly WorkflowCreator workflowCreator;
2023-04-12 14:06:04 +00:00
public TestLifecycle(Configuration configuration)
2023-04-12 11:53:55 +00:00
{
2023-04-12 14:06:04 +00:00
Log = new TestLog(configuration.GetLogConfig());
2023-04-13 12:36:17 +00:00
workflowCreator = new WorkflowCreator(configuration.GetK8sConfiguration());
2023-04-12 14:06:04 +00:00
FileManager = new FileManager(Log, configuration);
2023-04-13 12:36:17 +00:00
CodexStarter = new CodexStarter(this, workflowCreator);
PrometheusStarter = new PrometheusStarter(this, workflowCreator);
2023-04-12 14:06:04 +00:00
}
2023-04-12 11:53:55 +00:00
2023-04-12 14:06:04 +00:00
public TestLog Log { get; }
public FileManager FileManager { get; }
public CodexStarter CodexStarter { get; }
2023-04-13 12:36:17 +00:00
public PrometheusStarter PrometheusStarter { get; }
2023-04-12 11:53:55 +00:00
2023-04-12 14:06:04 +00:00
public void DeleteAllResources()
{
CodexStarter.DeleteAllResources();
FileManager.DeleteAllTestFiles();
2023-04-12 11:53:55 +00:00
}
2023-04-13 09:30:19 +00:00
public ICodexNodeLog DownloadLog(OnlineCodexNode node)
{
var subFile = Log.CreateSubfile();
var description = node.Describe();
var handler = new LogDownloadHandler(description, subFile);
Log.Log($"Downloading logs for {description} to file {subFile.FilenameWithoutPath}");
2023-04-13 09:30:19 +00:00
CodexStarter.DownloadLog(node.CodexAccess.Container, handler);
return new CodexNodeLog(subFile);
}
2023-04-12 11:53:55 +00:00
}
}