2023-09-11 09:59:33 +00:00
|
|
|
|
using DistTestCore.Logs;
|
2023-09-11 08:43:27 +00:00
|
|
|
|
using FileUtils;
|
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-07-31 09:51:29 +00:00
|
|
|
|
private readonly DateTime testStart;
|
2023-04-13 12:36:17 +00:00
|
|
|
|
|
2023-09-04 07:08:34 +00:00
|
|
|
|
public TestLifecycle(BaseLog log, Configuration configuration, ITimeSet timeSet, string testNamespace)
|
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;
|
2023-04-13 12:36:17 +00:00
|
|
|
|
|
2023-09-04 07:08:34 +00:00
|
|
|
|
WorkflowCreator = new WorkflowCreator(log, configuration.GetK8sConfiguration(timeSet), testNamespace);
|
2023-08-10 08:58:18 +00:00
|
|
|
|
|
2023-09-11 08:43:27 +00:00
|
|
|
|
FileManager = new FileManager(Log, configuration.GetFileManagerFolder());
|
2023-09-11 09:59:33 +00:00
|
|
|
|
//CodexStarter = new CodexStarter(this);
|
2023-08-10 08:58:18 +00:00
|
|
|
|
PrometheusStarter = new PrometheusStarter(this);
|
2023-08-13 06:40:32 +00:00
|
|
|
|
GrafanaStarter = new GrafanaStarter(this);
|
2023-09-11 09:59:33 +00:00
|
|
|
|
//GethStarter = new GethStarter(this);
|
2023-05-03 12:55:26 +00:00
|
|
|
|
testStart = DateTime.UtcNow;
|
2023-09-11 09:59:33 +00:00
|
|
|
|
//CodexVersion = null;
|
2023-07-18 12:26:21 +00:00
|
|
|
|
|
2023-09-11 14:57:57 +00:00
|
|
|
|
// the plugin manager is starting to look like the testlifecycle, that's bad because they are not supposed to be doing the same things:
|
|
|
|
|
// pluginmanager should be useful for disttest-deployer-continuoustest, everyone!
|
|
|
|
|
// but testlifecycle should be a disttest specific user of the plugin manager.
|
|
|
|
|
// disttest requires a hook by which it can keep track of containers created?? (does it?) /namespace used? for the purpose of cleaning up.
|
|
|
|
|
|
|
|
|
|
//var pluginManager = new PluginManager(Log, configuration, timeSet, testNamespace);
|
|
|
|
|
//pluginManager.InitializeAllPlugins();
|
|
|
|
|
|
2023-07-18 12:26:21 +00:00
|
|
|
|
Log.WriteLogTag();
|
2023-04-12 14:06:04 +00:00
|
|
|
|
}
|
2023-04-12 11:53:55 +00:00
|
|
|
|
|
2023-06-28 13:11:20 +00:00
|
|
|
|
public BaseLog 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-08-10 08:58:18 +00:00
|
|
|
|
public WorkflowCreator WorkflowCreator { get; }
|
2023-04-12 14:06:04 +00:00
|
|
|
|
public FileManager FileManager { get; }
|
2023-09-11 09:59:33 +00:00
|
|
|
|
//public CodexStarter CodexStarter { get; }
|
2023-04-13 12:36:17 +00:00
|
|
|
|
public PrometheusStarter PrometheusStarter { get; }
|
2023-08-13 06:40:32 +00:00
|
|
|
|
public GrafanaStarter GrafanaStarter { get; }
|
2023-09-11 09:59:33 +00:00
|
|
|
|
//public GethStarter GethStarter { get; }
|
|
|
|
|
//public CodexDebugVersionResponse? CodexVersion { get; private set; }
|
2023-04-12 11:53:55 +00:00
|
|
|
|
|
2023-04-12 14:06:04 +00:00
|
|
|
|
public void DeleteAllResources()
|
|
|
|
|
{
|
2023-09-11 09:59:33 +00:00
|
|
|
|
//CodexStarter.DeleteAllResources();
|
2023-04-12 14:06:04 +00:00
|
|
|
|
FileManager.DeleteAllTestFiles();
|
2023-04-12 11:53:55 +00:00
|
|
|
|
}
|
2023-04-13 09:30:19 +00:00
|
|
|
|
|
2023-08-16 14:13:29 +00:00
|
|
|
|
public IDownloadedLog DownloadLog(RunningContainer container, int? tailLines = null)
|
2023-04-13 09:30:19 +00:00
|
|
|
|
{
|
|
|
|
|
var subFile = Log.CreateSubfile();
|
2023-06-27 13:28:00 +00:00
|
|
|
|
var description = container.Name;
|
|
|
|
|
var handler = new LogDownloadHandler(container, 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-09-11 09:59:33 +00:00
|
|
|
|
//CodexStarter.DownloadLog(container, handler, tailLines);
|
2023-04-13 09:30:19 +00:00
|
|
|
|
|
2023-06-27 13:28:00 +00:00
|
|
|
|
return new DownloadedLog(subFile, description);
|
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-07-31 09:51:29 +00:00
|
|
|
|
|
2023-09-11 09:59:33 +00:00
|
|
|
|
//public void SetCodexVersion(CodexDebugVersionResponse version)
|
|
|
|
|
//{
|
|
|
|
|
// if (CodexVersion == null) CodexVersion = version;
|
|
|
|
|
//}
|
2023-08-10 09:25:22 +00:00
|
|
|
|
|
2023-08-10 11:58:50 +00:00
|
|
|
|
public ApplicationIds GetApplicationIds()
|
|
|
|
|
{
|
2023-09-11 09:59:33 +00:00
|
|
|
|
//return new ApplicationIds(
|
|
|
|
|
// codexId: GetCodexId(),
|
|
|
|
|
// gethId: new GethContainerRecipe().Image,
|
|
|
|
|
// prometheusId: new PrometheusContainerRecipe().Image,
|
|
|
|
|
// codexContractsId: new CodexContractsContainerRecipe().Image,
|
|
|
|
|
// grafanaId: new GrafanaContainerRecipe().Image
|
|
|
|
|
//);
|
|
|
|
|
return null!;
|
2023-08-10 11:58:50 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private string GetCodexId()
|
2023-08-10 09:25:22 +00:00
|
|
|
|
{
|
2023-09-11 09:59:33 +00:00
|
|
|
|
return "";
|
|
|
|
|
//var v = CodexVersion;
|
|
|
|
|
//if (v == null) return new CodexContainerRecipe().Image;
|
|
|
|
|
//if (v.version != "untagged build") return v.version;
|
|
|
|
|
//return v.revision;
|
2023-08-10 09:25:22 +00:00
|
|
|
|
}
|
2023-04-12 11:53:55 +00:00
|
|
|
|
}
|
|
|
|
|
}
|