From 009ce1e9f3d27c3e8042ffc705f4ed26b46725db Mon Sep 17 00:00:00 2001 From: benbierens Date: Tue, 18 Jul 2023 09:47:44 +0200 Subject: [PATCH] Wires up the status log. --- ContinuousTests/Configuration.cs | 6 ++++-- ContinuousTests/ContinuousTestRunner.cs | 2 +- ContinuousTests/SingleTestRun.cs | 2 +- ContinuousTests/StartupChecker.cs | 2 +- DistTestCore/DistTest.cs | 7 ++++++- Logging/StatusLog.cs | 14 ++------------ 6 files changed, 15 insertions(+), 18 deletions(-) diff --git a/ContinuousTests/Configuration.cs b/ContinuousTests/Configuration.cs index dd122cb..1cfb697 100644 --- a/ContinuousTests/Configuration.cs +++ b/ContinuousTests/Configuration.cs @@ -57,9 +57,11 @@ namespace ContinuousTests private static void PrintHelp() { var nl = Environment.NewLine; - Console.WriteLine("CodexNetDownloader lets you download all container logs given a codex-deployment.json file." + nl); + Console.WriteLine("ContinuousTests will run a set of tests against a codex deployment given a codex-deployment.json file." + nl + + "The tests will run in an endless loop unless otherwise specified, using the test-specific timing values." + nl); - Console.WriteLine("CodexNetDownloader assumes you are running this tool from *inside* the Kubernetes cluster. " + + + Console.WriteLine("ContinuousTests assumes you are running this tool from *inside* the Kubernetes cluster. " + "If you are not running this from a container inside the cluster, add the argument '--external'." + nl); } } diff --git a/ContinuousTests/ContinuousTestRunner.cs b/ContinuousTests/ContinuousTestRunner.cs index 5be4ff8..d7ac7d9 100644 --- a/ContinuousTests/ContinuousTestRunner.cs +++ b/ContinuousTests/ContinuousTestRunner.cs @@ -24,7 +24,7 @@ namespace ContinuousTests startupChecker.Check(); var taskFactory = new TaskFactory(); - var overviewLog = new FixtureLog(new LogConfig(config.LogPath, false), "Overview"); + var overviewLog = new FixtureLog(new LogConfig(config.LogPath, false), DateTime.UtcNow, "Overview"); overviewLog.Log("Continuous tests starting..."); var allTests = testFactory.CreateTests(); diff --git a/ContinuousTests/SingleTestRun.cs b/ContinuousTests/SingleTestRun.cs index f8e6583..b065c77 100644 --- a/ContinuousTests/SingleTestRun.cs +++ b/ContinuousTests/SingleTestRun.cs @@ -32,7 +32,7 @@ namespace ContinuousTests this.handle = handle; this.cancelToken = cancelToken; testName = handle.Test.GetType().Name; - fixtureLog = new FixtureLog(new LogConfig(config.LogPath, true), testName); + fixtureLog = new FixtureLog(new LogConfig(config.LogPath, true), DateTime.UtcNow, testName); nodes = CreateRandomNodes(handle.Test.RequiredNumberOfNodes); dataFolder = config.DataPath + "-" + Guid.NewGuid(); diff --git a/ContinuousTests/StartupChecker.cs b/ContinuousTests/StartupChecker.cs index a2e1e1f..f6a470c 100644 --- a/ContinuousTests/StartupChecker.cs +++ b/ContinuousTests/StartupChecker.cs @@ -19,7 +19,7 @@ namespace ContinuousTests public void Check() { - var log = new FixtureLog(new LogConfig(config.LogPath, false), "StartupChecks"); + var log = new FixtureLog(new LogConfig(config.LogPath, false), DateTime.UtcNow, "StartupChecks"); log.Log("Starting continuous test run..."); log.Log("Checking configuration..."); PreflightCheck(config); diff --git a/DistTestCore/DistTest.cs b/DistTestCore/DistTest.cs index e2a5c77..76c966a 100644 --- a/DistTestCore/DistTest.cs +++ b/DistTestCore/DistTest.cs @@ -16,6 +16,7 @@ namespace DistTestCore private readonly Configuration configuration = new Configuration(); private readonly Assembly[] testAssemblies; private readonly FixtureLog fixtureLog; + private readonly StatusLog statusLog; private readonly object lifecycleLock = new object(); private readonly Dictionary lifecycles = new Dictionary(); @@ -24,7 +25,10 @@ namespace DistTestCore var assemblies = AppDomain.CurrentDomain.GetAssemblies(); testAssemblies = assemblies.Where(a => a.FullName!.ToLowerInvariant().Contains("test")).ToArray(); - fixtureLog = new FixtureLog(configuration.GetLogConfig()); + var logConfig = configuration.GetLogConfig(); + var startTime = DateTime.UtcNow; + fixtureLog = new FixtureLog(logConfig, startTime); + statusLog = new StatusLog(logConfig, startTime, CodexContainerRecipe.DockerImage); PeerConnectionTestHelpers = new PeerConnectionTestHelpers(this); PeerDownloadTestHelpers = new PeerDownloadTestHelpers(this); @@ -196,6 +200,7 @@ namespace DistTestCore { var lifecycle = Get(); fixtureLog.Log($"{GetCurrentTestName()} = {GetTestResult()} ({lifecycle.GetTestDuration()})"); + statusLog.ConcludeTest(GetTestResult()); Stopwatch.Measure(fixtureLog, $"Teardown for {GetCurrentTestName()}", () => { lifecycle.Log.EndTest(); diff --git a/Logging/StatusLog.cs b/Logging/StatusLog.cs index 5af7542..4d852ee 100644 --- a/Logging/StatusLog.cs +++ b/Logging/StatusLog.cs @@ -16,23 +16,13 @@ namespace Logging this.codexId = codexId; } - public void TestPassed() - { - Write("successful"); - } - - public void TestFailed() - { - Write("failed"); - } - - private void Write(string status) + public void ConcludeTest(string resultStatus) { Write(new StatusLogJson { time = DateTime.UtcNow.ToString("u"), runid = GetRunId(), - status = status, + status = resultStatus, testid = GetTestId(), codexid = codexId, fixturename = fixtureName,