diff --git a/ContinuousTests/ContinuousTestRunner.cs b/ContinuousTests/ContinuousTestRunner.cs index e465e28..7ad16fa 100644 --- a/ContinuousTests/ContinuousTestRunner.cs +++ b/ContinuousTests/ContinuousTestRunner.cs @@ -38,7 +38,7 @@ namespace ContinuousTests overviewLog.Log("Launching test-loop for " + testLoop.Name); testLoop.Begin(); - Thread.Sleep(TimeSpan.FromSeconds(15)); + Thread.Sleep(TimeSpan.FromSeconds(5)); } overviewLog.Log("Finished launching test-loops."); diff --git a/ContinuousTests/SingleTestRun.cs b/ContinuousTests/SingleTestRun.cs index ac15e74..585971a 100644 --- a/ContinuousTests/SingleTestRun.cs +++ b/ContinuousTests/SingleTestRun.cs @@ -31,14 +31,14 @@ namespace ContinuousTests this.handle = handle; this.cancelToken = cancelToken; testName = handle.Test.GetType().Name; - fixtureLog = new FixtureLog(new LogConfig(config.LogPath, false), testName); + fixtureLog = new FixtureLog(new LogConfig(config.LogPath, true), testName); nodes = CreateRandomNodes(handle.Test.RequiredNumberOfNodes); dataFolder = config.DataPath + "-" + Guid.NewGuid(); fileManager = new FileManager(fixtureLog, CreateFileManagerConfiguration()); } - public void Run() + public void Run(EventWaitHandle runFinishedHandle) { taskFactory.Run(() => { @@ -47,6 +47,7 @@ namespace ContinuousTests RunTest(); fileManager.DeleteAllTestFiles(); Directory.Delete(dataFolder, true); + runFinishedHandle.Set(); } catch (Exception ex) { diff --git a/ContinuousTests/TestLoop.cs b/ContinuousTests/TestLoop.cs index 4de12a1..e57fee8 100644 --- a/ContinuousTests/TestLoop.cs +++ b/ContinuousTests/TestLoop.cs @@ -10,6 +10,7 @@ namespace ContinuousTests private readonly Type testType; private readonly TimeSpan runsEvery; private readonly CancellationToken cancelToken; + private readonly EventWaitHandle runFinishedHandle = new EventWaitHandle(true, EventResetMode.ManualReset); public TestLoop(TaskFactory taskFactory, Configuration config, BaseLog overviewLog, Type testType, TimeSpan runsEvery, CancellationToken cancelToken) { @@ -32,7 +33,10 @@ namespace ContinuousTests { while (true) { + WaitHandle.WaitAny(new[] { runFinishedHandle, cancelToken.WaitHandle }); + cancelToken.ThrowIfCancellationRequested(); + StartTest(); cancelToken.WaitHandle.WaitOne(runsEvery); @@ -55,7 +59,9 @@ namespace ContinuousTests var test = (ContinuousTest)Activator.CreateInstance(testType)!; var handle = new TestHandle(test); var run = new SingleTestRun(taskFactory, config, overviewLog, handle, cancelToken); - run.Run(); + + runFinishedHandle.Reset(); + run.Run(runFinishedHandle); } } }