diff --git a/DistTestCore/Codex/CodexAccess.cs b/DistTestCore/Codex/CodexAccess.cs index d0c0f72..c07a457 100644 --- a/DistTestCore/Codex/CodexAccess.cs +++ b/DistTestCore/Codex/CodexAccess.cs @@ -13,9 +13,7 @@ namespace DistTestCore.Codex public CodexDebugResponse GetDebugInfo() { - var response = Http().HttpGetJson("debug/info"); - //Log($"Got DebugInfo with id: '{response.id}'."); - return response; + return Http().HttpGetJson("debug/info"); } public string UploadFile(FileStream fileStream) diff --git a/DistTestCore/CodexNodeGroup.cs b/DistTestCore/CodexNodeGroup.cs index 25d46c1..4e2cd16 100644 --- a/DistTestCore/CodexNodeGroup.cs +++ b/DistTestCore/CodexNodeGroup.cs @@ -47,13 +47,6 @@ namespace DistTestCore public RunningContainers Containers { get; private set; } public OnlineCodexNode[] Nodes { get; private set; } - //public GethCompanionGroup? GethCompanionGroup { get; set; } - - //public CodexNodeContainer[] GetContainers() - //{ - // return Nodes.Select(n => n.Container).ToArray(); - //} - public IEnumerator GetEnumerator() { return Nodes.Cast().GetEnumerator(); @@ -64,13 +57,6 @@ namespace DistTestCore return Nodes.GetEnumerator(); } - //public CodexNodeLog DownloadLog(IOnlineCodexNode node) - //{ - // var logDownloader = new PodLogDownloader(log, k8SManager); - // var n = (OnlineCodexNode)node; - // return logDownloader.DownloadLog(n); - //} - public string Describe() { return $""; @@ -79,7 +65,22 @@ namespace DistTestCore private OnlineCodexNode CreateOnlineCodexNode(RunningContainer c, ICodexNodeFactory factory) { var access = new CodexAccess(c); + EnsureOnline(access); return factory.CreateOnlineCodexNode(access, this); } + + private void EnsureOnline(CodexAccess access) + { + try + { + var debugInfo = access.GetDebugInfo(); + if (debugInfo == null || string.IsNullOrEmpty(debugInfo.id)) throw new InvalidOperationException("Unable to get debug-info from codex node at startup."); + } + catch (Exception e) + { + lifecycle.Log.Error($"Failed to start codex node: {e}"); + throw; + } + } } } diff --git a/DistTestCore/FileManager.cs b/DistTestCore/FileManager.cs index 10f126b..b195e9c 100644 --- a/DistTestCore/FileManager.cs +++ b/DistTestCore/FileManager.cs @@ -14,7 +14,6 @@ namespace DistTestCore { public const int ChunkSize = 1024 * 1024; private readonly Random random = new Random(); - private readonly List activeFiles = new List(); private readonly TestLog log; private readonly string folder; @@ -22,7 +21,7 @@ namespace DistTestCore { folder = configuration.GetFileManagerFolder(); - if (!Directory.Exists(folder)) Directory.CreateDirectory(folder); + EnsureDirectory(); this.log = log; } @@ -30,7 +29,6 @@ namespace DistTestCore { var result = new TestFile(Path.Combine(folder, Guid.NewGuid().ToString() + "_test.bin")); File.Create(result.Filename).Close(); - activeFiles.Add(result); return result; } @@ -44,8 +42,7 @@ namespace DistTestCore public void DeleteAllTestFiles() { - foreach (var file in activeFiles) File.Delete(file.Filename); - activeFiles.Clear(); + DeleteDirectory(); } private void GenerateFileBytes(TestFile result, ByteSize size) @@ -66,6 +63,16 @@ namespace DistTestCore using var stream = new FileStream(result.Filename, FileMode.Append); stream.Write(bytes, 0, bytes.Length); } + + private void EnsureDirectory() + { + if (!Directory.Exists(folder)) Directory.CreateDirectory(folder); + } + + private void DeleteDirectory() + { + Directory.Delete(folder, true); + } } public class TestFile diff --git a/Logging/FixtureLog.cs b/Logging/FixtureLog.cs index e06f4bc..7bb80ab 100644 --- a/Logging/FixtureLog.cs +++ b/Logging/FixtureLog.cs @@ -10,8 +10,8 @@ namespace Logging public FixtureLog(LogConfig config) { start = DateTime.UtcNow; - var folder = DetermineFolder(config); // "root/2023-04 /14" - var fixtureName = GetFixtureName(); // "11-09-23Z_ExampleTests" + var folder = DetermineFolder(config); + var fixtureName = GetFixtureName(); fullName = Path.Combine(folder, fixtureName); }