diff --git a/Framework/Utils/CrashWatcher.cs b/Framework/Utils/CrashWatcher.cs deleted file mode 100644 index 9477bdf8..00000000 --- a/Framework/Utils/CrashWatcher.cs +++ /dev/null @@ -1,9 +0,0 @@ -namespace Utils -{ - //public interface ICrashWatcher - //{ - // void Start(); - // void Stop(); - // bool HasCrashed(); - //} -} diff --git a/ProjectPlugins/CodexPlugin/CodexNodeGroup.cs b/ProjectPlugins/CodexPlugin/CodexNodeGroup.cs index 4a8bd9bb..70a5316d 100644 --- a/ProjectPlugins/CodexPlugin/CodexNodeGroup.cs +++ b/ProjectPlugins/CodexPlugin/CodexNodeGroup.cs @@ -57,9 +57,14 @@ namespace CodexPlugin return Nodes.GetEnumerator(); } - public string Describe() + public string Names() { - return $"group:[{string.Join(",", Nodes.Select(n => n.GetName()))}]"; + return $"[{string.Join(",", Nodes.Select(n => n.GetName()))}]"; + } + + public override string ToString() + { + return Names(); } public void EnsureOnline() @@ -76,4 +81,17 @@ namespace CodexPlugin Version = first; } } + + public static class CodexNodeGroupExtensions + { + public static string Names(this ICodexNode[] nodes) + { + return $"[{string.Join(",", nodes.Select(n => n.GetName()))}]"; + } + + public static string Names(this List nodes) + { + return $"[{string.Join(",", nodes.Select(n => n.GetName()))}]"; + } + } } diff --git a/Tests/CodexReleaseTests/DataTests/TheseusTest.cs b/Tests/CodexReleaseTests/DataTests/TheseusTest.cs index eb46cfde..072bc882 100644 --- a/Tests/CodexReleaseTests/DataTests/TheseusTest.cs +++ b/Tests/CodexReleaseTests/DataTests/TheseusTest.cs @@ -1,4 +1,5 @@ using CodexClient; +using CodexPlugin; using CodexTests; using FileUtils; using NUnit.Framework; @@ -36,7 +37,7 @@ namespace CodexReleaseTests.DataTests for (var i = 0; i < steps; i++) { Log($"{nameof(Theseus)} step {i}"); - nodes[i].Stop(waitTillStopped: true); + nodes[0].Stop(waitTillStopped: true); nodes.RemoveAt(0); nodes.Add(StartCodex()); @@ -47,8 +48,12 @@ namespace CodexReleaseTests.DataTests private void AllNodesHaveFile() { - Log($"{nameof(AllNodesHaveFile)} [{string.Join(",", nodes.Select(n => n.GetName()))}]"); + WaitAndCheckNodesStaysAlive(TimeSpan.FromSeconds(20), nodes.ToArray()); + + Log($"{nameof(AllNodesHaveFile)} {nodes.Names()}"); foreach (var n in nodes) HasFile(n); + + WaitAndCheckNodesStaysAlive(TimeSpan.FromSeconds(20), nodes.ToArray()); } private void HasFile(ICodexNode n) diff --git a/Tests/ExperimentalTests/CodexDistTest.cs b/Tests/ExperimentalTests/CodexDistTest.cs index 81f3d051..273128ea 100644 --- a/Tests/ExperimentalTests/CodexDistTest.cs +++ b/Tests/ExperimentalTests/CodexDistTest.cs @@ -16,6 +16,7 @@ using Newtonsoft.Json; using NUnit.Framework; using NUnit.Framework.Constraints; using OverwatchTranscript; +using Utils; namespace CodexTests { @@ -128,16 +129,25 @@ namespace CodexTests public void WaitAndCheckNodesStaysAlive(TimeSpan duration, params ICodexNode[] nodes) { + Log($"{nameof(WaitAndCheckNodesStaysAlive)} {Time.FormatDuration(duration)}..."); + + var timeout = TimeSpan.FromSeconds(3.0); + Assert.That(duration.TotalSeconds, Is.GreaterThan(timeout.TotalSeconds)); + var start = DateTime.UtcNow; while ((DateTime.UtcNow - start) < duration) { - Thread.Sleep(5000); + Thread.Sleep(timeout); foreach (var node in nodes) { + Assert.That(node.HasCrashed(), Is.False); + var info = node.GetDebugInfo(); Assert.That(!string.IsNullOrEmpty(info.Id)); } } + + Log($"{nameof(WaitAndCheckNodesStaysAlive)} OK"); } public void AssertNodesContainFile(ContentId cid, ICodexNodeGroup nodes) @@ -147,11 +157,15 @@ namespace CodexTests public void AssertNodesContainFile(ContentId cid, params ICodexNode[] nodes) { + Log($"{nameof(AssertNodesContainFile)} {nodes.Names()} {cid}..."); + foreach (var node in nodes) { var localDatasets = node.LocalFiles(); CollectionAssert.Contains(localDatasets.Content.Select(c => c.Cid), cid); } + + Log($"{nameof(AssertNodesContainFile)} OK"); } private string GetBasicNodeStatus(ICodexNode node) diff --git a/Tests/ExperimentalTests/Helpers/FullConnectivityHelper.cs b/Tests/ExperimentalTests/Helpers/FullConnectivityHelper.cs index f57a3c65..f8fc6f1d 100644 --- a/Tests/ExperimentalTests/Helpers/FullConnectivityHelper.cs +++ b/Tests/ExperimentalTests/Helpers/FullConnectivityHelper.cs @@ -1,4 +1,5 @@ using CodexClient; +using CodexPlugin; using Logging; using NUnit.Framework; @@ -30,7 +31,7 @@ namespace CodexTests.Helpers private void AssertFullyConnected(ICodexNode[] nodes) { - Log($"Asserting '{implementation.Description()}' for nodes: '{string.Join(",", nodes.Select(n => n.GetName()))}'..."); + Log($"Asserting '{implementation.Description()}' for nodes: '{nodes.Names()}'..."); Assert.That(nodes.Length, Is.GreaterThan(1)); var entries = CreateEntries(nodes); @@ -50,7 +51,7 @@ namespace CodexTests.Helpers } else { - Log($"'{implementation.Description()}' = Success! for nodes: {string.Join(",", nodes.Select(n => n.GetName()))}"); + Log($"'{implementation.Description()}' = Success! for nodes: {nodes.Names()}"); } } diff --git a/Tools/CodexNetDeployer/Deployer.cs b/Tools/CodexNetDeployer/Deployer.cs index 0d78962e..85393052 100644 --- a/Tools/CodexNetDeployer/Deployer.cs +++ b/Tools/CodexNetDeployer/Deployer.cs @@ -222,8 +222,7 @@ namespace CodexNetDeployer } else { - Log( - $"Check failed. The following containers have crashed: {string.Join(",", crashes.Select(c => c.GetName()))}"); + Log($"Check failed. The following containers have crashed: {crashes.Names()}"); throw new Exception("Deployment failed: One or more containers crashed."); } }