From 4cbd9ac8285f9bbe869722c5b20f34dd1ddd81e8 Mon Sep 17 00:00:00 2001 From: benbierens Date: Tue, 12 Sep 2023 11:37:20 +0200 Subject: [PATCH] workflow creator lifecycle --- CodexPlugin/CodexPlugin.cs | 2 +- DistTestCore/DistTest.cs | 5 +++-- DistTestCore/TestLifecycle.cs | 6 ++++-- 3 files changed, 8 insertions(+), 5 deletions(-) diff --git a/CodexPlugin/CodexPlugin.cs b/CodexPlugin/CodexPlugin.cs index a47f1a5a..2f9c5318 100644 --- a/CodexPlugin/CodexPlugin.cs +++ b/CodexPlugin/CodexPlugin.cs @@ -45,7 +45,7 @@ namespace CodexPlugin public ICodexNodeGroup SetupCodexNodes(int number) { - var rc = StartCodexNodes(1, s => { }); + var rc = StartCodexNodes(number, s => { }); return WrapCodexContainers(rc); } diff --git a/DistTestCore/DistTest.cs b/DistTestCore/DistTest.cs index d5020e28..fb56023e 100644 --- a/DistTestCore/DistTest.cs +++ b/DistTestCore/DistTest.cs @@ -12,6 +12,7 @@ namespace DistTestCore public abstract class DistTest : PluginInterface { private const string TestsType = "dist-tests"; + private const string TestNamespacePrefix = "ct-"; private readonly Configuration configuration = new Configuration(); private readonly Assembly[] testAssemblies; private readonly FixtureLog fixtureLog; @@ -45,7 +46,7 @@ namespace DistTestCore Stopwatch.Measure(fixtureLog, "Global setup", () => { var wc = new WorkflowCreator(fixtureLog, configuration.GetK8sConfiguration(GetTimeSet()), string.Empty); - wc.CreateWorkflow().DeleteNamespace(); + wc.CreateWorkflow().DeleteNamespacesStartingWith(TestNamespacePrefix); }); } catch (Exception ex) @@ -221,7 +222,7 @@ namespace DistTestCore { lock (lifecycleLock) { - var testNamespace = Guid.NewGuid().ToString(); + var testNamespace = TestNamespacePrefix + Guid.NewGuid().ToString(); var lifecycle = new TestLifecycle(fixtureLog.CreateTestLog(), configuration, GetTimeSet(), testNamespace); lifecycles.Add(testName, lifecycle); DefaultContainerRecipe.TestsType = TestsType; diff --git a/DistTestCore/TestLifecycle.cs b/DistTestCore/TestLifecycle.cs index a13dee2e..a075fe55 100644 --- a/DistTestCore/TestLifecycle.cs +++ b/DistTestCore/TestLifecycle.cs @@ -9,6 +9,7 @@ namespace DistTestCore { private readonly PluginManager pluginManager; private readonly DateTime testStart; + private readonly WorkflowCreator workflowCreator; public TestLifecycle(TestLog log, Configuration configuration, ITimeSet timeSet, string testNamespace) { @@ -19,6 +20,8 @@ namespace DistTestCore testStart = DateTime.UtcNow; FileManager = new FileManager(Log, Configuration.GetFileManagerFolder()); + workflowCreator = new WorkflowCreator(Log, Configuration.GetK8sConfiguration(TimeSet), TestNamespace); + pluginManager = new PluginManager(); pluginManager.DiscoverPlugins(); pluginManager.InitializePlugins(this); @@ -50,8 +53,7 @@ namespace DistTestCore public IStartupWorkflow CreateWorkflow(string? namespaceOverride = null) { if (namespaceOverride != null) throw new Exception("Namespace override is not supported in the DistTest environment. (It would mess up automatic resource cleanup.)"); - var wc = new WorkflowCreator(Log, Configuration.GetK8sConfiguration(TimeSet), TestNamespace); - return wc.CreateWorkflow(); + return workflowCreator.CreateWorkflow(); } public IFileManager GetFileManager()