Merge branch 'feature/continuous-testing'

This commit is contained in:
benbierens 2023-06-25 11:07:09 +02:00
commit 0ebfed6014
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
{
@ -17,8 +19,9 @@
{
startupChecker.Check();
var overviewLog = new FixtureLog(new LogConfig(config.LogPath, false), "Overview");
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)
{

View File

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

View File

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