Proper log monitoring shutdown

This commit is contained in:
benbierens 2023-10-01 10:52:05 +02:00
parent b23c66c86e
commit da855b8d0d
No known key found for this signature in database
GPG Key ID: FE44815D96D0A1AA
3 changed files with 11 additions and 4 deletions

View File

@ -73,6 +73,7 @@ namespace ContinuousTests
{
var targetDuration = TimeSpan.FromSeconds(config.TargetDurationSeconds);
cancelToken.WaitHandle.WaitOne(targetDuration);
Cancellation.Cts.Cancel();
overviewLog.Log($"Congratulations! The targer duration has been reached! ({Time.FormatDuration(targetDuration)})");
statusLog.ConcludeTest("Passed", testDuration, testData);
}

View File

@ -73,12 +73,10 @@ namespace ContinuousTests
try
{
foreach (var m in monitors) m.Run();
fixtureLog.Log("Monitor start");
RunTestMoments();
foreach (var m in monitors) m.Stop();
if (monitors.Any(m => m.Fault)) throw new Exception("Any faulted");
if (!config.KeepPassedTestLogs)
{
fixtureLog.Delete();
@ -103,6 +101,13 @@ namespace ContinuousTests
}
}
}
finally
{
Thread.Sleep(1000);
fixtureLog.Log("Monitor stop");
foreach (var m in monitors) m.Stop();
if (monitors.Any(m => m.Fault)) throw new Exception("One or more downloaded container log is missing lines!");
}
}
private void ApplyLogReplacements(FixtureLog fixtureLog, StartupChecker startupChecker)
@ -143,6 +148,7 @@ namespace ContinuousTests
return;
}
}
fixtureLog.Log("Test run has been cancelled.");
}
private void ThrowFailTest()

View File

@ -39,7 +39,7 @@ namespace ContinuousTests
{
NumberOfPasses = 0;
NumberOfFailures = 0;
while (true)
while (!cancelToken.IsCancellationRequested)
{
WaitHandle.WaitAny(new[] { runFinishedHandle, cancelToken.WaitHandle });