Sets up bootstrap geth node

This commit is contained in:
benbierens 2023-04-10 14:00:12 +02:00
parent 2f694bac8d
commit e800197cdd
No known key found for this signature in database
GPG Key ID: FE44815D96D0A1AA
4 changed files with 41 additions and 11 deletions

View File

@ -89,7 +89,9 @@ namespace CodexDistTestCore
public PodInfo BringOnlineGethBootstrapNode() public PodInfo BringOnlineGethBootstrapNode()
{ {
return K8s(k => k.BringOnlineGethBootstrapNode()); var spec = new K8sGethBoostrapSpecs(codexGroupNumberSource.GetNextServicePort());
return K8s(k => k.BringOnlineGethBootstrapNode(spec));
} }
public void DownloadAllMetrics() public void DownloadAllMetrics()

View File

@ -1,4 +1,5 @@
using CodexDistTestCore.Config; using CodexDistTestCore.Config;
using CodexDistTestCore.Marketplace;
using CodexDistTestCore.Metrics; using CodexDistTestCore.Metrics;
using k8s; using k8s;
using k8s.KubeConfigModels; using k8s.KubeConfigModels;
@ -78,12 +79,15 @@ namespace CodexDistTestCore
return new PrometheusInfo(spec.ServicePort, FetchNewPod()); return new PrometheusInfo(spec.ServicePort, FetchNewPod());
} }
public PodInfo BringOnlineGethBootstrapNode() public PodInfo BringOnlineGethBootstrapNode(K8sGethBoostrapSpecs spec)
{ {
EnsureTestNamespace(); EnsureTestNamespace();
return FetchNewPod(); CreateGethBootstrapDeployment(spec);
CreateGethBootstrapService(spec);
WaitUntilGethBootstrapOnline(spec);
return FetchNewPod();
} }
private void FetchPodInfo(CodexNodeGroup online) private void FetchPodInfo(CodexNodeGroup online)
@ -140,7 +144,16 @@ namespace CodexDistTestCore
private void WaitUntilPrometheusOnline(K8sPrometheusSpecs spec) 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(() => WaitUntil(() =>
{ {
var deployment = client.ReadNamespacedDeployment(deploymentName, K8sNamespace); var deployment = client.ReadNamespacedDeployment(deploymentName, K8sNamespace);
@ -216,6 +229,11 @@ namespace CodexDistTestCore
client.CreateNamespacedService(spec.CreatePrometheusService(), K8sNamespace); client.CreateNamespacedService(spec.CreatePrometheusService(), K8sNamespace);
} }
private void CreateGethBootstrapService(K8sGethBoostrapSpecs spec)
{
client.CreateNamespacedService(spec.CreateGethBootstrapService(), K8sNamespace);
}
#endregion #endregion
#region Deployment management #region Deployment management
@ -298,6 +316,11 @@ namespace CodexDistTestCore
client.CreateNamespacedDeployment(spec.CreatePrometheusDeployment(), K8sNamespace); client.CreateNamespacedDeployment(spec.CreatePrometheusDeployment(), K8sNamespace);
} }
private void CreateGethBootstrapDeployment(K8sGethBoostrapSpecs spec)
{
client.CreateNamespacedDeployment(spec.CreateGethBootstrapDeployment(), K8sNamespace);
}
#endregion #endregion
#region Namespace management #region Namespace management

View File

@ -63,14 +63,14 @@ namespace CodexDistTestCore.Marketplace
}, },
Env = new List<V1EnvVar> Env = new List<V1EnvVar>
{ {
//new V1EnvVar
//{
// Name = "GETH_ARGS",
// Value = "--qwerty"
//},
new V1EnvVar new V1EnvVar
{ {
Name = "GETH_ARGS", Name = "GENESIS_JSON",
Value = "--qwerty"
},
new V1EnvVar
{
Name = "GENSIS_JSON",
Value = genesisJsonBase64 Value = genesisJsonBase64
}, },
new V1EnvVar new V1EnvVar

View File

@ -1,4 +1,6 @@
namespace CodexDistTestCore.Marketplace using NUnit.Framework;
namespace CodexDistTestCore.Marketplace
{ {
public class MarketplaceController public class MarketplaceController
{ {
@ -28,6 +30,9 @@
{ {
bootstrapAccount = ExecuteCommand("cat", "account_string.txt"); bootstrapAccount = ExecuteCommand("cat", "account_string.txt");
bootstrapGenesisJson = ExecuteCommand("cat", "genesis.json"); 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) private string ExecuteCommand(string command, params string[] arguments)