diff --git a/CodexNetDeployer/Deployer.cs b/CodexNetDeployer/Deployer.cs index 32e08c7..a5e174e 100644 --- a/CodexNetDeployer/Deployer.cs +++ b/CodexNetDeployer/Deployer.cs @@ -72,7 +72,7 @@ namespace CodexNetDeployer k8sNamespacePrefix: config.KubeNamespace ); - return new TestLifecycle(log, lifecycleConfig, timeset, config.TestsTypePodLabel); + return new TestLifecycle(log, lifecycleConfig, timeset, config.TestsTypePodLabel, string.Empty); } private RunningContainer? StartMetricsService(TestLifecycle lifecycle, CodexSetup setup, List codexContainers) diff --git a/ContinuousTests/K8sFactory.cs b/ContinuousTests/K8sFactory.cs index 5627941..ff9b7e9 100644 --- a/ContinuousTests/K8sFactory.cs +++ b/ContinuousTests/K8sFactory.cs @@ -20,7 +20,7 @@ namespace ContinuousTests k8sNamespacePrefix: customNamespace ); - return new TestLifecycle(log, lifecycleConfig, timeSet, "continuous-tests"); + return new TestLifecycle(log, lifecycleConfig, timeSet, "continuous-tests", string.Empty); } private static string? GetKubeConfig(string kubeConfigFile) diff --git a/DistTestCore/DistTest.cs b/DistTestCore/DistTest.cs index 48ae884..a38377d 100644 --- a/DistTestCore/DistTest.cs +++ b/DistTestCore/DistTest.cs @@ -53,7 +53,7 @@ namespace DistTestCore { Stopwatch.Measure(fixtureLog, "Global setup", () => { - var wc = new WorkflowCreator(fixtureLog, configuration.GetK8sConfiguration(GetTimeSet()), new PodLabels(TestsType, "null")); + var wc = new WorkflowCreator(fixtureLog, configuration.GetK8sConfiguration(GetTimeSet()), new PodLabels(TestsType, null!), string.Empty); wc.CreateWorkflow().DeleteAllResources(); }); } @@ -196,7 +196,9 @@ namespace DistTestCore { lock (lifecycleLock) { - lifecycles.Add(testName, new TestLifecycle(fixtureLog.CreateTestLog(), configuration, GetTimeSet(), TestsType)); + var testNamespace = Guid.NewGuid().ToString(); + var lifecycle = new TestLifecycle(fixtureLog.CreateTestLog(), configuration, GetTimeSet(), TestsType, testNamespace); + lifecycles.Add(testName, lifecycle); } }); } @@ -207,7 +209,7 @@ namespace DistTestCore var testResult = GetTestResult(); var testDuration = lifecycle.GetTestDuration(); fixtureLog.Log($"{GetCurrentTestName()} = {testResult} ({testDuration})"); - statusLog.ConcludeTest(testResult, testDuration, lifecycle.GetCodexId()); + statusLog.ConcludeTest(testResult, testDuration, lifecycle.GetApplicationIds()); Stopwatch.Measure(fixtureLog, $"Teardown for {GetCurrentTestName()}", () => { lifecycle.Log.EndTest(); diff --git a/DistTestCore/TestLifecycle.cs b/DistTestCore/TestLifecycle.cs index cc98ec5..eede32d 100644 --- a/DistTestCore/TestLifecycle.cs +++ b/DistTestCore/TestLifecycle.cs @@ -1,5 +1,7 @@ using DistTestCore.Codex; using DistTestCore.Logs; +using DistTestCore.Marketplace; +using DistTestCore.Metrics; using KubernetesWorkflow; using Logging; using Utils; @@ -10,14 +12,14 @@ namespace DistTestCore { private readonly DateTime testStart; - public TestLifecycle(BaseLog log, Configuration configuration, ITimeSet timeSet, string testsType) + public TestLifecycle(BaseLog log, Configuration configuration, ITimeSet timeSet, string testsType, string testNamespace) { Log = log; Configuration = configuration; TimeSet = timeSet; - var podLabels = new PodLabels(testsType, GetCodexId()); - WorkflowCreator = new WorkflowCreator(log, configuration.GetK8sConfiguration(timeSet), podLabels); + var podLabels = new PodLabels(testsType, GetApplicationIds()); + WorkflowCreator = new WorkflowCreator(log, configuration.GetK8sConfiguration(timeSet), podLabels, testNamespace); FileManager = new FileManager(Log, configuration); CodexStarter = new CodexStarter(this); @@ -68,7 +70,17 @@ namespace DistTestCore if (CodexVersion == null) CodexVersion = version; } - public string GetCodexId() + public ApplicationIds GetApplicationIds() + { + return new ApplicationIds( + codexId: GetCodexId(), + gethId: new GethContainerRecipe().Image, + prometheusId: new PrometheusContainerRecipe().Image, + codexContractsId: new CodexContractsContainerRecipe().Image + ); + } + + private string GetCodexId() { var v = CodexVersion; if (v == null) return new CodexContainerRecipe().Image; diff --git a/KubernetesWorkflow/PodLabels.cs b/KubernetesWorkflow/PodLabels.cs index e73a348..60fc332 100644 --- a/KubernetesWorkflow/PodLabels.cs +++ b/KubernetesWorkflow/PodLabels.cs @@ -11,15 +11,20 @@ namespace KubernetesWorkflow labels = source.labels.ToDictionary(p => p.Key, p => p.Value); } - public PodLabels(string testsType, string codexId) + public PodLabels(string testsType, ApplicationIds applicationIds) { Add("tests-type", testsType); Add("runid", NameUtils.GetRunId()); Add("testid", NameUtils.GetTestId()); Add("category", NameUtils.GetCategoryName()); - Add("codexid", codexId); Add("fixturename", NameUtils.GetRawFixtureName()); Add("testname", NameUtils.GetTestMethodName()); + + if (applicationIds == null) return; + Add("codexid", applicationIds.CodexId); + Add("gethid", applicationIds.GethId); + Add("prometheusid", applicationIds.PrometheusId); + Add("codexcontractsid", applicationIds.CodexContractsId); } public PodLabels GetLabelsForAppName(string appName) diff --git a/KubernetesWorkflow/WorkflowCreator.cs b/KubernetesWorkflow/WorkflowCreator.cs index afc515f..4e1c346 100644 --- a/KubernetesWorkflow/WorkflowCreator.cs +++ b/KubernetesWorkflow/WorkflowCreator.cs @@ -13,12 +13,12 @@ namespace KubernetesWorkflow private readonly PodLabels podLabels; private readonly string testNamespace; - public WorkflowCreator(BaseLog log, Configuration configuration, PodLabels podLabels) + public WorkflowCreator(BaseLog log, Configuration configuration, PodLabels podLabels, string testNamespace) { cluster = new K8sCluster(configuration); this.log = log; this.podLabels = podLabels; - testNamespace = Guid.NewGuid().ToString().ToLowerInvariant(); + this.testNamespace = testNamespace.ToLowerInvariant(); } public StartupWorkflow CreateWorkflow() diff --git a/Logging/ApplicationIds.cs b/Logging/ApplicationIds.cs new file mode 100644 index 0000000..d52dc10 --- /dev/null +++ b/Logging/ApplicationIds.cs @@ -0,0 +1,18 @@ +namespace Logging +{ + public class ApplicationIds + { + public ApplicationIds(string codexId, string gethId, string prometheusId, string codexContractsId) + { + CodexId = codexId; + GethId = gethId; + PrometheusId = prometheusId; + CodexContractsId = codexContractsId; + } + + public string CodexId { get; } + public string GethId { get; } + public string PrometheusId { get; } + public string CodexContractsId { get; } + } +} diff --git a/Logging/StatusLog.cs b/Logging/StatusLog.cs index f0a366b..96a8cc2 100644 --- a/Logging/StatusLog.cs +++ b/Logging/StatusLog.cs @@ -14,7 +14,7 @@ namespace Logging fixtureName = NameUtils.GetRawFixtureName(); } - public void ConcludeTest(string resultStatus, string testDuration, string codexId) + public void ConcludeTest(string resultStatus, string testDuration, ApplicationIds applicationIds) { Write(new StatusLogJson { @@ -22,7 +22,10 @@ namespace Logging runid = NameUtils.GetRunId(), status = resultStatus, testid = NameUtils.GetTestId(), - codexid = codexId, + codexid = applicationIds.CodexId, + gethid = applicationIds.GethId, + prometheusid = applicationIds.PrometheusId, + codexcontractsid = applicationIds.CodexContractsId, category = NameUtils.GetCategoryName(), fixturename = fixtureName, testname = NameUtils.GetTestMethodName(), @@ -53,6 +56,9 @@ namespace Logging public string status { get; set; } = string.Empty; public string testid { get; set; } = string.Empty; public string codexid { get; set; } = string.Empty; + public string gethid { get; set; } = string.Empty; + public string prometheusid { get; set; } = string.Empty; + public string codexcontractsid { get; set; } = string.Empty; public string category { get; set; } = string.Empty; public string fixturename { get; set; } = string.Empty; public string testname { get; set; } = string.Empty;