From 5996c0fa63fec19e3becf149c2ec08cb7a5d4f29 Mon Sep 17 00:00:00 2001 From: benbierens Date: Tue, 14 Nov 2023 12:56:47 +0100 Subject: [PATCH] Adds involvedpods, error, and duration in seconds to status logs for continuous tests. --- Tests/CodexContinuousTests/ContinuousTestRunner.cs | 2 +- Tests/CodexContinuousTests/SingleTestRun.cs | 6 ++++++ Tests/DistTestCore/Logs/StatusLog.cs | 4 ++-- Tests/DistTestCore/TestLifecycle.cs | 5 ++--- 4 files changed, 11 insertions(+), 6 deletions(-) diff --git a/Tests/CodexContinuousTests/ContinuousTestRunner.cs b/Tests/CodexContinuousTests/ContinuousTestRunner.cs index 1816960..2838a1b 100644 --- a/Tests/CodexContinuousTests/ContinuousTestRunner.cs +++ b/Tests/CodexContinuousTests/ContinuousTestRunner.cs @@ -98,7 +98,7 @@ namespace ContinuousTests private void WaitUntilFinished(LogSplitter overviewLog, StatusLog statusLog, DateTime startTime, TestLoop[] testLoops) { - var testDuration = Time.FormatDuration(DateTime.UtcNow - startTime); + var testDuration = (DateTime.UtcNow - startTime).TotalSeconds.ToString(); var testData = FormatTestRuns(testLoops); overviewLog.Log("Total duration: " + testDuration); diff --git a/Tests/CodexContinuousTests/SingleTestRun.cs b/Tests/CodexContinuousTests/SingleTestRun.cs index 033e9c9..b525a72 100644 --- a/Tests/CodexContinuousTests/SingleTestRun.cs +++ b/Tests/CodexContinuousTests/SingleTestRun.cs @@ -191,6 +191,12 @@ namespace ContinuousTests result.Add("teststart", testStart.ToString("o")); result.Add("testname", testName); result.Add("message", message); + result.Add("involvedpods", string.Join(",", nodes.Select(n => n.GetName()))); + + var error = message.Split(Environment.NewLine).First(); + if (error.Contains(":")) error = error.Substring(1 + error.LastIndexOf(":")); + result.Add("error", error); + return result; } diff --git a/Tests/DistTestCore/Logs/StatusLog.cs b/Tests/DistTestCore/Logs/StatusLog.cs index 8c097ad..a03e919 100644 --- a/Tests/DistTestCore/Logs/StatusLog.cs +++ b/Tests/DistTestCore/Logs/StatusLog.cs @@ -1,6 +1,6 @@ using Logging; using Newtonsoft.Json; -using Utils; +using System.Globalization; namespace DistTestCore.Logs { @@ -20,7 +20,7 @@ namespace DistTestCore.Logs public void ConcludeTest(string resultStatus, TimeSpan testDuration, Dictionary data) { - ConcludeTest(resultStatus, Time.FormatDuration(testDuration), data); + ConcludeTest(resultStatus, testDuration.TotalSeconds.ToString(CultureInfo.InvariantCulture), data); } public void ConcludeTest(string resultStatus, string testDuration, Dictionary data) diff --git a/Tests/DistTestCore/TestLifecycle.cs b/Tests/DistTestCore/TestLifecycle.cs index b386343..45cfff4 100644 --- a/Tests/DistTestCore/TestLifecycle.cs +++ b/Tests/DistTestCore/TestLifecycle.cs @@ -58,10 +58,9 @@ namespace DistTestCore return entryPoint.GetPluginMetadata(); } - public string GetTestDuration() + public TimeSpan GetTestDuration() { - var testDuration = DateTime.UtcNow - testStart; - return Time.FormatDuration(testDuration); + return DateTime.UtcNow - testStart; } public void OnContainersStarted(RunningContainers rc)