From e800197cdd6af66dc7efd0246043a147649860dc Mon Sep 17 00:00:00 2001 From: benbierens Date: Mon, 10 Apr 2023 14:00:12 +0200 Subject: [PATCH] Sets up bootstrap geth node --- CodexDistTestCore/K8sManager.cs | 4 ++- CodexDistTestCore/K8sOperations.cs | 29 +++++++++++++++++-- CodexDistTestCore/Marketplace/K8sGethSpecs.cs | 12 ++++---- .../Marketplace/MarketplaceController.cs | 7 ++++- 4 files changed, 41 insertions(+), 11 deletions(-) diff --git a/CodexDistTestCore/K8sManager.cs b/CodexDistTestCore/K8sManager.cs index d10f8ea..635a8fe 100644 --- a/CodexDistTestCore/K8sManager.cs +++ b/CodexDistTestCore/K8sManager.cs @@ -89,7 +89,9 @@ namespace CodexDistTestCore public PodInfo BringOnlineGethBootstrapNode() { - return K8s(k => k.BringOnlineGethBootstrapNode()); + var spec = new K8sGethBoostrapSpecs(codexGroupNumberSource.GetNextServicePort()); + + return K8s(k => k.BringOnlineGethBootstrapNode(spec)); } public void DownloadAllMetrics() diff --git a/CodexDistTestCore/K8sOperations.cs b/CodexDistTestCore/K8sOperations.cs index 576495c..86ab636 100644 --- a/CodexDistTestCore/K8sOperations.cs +++ b/CodexDistTestCore/K8sOperations.cs @@ -1,4 +1,5 @@ using CodexDistTestCore.Config; +using CodexDistTestCore.Marketplace; using CodexDistTestCore.Metrics; using k8s; using k8s.KubeConfigModels; @@ -78,12 +79,15 @@ namespace CodexDistTestCore return new PrometheusInfo(spec.ServicePort, FetchNewPod()); } - public PodInfo BringOnlineGethBootstrapNode() + public PodInfo BringOnlineGethBootstrapNode(K8sGethBoostrapSpecs spec) { EnsureTestNamespace(); - return FetchNewPod(); + CreateGethBootstrapDeployment(spec); + CreateGethBootstrapService(spec); + WaitUntilGethBootstrapOnline(spec); + return FetchNewPod(); } private void FetchPodInfo(CodexNodeGroup online) @@ -140,7 +144,16 @@ namespace CodexDistTestCore private void WaitUntilPrometheusOnline(K8sPrometheusSpecs spec) { - var deploymentName = spec.GetDeploymentName(); + WaitUntilDeploymentOnline(spec.GetDeploymentName()); + } + + private void WaitUntilGethBootstrapOnline(K8sGethBoostrapSpecs spec) + { + WaitUntilDeploymentOnline(spec.GetDeploymentName()); + } + + private void WaitUntilDeploymentOnline(string deploymentName) + { WaitUntil(() => { var deployment = client.ReadNamespacedDeployment(deploymentName, K8sNamespace); @@ -216,6 +229,11 @@ namespace CodexDistTestCore client.CreateNamespacedService(spec.CreatePrometheusService(), K8sNamespace); } + private void CreateGethBootstrapService(K8sGethBoostrapSpecs spec) + { + client.CreateNamespacedService(spec.CreateGethBootstrapService(), K8sNamespace); + } + #endregion #region Deployment management @@ -298,6 +316,11 @@ namespace CodexDistTestCore client.CreateNamespacedDeployment(spec.CreatePrometheusDeployment(), K8sNamespace); } + private void CreateGethBootstrapDeployment(K8sGethBoostrapSpecs spec) + { + client.CreateNamespacedDeployment(spec.CreateGethBootstrapDeployment(), K8sNamespace); + } + #endregion #region Namespace management diff --git a/CodexDistTestCore/Marketplace/K8sGethSpecs.cs b/CodexDistTestCore/Marketplace/K8sGethSpecs.cs index 3485ddc..0682b49 100644 --- a/CodexDistTestCore/Marketplace/K8sGethSpecs.cs +++ b/CodexDistTestCore/Marketplace/K8sGethSpecs.cs @@ -63,14 +63,14 @@ namespace CodexDistTestCore.Marketplace }, Env = new List { + //new V1EnvVar + //{ + // Name = "GETH_ARGS", + // Value = "--qwerty" + //}, new V1EnvVar { - Name = "GETH_ARGS", - Value = "--qwerty" - }, - new V1EnvVar - { - Name = "GENSIS_JSON", + Name = "GENESIS_JSON", Value = genesisJsonBase64 }, new V1EnvVar diff --git a/CodexDistTestCore/Marketplace/MarketplaceController.cs b/CodexDistTestCore/Marketplace/MarketplaceController.cs index d0f5947..38b5ad1 100644 --- a/CodexDistTestCore/Marketplace/MarketplaceController.cs +++ b/CodexDistTestCore/Marketplace/MarketplaceController.cs @@ -1,4 +1,6 @@ -namespace CodexDistTestCore.Marketplace +using NUnit.Framework; + +namespace CodexDistTestCore.Marketplace { public class MarketplaceController { @@ -28,6 +30,9 @@ { bootstrapAccount = ExecuteCommand("cat", "account_string.txt"); bootstrapGenesisJson = ExecuteCommand("cat", "genesis.json"); + + Assert.That(bootstrapAccount, Is.Not.Empty, "Unable to fetch account for bootstrap geth node. Test infra failure."); + Assert.That(bootstrapGenesisJson, Is.Not.Empty, "Unable to fetch genesis-json for bootstrap geth node. Test infra failure."); } private string ExecuteCommand(string command, params string[] arguments)