Adds filter option for selecting tests. Adds cleanup option for deleting deployment namespace.
This commit is contained in:
parent
b96751cd2c
commit
6fe9d38eb3
|
@ -27,6 +27,12 @@ namespace ContinuousTests
|
||||||
[Uniform("target-duration", "td", "TARGETDURATION", false, "If greater than zero, runner will run for this many seconds before stopping.")]
|
[Uniform("target-duration", "td", "TARGETDURATION", false, "If greater than zero, runner will run for this many seconds before stopping.")]
|
||||||
public int TargetDurationSeconds { get; set; } = 0;
|
public int TargetDurationSeconds { get; set; } = 0;
|
||||||
|
|
||||||
|
[Uniform("filter", "f", "FILTER", false, "If set, runs only tests whose names contain any of the filter strings. Comma-separated. Case sensitive.")]
|
||||||
|
public string Filter { get; set; } = string.Empty;
|
||||||
|
|
||||||
|
[Uniform("cleanup", "cl", "CLEANUP", false, "If set, the kubernetes namespace will be deleted after the test run has finished.")]
|
||||||
|
public bool Cleanup { get; set; } = false;
|
||||||
|
|
||||||
public CodexDeployment CodexDeployment { get; set; } = null!;
|
public CodexDeployment CodexDeployment { get; set; } = null!;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -46,7 +46,13 @@ namespace ContinuousTests
|
||||||
|
|
||||||
ClearAllCustomNamespaces(allTests, overviewLog);
|
ClearAllCustomNamespaces(allTests, overviewLog);
|
||||||
|
|
||||||
var testLoops = allTests.Select(t => new TestLoop(entryPointFactory, taskFactory, config, overviewLog, t.GetType(), t.RunTestEvery, startupChecker, cancelToken)).ToArray();
|
var filteredTests = FilterTests(allTests, overviewLog);
|
||||||
|
if (!filteredTests.Any())
|
||||||
|
{
|
||||||
|
overviewLog.Log("No tests selected.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
var testLoops = filteredTests.Select(t => new TestLoop(entryPointFactory, taskFactory, config, overviewLog, t.GetType(), t.RunTestEvery, startupChecker, cancelToken)).ToArray();
|
||||||
|
|
||||||
foreach (var testLoop in testLoops)
|
foreach (var testLoop in testLoops)
|
||||||
{
|
{
|
||||||
|
@ -62,6 +68,24 @@ namespace ContinuousTests
|
||||||
overviewLog.Log("Cancelling all test-loops...");
|
overviewLog.Log("Cancelling all test-loops...");
|
||||||
taskFactory.WaitAll();
|
taskFactory.WaitAll();
|
||||||
overviewLog.Log("All tasks cancelled.");
|
overviewLog.Log("All tasks cancelled.");
|
||||||
|
|
||||||
|
PerformCleanup(overviewLog);
|
||||||
|
}
|
||||||
|
|
||||||
|
private ContinuousTest[] FilterTests(ContinuousTest[] allTests, ILog log)
|
||||||
|
{
|
||||||
|
log.Log($"Available tests: {string.Join(", ", allTests.Select(r => r.Name))}");
|
||||||
|
|
||||||
|
var result = allTests.ToArray();
|
||||||
|
var filters = config.Filter.Split(",", StringSplitOptions.RemoveEmptyEntries);
|
||||||
|
if (filters.Any())
|
||||||
|
{
|
||||||
|
log.Log($"Applying filters: {string.Join(", ", filters)}");
|
||||||
|
result = allTests.Where(t => filters.Any(f => t.Name.Contains(f))).ToArray();
|
||||||
|
}
|
||||||
|
|
||||||
|
log.Log($"Selected for running: {string.Join(", ", result.Select(r => r.Name))}");
|
||||||
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void WaitUntilFinished(LogSplitter overviewLog, StatusLog statusLog, DateTime startTime, TestLoop[] testLoops)
|
private void WaitUntilFinished(LogSplitter overviewLog, StatusLog statusLog, DateTime startTime, TestLoop[] testLoops)
|
||||||
|
@ -107,5 +131,15 @@ namespace ContinuousTests
|
||||||
var entryPoint = entryPointFactory.CreateEntryPoint(config.KubeConfigFile, config.DataPath, test.CustomK8sNamespace, log);
|
var entryPoint = entryPointFactory.CreateEntryPoint(config.KubeConfigFile, config.DataPath, test.CustomK8sNamespace, log);
|
||||||
entryPoint.Tools.CreateWorkflow().DeleteNamespacesStartingWith(test.CustomK8sNamespace);
|
entryPoint.Tools.CreateWorkflow().DeleteNamespacesStartingWith(test.CustomK8sNamespace);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void PerformCleanup(ILog log)
|
||||||
|
{
|
||||||
|
if (!config.Cleanup) return;
|
||||||
|
log.Log("Cleaning up test namespace...");
|
||||||
|
|
||||||
|
var entryPoint = entryPointFactory.CreateEntryPoint(config.KubeConfigFile, config.DataPath, config.CodexDeployment.Metadata.KubeNamespace, log);
|
||||||
|
entryPoint.Decommission(deleteKubernetesResources: true, deleteTrackedFiles: true);
|
||||||
|
log.Log("Cleanup finished.");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,6 +2,7 @@
|
||||||
using Core;
|
using Core;
|
||||||
using DistTestCore.Logs;
|
using DistTestCore.Logs;
|
||||||
using Logging;
|
using Logging;
|
||||||
|
using Newtonsoft.Json;
|
||||||
|
|
||||||
namespace ContinuousTests
|
namespace ContinuousTests
|
||||||
{
|
{
|
||||||
|
@ -45,6 +46,7 @@ namespace ContinuousTests
|
||||||
foreach (var vars in codexVars) log.Log(vars.ToString());
|
foreach (var vars in codexVars) log.Log(vars.ToString());
|
||||||
log.Log("");
|
log.Log("");
|
||||||
}
|
}
|
||||||
|
log.Log($"Deployment metadata: {JsonConvert.SerializeObject(deployment.Metadata)}");
|
||||||
log.Log("");
|
log.Log("");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue