2023-04-14 07:54:07 +00:00
|
|
|
|
using DistTestCore.Logs;
|
2023-04-13 12:36:17 +00:00
|
|
|
|
using KubernetesWorkflow;
|
2023-04-13 09:30:19 +00:00
|
|
|
|
using Logging;
|
2023-05-03 12:55:26 +00:00
|
|
|
|
using Utils;
|
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-05-03 12:55:26 +00:00
|
|
|
|
private DateTime testStart = DateTime.MinValue;
|
2023-04-13 12:36:17 +00:00
|
|
|
|
|
2023-05-04 06:55:20 +00:00
|
|
|
|
public TestLifecycle(TestLog log, Configuration configuration, ITimeSet timeSet)
|
2023-04-12 11:53:55 +00:00
|
|
|
|
{
|
2023-04-14 12:53:39 +00:00
|
|
|
|
Log = log;
|
2023-06-01 07:35:18 +00:00
|
|
|
|
Configuration = configuration;
|
2023-05-04 06:55:20 +00:00
|
|
|
|
TimeSet = timeSet;
|
|
|
|
|
workflowCreator = new WorkflowCreator(log, configuration.GetK8sConfiguration(timeSet));
|
2023-04-13 12:36:17 +00:00
|
|
|
|
|
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-14 07:54:07 +00:00
|
|
|
|
GethStarter = new GethStarter(this, workflowCreator);
|
2023-05-03 12:55:26 +00:00
|
|
|
|
testStart = DateTime.UtcNow;
|
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; }
|
2023-06-01 07:35:18 +00:00
|
|
|
|
public Configuration Configuration { get; }
|
2023-05-04 06:55:20 +00:00
|
|
|
|
public ITimeSet TimeSet { get; }
|
2023-04-12 14:06:04 +00:00
|
|
|
|
public FileManager FileManager { get; }
|
|
|
|
|
public CodexStarter CodexStarter { get; }
|
2023-04-13 12:36:17 +00:00
|
|
|
|
public PrometheusStarter PrometheusStarter { get; }
|
2023-04-14 07:54:07 +00:00
|
|
|
|
public GethStarter GethStarter { 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();
|
2023-04-19 12:57:00 +00:00
|
|
|
|
var description = node.GetName();
|
2023-04-19 08:42:08 +00:00
|
|
|
|
var handler = new LogDownloadHandler(node, description, subFile);
|
2023-04-13 09:30:19 +00:00
|
|
|
|
|
2023-04-14 12:53:39 +00:00
|
|
|
|
Log.Log($"Downloading logs for {description} to file '{subFile.FullFilename}'");
|
2023-04-13 09:30:19 +00:00
|
|
|
|
CodexStarter.DownloadLog(node.CodexAccess.Container, handler);
|
|
|
|
|
|
2023-04-19 08:42:08 +00:00
|
|
|
|
return new CodexNodeLog(subFile, node);
|
2023-04-13 09:30:19 +00:00
|
|
|
|
}
|
2023-05-03 12:55:26 +00:00
|
|
|
|
|
|
|
|
|
public string GetTestDuration()
|
|
|
|
|
{
|
|
|
|
|
var testDuration = DateTime.UtcNow - testStart;
|
|
|
|
|
return Time.FormatDuration(testDuration);
|
|
|
|
|
}
|
2023-04-12 11:53:55 +00:00
|
|
|
|
}
|
|
|
|
|
}
|