Wires up the status log.

This commit is contained in:
benbierens 2023-07-18 09:47:44 +02:00
parent f50b8dfc83
commit 009ce1e9f3
No known key found for this signature in database
GPG Key ID: FE44815D96D0A1AA
6 changed files with 15 additions and 18 deletions

View File

@ -57,9 +57,11 @@ namespace ContinuousTests
private static void PrintHelp() private static void PrintHelp()
{ {
var nl = Environment.NewLine; 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); "If you are not running this from a container inside the cluster, add the argument '--external'." + nl);
} }
} }

View File

@ -24,7 +24,7 @@ namespace ContinuousTests
startupChecker.Check(); startupChecker.Check();
var taskFactory = new TaskFactory(); 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..."); overviewLog.Log("Continuous tests starting...");
var allTests = testFactory.CreateTests(); var allTests = testFactory.CreateTests();

View File

@ -32,7 +32,7 @@ namespace ContinuousTests
this.handle = handle; this.handle = handle;
this.cancelToken = cancelToken; this.cancelToken = cancelToken;
testName = handle.Test.GetType().Name; 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); nodes = CreateRandomNodes(handle.Test.RequiredNumberOfNodes);
dataFolder = config.DataPath + "-" + Guid.NewGuid(); dataFolder = config.DataPath + "-" + Guid.NewGuid();

View File

@ -19,7 +19,7 @@ namespace ContinuousTests
public void Check() 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("Starting continuous test run...");
log.Log("Checking configuration..."); log.Log("Checking configuration...");
PreflightCheck(config); PreflightCheck(config);

View File

@ -16,6 +16,7 @@ namespace DistTestCore
private readonly Configuration configuration = new Configuration(); private readonly Configuration configuration = new Configuration();
private readonly Assembly[] testAssemblies; private readonly Assembly[] testAssemblies;
private readonly FixtureLog fixtureLog; private readonly FixtureLog fixtureLog;
private readonly StatusLog statusLog;
private readonly object lifecycleLock = new object(); private readonly object lifecycleLock = new object();
private readonly Dictionary<string, TestLifecycle> lifecycles = new Dictionary<string, TestLifecycle>(); private readonly Dictionary<string, TestLifecycle> lifecycles = new Dictionary<string, TestLifecycle>();
@ -24,7 +25,10 @@ namespace DistTestCore
var assemblies = AppDomain.CurrentDomain.GetAssemblies(); var assemblies = AppDomain.CurrentDomain.GetAssemblies();
testAssemblies = assemblies.Where(a => a.FullName!.ToLowerInvariant().Contains("test")).ToArray(); 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); PeerConnectionTestHelpers = new PeerConnectionTestHelpers(this);
PeerDownloadTestHelpers = new PeerDownloadTestHelpers(this); PeerDownloadTestHelpers = new PeerDownloadTestHelpers(this);
@ -196,6 +200,7 @@ namespace DistTestCore
{ {
var lifecycle = Get(); var lifecycle = Get();
fixtureLog.Log($"{GetCurrentTestName()} = {GetTestResult()} ({lifecycle.GetTestDuration()})"); fixtureLog.Log($"{GetCurrentTestName()} = {GetTestResult()} ({lifecycle.GetTestDuration()})");
statusLog.ConcludeTest(GetTestResult());
Stopwatch.Measure(fixtureLog, $"Teardown for {GetCurrentTestName()}", () => Stopwatch.Measure(fixtureLog, $"Teardown for {GetCurrentTestName()}", () =>
{ {
lifecycle.Log.EndTest(); lifecycle.Log.EndTest();

View File

@ -16,23 +16,13 @@ namespace Logging
this.codexId = codexId; this.codexId = codexId;
} }
public void TestPassed() public void ConcludeTest(string resultStatus)
{
Write("successful");
}
public void TestFailed()
{
Write("failed");
}
private void Write(string status)
{ {
Write(new StatusLogJson Write(new StatusLogJson
{ {
time = DateTime.UtcNow.ToString("u"), time = DateTime.UtcNow.ToString("u"),
runid = GetRunId(), runid = GetRunId(),
status = status, status = resultStatus,
testid = GetTestId(), testid = GetTestId(),
codexid = codexId, codexid = codexId,
fixturename = fixtureName, fixturename = fixtureName,