Adds overview log

This commit is contained in:
benbierens 2023-06-25 11:06:47 +02:00
parent ae3b4df92c
commit 83c2088185
No known key found for this signature in database
GPG Key ID: FE44815D96D0A1AA
3 changed files with 25 additions and 9 deletions

View File

@ -1,4 +1,6 @@
namespace ContinuousTests using Logging;
namespace ContinuousTests
{ {
public class ContinuousTestRunner public class ContinuousTestRunner
{ {
@ -17,8 +19,9 @@
{ {
startupChecker.Check(); startupChecker.Check();
var overviewLog = new FixtureLog(new LogConfig(config.LogPath, false), "Overview");
var allTests = testFactory.CreateTests(); var allTests = testFactory.CreateTests();
var testStarters = allTests.Select(t => new TestStarter(config, t.GetType(), t.RunTestEvery)).ToArray(); var testStarters = allTests.Select(t => new TestStarter(config, overviewLog, t.GetType(), t.RunTestEvery)).ToArray();
foreach (var t in testStarters) foreach (var t in testStarters)
{ {

View File

@ -11,15 +11,17 @@ namespace ContinuousTests
private readonly CodexNodeFactory codexNodeFactory = new CodexNodeFactory(); private readonly CodexNodeFactory codexNodeFactory = new CodexNodeFactory();
private readonly List<Exception> exceptions = new List<Exception>(); private readonly List<Exception> exceptions = new List<Exception>();
private readonly Configuration config; private readonly Configuration config;
private readonly BaseLog overviewLog;
private readonly TestHandle handle; private readonly TestHandle handle;
private readonly CodexNode[] nodes; private readonly CodexNode[] nodes;
private readonly FileManager fileManager; private readonly FileManager fileManager;
private readonly FixtureLog fixtureLog; private readonly FixtureLog fixtureLog;
private readonly string dataFolder; private readonly string dataFolder;
public SingleTestRun(Configuration config, TestHandle handle) public SingleTestRun(Configuration config, BaseLog overviewLog, TestHandle handle)
{ {
this.config = config; this.config = config;
this.overviewLog = overviewLog;
this.handle = handle; this.handle = handle;
var testName = handle.Test.GetType().Name; var testName = handle.Test.GetType().Name;
@ -76,10 +78,11 @@ namespace ContinuousTests
{ {
if (exceptions.Any()) if (exceptions.Any())
{ {
Log(" > Completed last test moment. Test failed."); var ex = exceptions.First();
throw exceptions.First(); OverviewLog(" > Test failed: " + ex);
throw ex;
} }
Log(" > Completed last test moment. Test passed."); OverviewLog(" > Test passed.");
return; return;
} }
} }
@ -116,6 +119,12 @@ namespace ContinuousTests
fixtureLog.Log(msg); fixtureLog.Log(msg);
} }
private void OverviewLog(string msg)
{
Log(msg);
overviewLog.Log(msg);
}
private CodexNode[] CreateRandomNodes(int number) private CodexNode[] CreateRandomNodes(int number)
{ {
var containers = SelectRandomContainers(number); var containers = SelectRandomContainers(number);

View File

@ -1,14 +1,18 @@
namespace ContinuousTests using Logging;
namespace ContinuousTests
{ {
public class TestStarter public class TestStarter
{ {
private readonly Configuration config; private readonly Configuration config;
private readonly BaseLog overviewLog;
private readonly Type testType; private readonly Type testType;
private readonly TimeSpan runsEvery; private readonly TimeSpan runsEvery;
public TestStarter(Configuration config, Type testType, TimeSpan runsEvery) public TestStarter(Configuration config, BaseLog overviewLog, Type testType, TimeSpan runsEvery)
{ {
this.config = config; this.config = config;
this.overviewLog = overviewLog;
this.testType = testType; this.testType = testType;
this.runsEvery = runsEvery; this.runsEvery = runsEvery;
} }
@ -29,7 +33,7 @@
{ {
var test = (ContinuousTest)Activator.CreateInstance(testType)!; var test = (ContinuousTest)Activator.CreateInstance(testType)!;
var handle = new TestHandle(test); var handle = new TestHandle(test);
var run = new SingleTestRun(config, handle); var run = new SingleTestRun(config, overviewLog, handle);
run.Run(); run.Run();
} }
} }