diff --git a/CodexPlugin/CodexAccess.cs b/CodexPlugin/CodexAccess.cs index 40433cf..fa9c00a 100644 --- a/CodexPlugin/CodexAccess.cs +++ b/CodexPlugin/CodexAccess.cs @@ -1,6 +1,5 @@ using Core; using KubernetesWorkflow; -using Utils; namespace CodexPlugin { @@ -83,7 +82,7 @@ namespace CodexPlugin return Container.Name; } - private Http Http() + private IHttp Http() { return tools.CreateHttp(Container.Address, baseUrl: "/api/codex/v1", CheckContainerCrashed, Container.Name); } diff --git a/Core/CoreInterface.cs b/Core/CoreInterface.cs index 8b6b1b4..fca6e62 100644 --- a/Core/CoreInterface.cs +++ b/Core/CoreInterface.cs @@ -25,6 +25,7 @@ namespace Core { var workflow = entryPoint.Tools.CreateWorkflow(); var file = entryPoint.Tools.GetLog().CreateSubfile(); + entryPoint.Tools.GetLog().Log($"Downloading container log for '{container.Name}' to file '{file.FullFilename}'..."); var logHandler = new LogDownloadHandler(container.Name, file); workflow.DownloadContainerLog(container, logHandler, tailLines); return logHandler.DownloadLog(); diff --git a/Core/DownloadedLog.cs b/Core/DownloadedLog.cs index ee31ed7..9242d9b 100644 --- a/Core/DownloadedLog.cs +++ b/Core/DownloadedLog.cs @@ -9,11 +9,11 @@ namespace Core void DeleteFile(); } - public class DownloadedLog : IDownloadedLog + internal class DownloadedLog : IDownloadedLog { private readonly LogFile logFile; - public DownloadedLog(LogFile logFile) + internal DownloadedLog(LogFile logFile) { this.logFile = logFile; } diff --git a/Core/Http.cs b/Core/Http.cs index dbb2f99..5bbd132 100644 --- a/Core/Http.cs +++ b/Core/Http.cs @@ -7,7 +7,19 @@ using Utils; namespace Core { - public class Http + public interface IHttp + { + string HttpGetString(string route); + T HttpGetJson(string route); + TResponse HttpPostJson(string route, TRequest body); + string HttpPostJson(string route, TRequest body); + string HttpPostString(string route, string body); + string HttpPostStream(string route, Stream stream); + Stream HttpGetStream(string route); + T TryJsonDeserialize(string json); + } + + internal class Http : IHttp { private readonly ILog log; private readonly ITimeSet timeSet; @@ -16,12 +28,12 @@ namespace Core private readonly Action onClientCreated; private readonly string? logAlias; - public Http(ILog log, ITimeSet timeSet, Address address, string baseUrl, string? logAlias = null) + internal Http(ILog log, ITimeSet timeSet, Address address, string baseUrl, string? logAlias = null) : this(log, timeSet, address, baseUrl, DoNothing, logAlias) { } - public Http(ILog log, ITimeSet timeSet, Address address, string baseUrl, Action onClientCreated, string? logAlias = null) + internal Http(ILog log, ITimeSet timeSet, Address address, string baseUrl, Action onClientCreated, string? logAlias = null) { this.log = log; this.timeSet = timeSet; diff --git a/Core/LogDownloadHandler.cs b/Core/LogDownloadHandler.cs index ae6a1da..e1736ed 100644 --- a/Core/LogDownloadHandler.cs +++ b/Core/LogDownloadHandler.cs @@ -3,11 +3,11 @@ using Logging; namespace Core { - public class LogDownloadHandler : LogHandler, ILogHandler + internal class LogDownloadHandler : LogHandler, ILogHandler { private readonly LogFile log; - public LogDownloadHandler(string description, LogFile log) + internal LogDownloadHandler(string description, LogFile log) { this.log = log; @@ -15,7 +15,7 @@ namespace Core log.WriteRaw(description); } - public IDownloadedLog DownloadLog() + internal IDownloadedLog DownloadLog() { return new DownloadedLog(log); } diff --git a/Core/PluginFinder.cs b/Core/PluginFinder.cs index 693db86..69df075 100644 --- a/Core/PluginFinder.cs +++ b/Core/PluginFinder.cs @@ -2,11 +2,11 @@ namespace Core { - public static class PluginFinder + internal static class PluginFinder { private static Type[]? pluginTypes = null; - public static Type[] GetPluginTypes() + internal static Type[] GetPluginTypes() { if (pluginTypes != null) return pluginTypes; diff --git a/Core/PluginManager.cs b/Core/PluginManager.cs index 2b24788..69ee4bb 100644 --- a/Core/PluginManager.cs +++ b/Core/PluginManager.cs @@ -1,6 +1,6 @@ namespace Core { - public class PluginManager + internal class PluginManager { private readonly List projectPlugins = new List(); @@ -16,12 +16,12 @@ } } - public void AnnouncePlugins() + internal void AnnouncePlugins() { foreach (var plugin in projectPlugins) plugin.Announce(); } - public PluginMetadata GatherPluginMetadata() + internal PluginMetadata GatherPluginMetadata() { var metadata = new PluginMetadata(); foreach (var plugin in projectPlugins) @@ -34,12 +34,12 @@ return metadata; } - public void DecommissionPlugins() + internal void DecommissionPlugins() { foreach (var plugin in projectPlugins) plugin.Decommission(); } - public T GetPlugin() where T : IProjectPlugin + internal T GetPlugin() where T : IProjectPlugin { return (T)projectPlugins.Single(p => p.GetType() == typeof(T)); } diff --git a/Core/PluginMetadata.cs b/Core/PluginMetadata.cs index c84af76..7bbe1e1 100644 --- a/Core/PluginMetadata.cs +++ b/Core/PluginMetadata.cs @@ -1,6 +1,6 @@ namespace Core { - public interface IPluginMetadata + internal interface IPluginMetadata { Dictionary Get(); } @@ -10,7 +10,7 @@ void Add(string key, string value); } - public class PluginMetadata : IPluginMetadata, IAddMetadata + internal class PluginMetadata : IPluginMetadata, IAddMetadata { private readonly Dictionary metadata = new Dictionary(); diff --git a/Core/PluginTools.cs b/Core/PluginTools.cs index 704588a..dd0360c 100644 --- a/Core/PluginTools.cs +++ b/Core/PluginTools.cs @@ -21,8 +21,8 @@ namespace Core public interface IHttpFactoryTool { - Http CreateHttp(Address address, string baseUrl, Action onClientCreated, string? logAlias = null); - Http CreateHttp(Address address, string baseUrl, string? logAlias = null); + IHttp CreateHttp(Address address, string baseUrl, Action onClientCreated, string? logAlias = null); + IHttp CreateHttp(Address address, string baseUrl, string? logAlias = null); } public interface IFileTool @@ -37,7 +37,7 @@ namespace Core private readonly IFileManager fileManager; private ILog log; - public PluginTools(ILog log, WorkflowCreator workflowCreator, string fileManagerRootFolder, ITimeSet timeSet) + internal PluginTools(ILog log, WorkflowCreator workflowCreator, string fileManagerRootFolder, ITimeSet timeSet) { this.log = log; this.workflowCreator = workflowCreator; @@ -50,12 +50,12 @@ namespace Core log = new LogPrefixer(log, prefix); } - public Http CreateHttp(Address address, string baseUrl, Action onClientCreated, string? logAlias = null) + public IHttp CreateHttp(Address address, string baseUrl, Action onClientCreated, string? logAlias = null) { return new Http(log, timeSet, address, baseUrl, onClientCreated, logAlias); } - public Http CreateHttp(Address address, string baseUrl, string? logAlias = null) + public IHttp CreateHttp(Address address, string baseUrl, string? logAlias = null) { return new Http(log, timeSet, address, baseUrl, logAlias); } diff --git a/DistTestCore/TestLifecycle.cs b/DistTestCore/TestLifecycle.cs index 4723dd2..1ceea34 100644 --- a/DistTestCore/TestLifecycle.cs +++ b/DistTestCore/TestLifecycle.cs @@ -81,22 +81,13 @@ namespace DistTestCore public void DownloadAllLogs() { - var workflow = entryPoint.Tools.CreateWorkflow(); foreach (var rc in runningContainers) { foreach (var c in rc.Containers) { - DownloadContainerLog(workflow, c); + CoreInterface.DownloadLog(c); } } } - - private void DownloadContainerLog(IStartupWorkflow workflow, RunningContainer c) - { - var file = Log.CreateSubfile(); - Log.Log($"Downloading container log for '{c.Name}' to file '{file.FullFilename}'..."); - var handler = new LogDownloadHandler(c.Name, file); - workflow.DownloadContainerLog(c, handler); - } } } diff --git a/MetricsPlugin/MetricsQuery.cs b/MetricsPlugin/MetricsQuery.cs index 425907e..7d63477 100644 --- a/MetricsPlugin/MetricsQuery.cs +++ b/MetricsPlugin/MetricsQuery.cs @@ -6,7 +6,7 @@ namespace MetricsPlugin { public class MetricsQuery { - private readonly Http http; + private readonly IHttp http; public MetricsQuery(IPluginTools tools, RunningContainer runningContainer) {