80 lines
2.6 KiB
C#
Raw Normal View History

2023-09-12 13:32:06 +02:00
using Core;
2023-04-13 11:30:19 +02:00
using Logging;
using Utils;
2023-04-12 13:53:55 +02:00
namespace DistTestCore
{
public class TestLifecycle
2023-04-12 13:53:55 +02:00
{
2023-07-31 11:51:29 +02:00
private readonly DateTime testStart;
2023-04-13 14:36:17 +02:00
2023-09-12 10:31:55 +02:00
public TestLifecycle(TestLog log, Configuration configuration, ITimeSet timeSet, string testNamespace)
2023-04-12 13:53:55 +02:00
{
2023-04-14 14:53:39 +02:00
Log = log;
Configuration = configuration;
TimeSet = timeSet;
testStart = DateTime.UtcNow;
2023-07-18 14:26:21 +02:00
EntryPoint = new EntryPoint(log, configuration.GetK8sConfiguration(timeSet, testNamespace), configuration.GetFileManagerFolder(), timeSet);
EntryPoint.Initialize();
2023-09-11 16:57:57 +02:00
2023-09-12 10:31:55 +02:00
log.WriteLogTag();
2023-04-12 16:06:04 +02:00
}
2023-04-12 13:53:55 +02:00
2023-09-12 10:31:55 +02:00
public TestLog Log { get; }
public Configuration Configuration { get; }
public ITimeSet TimeSet { get; }
public EntryPoint EntryPoint { get; }
2023-09-12 10:31:55 +02:00
public void DeleteAllResources()
{
EntryPoint.CreateWorkflow().DeleteNamespace();
EntryPoint.GetFileManager().DeleteAllTestFiles();
}
2023-07-31 11:51:29 +02:00
2023-09-12 10:31:55 +02:00
//public IDownloadedLog DownloadLog(RunningContainer container, int? tailLines = null)
//{
2023-09-12 10:31:55 +02:00
// var subFile = Log.CreateSubfile();
// var description = container.Name;
// var handler = new LogDownloadHandler(container, description, subFile);
// Log.Log($"Downloading logs for {description} to file '{subFile.FullFilename}'");
// //CodexStarter.DownloadLog(container, handler, tailLines);
// return new DownloadedLog(subFile, description);
//}
2023-08-10 11:25:22 +02:00
2023-09-12 10:31:55 +02:00
public string GetTestDuration()
{
2023-09-12 10:31:55 +02:00
var testDuration = DateTime.UtcNow - testStart;
return Time.FormatDuration(testDuration);
}
2023-09-12 10:31:55 +02:00
////public void SetCodexVersion(CodexDebugVersionResponse version)
////{
//// if (CodexVersion == null) CodexVersion = version;
////}
//public ApplicationIds GetApplicationIds()
//{
// //return new ApplicationIds(
// // codexId: GetCodexId(),
// // gethId: new GethContainerRecipe().Image,
// // prometheusId: new PrometheusContainerRecipe().Image,
// // codexContractsId: new CodexContractsContainerRecipe().Image,
// // grafanaId: new GrafanaContainerRecipe().Image
// //);
// return null!;
//}
//private string GetCodexId()
//{
// return "";
// //var v = CodexVersion;
// //if (v == null) return new CodexContainerRecipe().Image;
// //if (v.version != "untagged build") return v.version;
// //return v.revision;
//}
2023-04-12 13:53:55 +02:00
}
}