Adds option to declare validators.

This commit is contained in:
benbierens 2023-06-22 15:58:18 +02:00
parent cd69565c2e
commit f242ad5a16
No known key found for this signature in database
GPG Key ID: FE44815D96D0A1AA
7 changed files with 30 additions and 5 deletions

View File

@ -8,6 +8,7 @@
public static readonly ArgVar KubeConfigFile = new ArgVar("kube-config", "KUBECONFIG", "Path to Kubeconfig file.");
public static readonly ArgVar KubeNamespace = new ArgVar("kube-namespace", "KUBENAMESPACE", "Kubernetes namespace to be used for deployment.");
public static readonly ArgVar NumberOfCodexNodes = new ArgVar("nodes", "NODES", "Number of Codex nodes to be created.");
public static readonly ArgVar NumberOfValidatorNodes = new ArgVar("validators", "VALIDATORS", "Number of Codex nodes that will be validating.");
public static readonly ArgVar StorageQuota = new ArgVar("storage-quota", "STORAGEQUOTA", "Storage quota in megabytes used by each Codex node.");
public static readonly ArgVar LogLevel = new ArgVar("log-level", "LOGLEVEL", "Log level used by each Codex node. [Trace, Debug*, Info, Warn, Error]");

View File

@ -12,6 +12,7 @@ namespace CodexNetDeployer
string kubeConfigFile,
string kubeNamespace,
int? numberOfCodexNodes,
int? numberOfValidators,
int? storageQuota,
CodexLogLevel codexLogLevel,
TestRunnerLocation runnerLocation)
@ -22,6 +23,7 @@ namespace CodexNetDeployer
KubeConfigFile = kubeConfigFile;
KubeNamespace = kubeNamespace;
NumberOfCodexNodes = numberOfCodexNodes;
NumberOfValidators = numberOfValidators;
StorageQuota = storageQuota;
CodexLogLevel = codexLogLevel;
RunnerLocation = runnerLocation;
@ -33,6 +35,7 @@ namespace CodexNetDeployer
public string KubeConfigFile { get; }
public string KubeNamespace { get; }
public int? NumberOfCodexNodes { get; }
public int? NumberOfValidators { get; }
public int? StorageQuota { get; }
public CodexLogLevel CodexLogLevel { get; }
public TestRunnerLocation RunnerLocation { get; }
@ -50,6 +53,11 @@ namespace CodexNetDeployer
onString: (n, v) => StringIsSet(n, v, errors),
onInt: (n, v) => IntIsOverZero(n, v, errors));
if (NumberOfValidators > NumberOfCodexNodes)
{
errors.Add($"{nameof(NumberOfValidators)} ({NumberOfValidators}) may not be greater than {nameof(NumberOfCodexNodes)} ({NumberOfCodexNodes}).");
}
return errors;
}

View File

@ -39,16 +39,16 @@ namespace CodexNetDeployer
// Each node must have its own IP, so it needs it own pod. Start them 1 at a time.
var bootstrapSpr = ""; // The first one will be used to bootstrap the others.
int validatorsLeft = config.NumberOfValidators!.Value;
for (var i = 0; i < config.NumberOfCodexNodes; i++)
{
Console.Write($" - {i} = ");
var workflow = workflowCreator.CreateWorkflow();
var workflowStartup = new StartupConfig();
var codexStart = new CodexStartupConfig(config.CodexLogLevel);
workflowStartup.Add(codexStart);
if (!string.IsNullOrEmpty(bootstrapSpr)) codexStart.BootstrapSpr = bootstrapSpr;
codexStart.StorageQuota = config.StorageQuota.Value.MB();
var marketplaceConfig = new MarketplaceInitialConfig(100000.Eth(), 0.TestTokens());
var marketplaceConfig = new MarketplaceInitialConfig(100000.Eth(), 0.TestTokens(), validatorsLeft > 0);
marketplaceConfig.AccountIndexOverride = i;
codexStart.MarketplaceConfig = marketplaceConfig;
workflowStartup.Add(gethResults);
@ -66,6 +66,7 @@ namespace CodexNetDeployer
Console.Write($"Online ({pod.Name} at {pod.Ip} on '{pod.K8SNodeName}'" + Environment.NewLine);
if (string.IsNullOrEmpty(bootstrapSpr)) bootstrapSpr = debugInfo.spr;
validatorsLeft--;
}
else
{

View File

@ -13,7 +13,8 @@ public class Program
{
@"--kube-config=C:\Users\Ben\.kube\codex-tests-ams3-dev-kubeconfig.yaml",
"--kube-namespace=testing-deployer",
"--nodes=3",
"--nodes=5",
"--validators=3",
"--storage-quota=1024"
};
@ -41,6 +42,7 @@ public class Program
kubeConfigFile: argOrVar.Get(ArgOrVar.KubeConfigFile),
kubeNamespace: argOrVar.Get(ArgOrVar.KubeNamespace),
numberOfCodexNodes: argOrVar.GetInt(ArgOrVar.NumberOfCodexNodes),
numberOfValidators: argOrVar.GetInt(ArgOrVar.NumberOfValidatorNodes),
storageQuota: argOrVar.GetInt(ArgOrVar.StorageQuota),
codexLogLevel: ParseEnum.Parse<CodexLogLevel>(argOrVar.Get(ArgOrVar.LogLevel, nameof(CodexLogLevel.Debug))),
runnerLocation: location

View File

@ -60,6 +60,11 @@ namespace DistTestCore.Codex
AddEnvVar("ETH_ACCOUNT", companionNodeAccount.Account);
AddEnvVar("ETH_MARKETPLACE_ADDRESS", gethConfig.MarketplaceNetwork.Marketplace.Address);
AddEnvVar("PERSISTENCE", "1");
if (config.MarketplaceConfig.IsValidator)
{
AddEnvVar("VALIDATOR", "1");
}
}
}

View File

@ -13,6 +13,7 @@ namespace DistTestCore
ICodexSetup EnableMetrics();
ICodexSetup EnableMarketplace(TestToken initialBalance);
ICodexSetup EnableMarketplace(TestToken initialBalance, Ether initialEther);
ICodexSetup EnableMarketplace(TestToken initialBalance, Ether initialEther, bool isValidator);
}
public class CodexSetup : CodexStartupConfig, ICodexSetup
@ -62,7 +63,12 @@ namespace DistTestCore
public ICodexSetup EnableMarketplace(TestToken initialBalance, Ether initialEther)
{
MarketplaceConfig = new MarketplaceInitialConfig(initialEther, initialBalance);
return EnableMarketplace(initialBalance, initialEther, false);
}
public ICodexSetup EnableMarketplace(TestToken initialBalance, Ether initialEther, bool isValidator)
{
MarketplaceConfig = new MarketplaceInitialConfig(initialEther, initialBalance, isValidator);
return this;
}

View File

@ -2,14 +2,16 @@
{
public class MarketplaceInitialConfig
{
public MarketplaceInitialConfig(Ether initialEth, TestToken initialTestTokens)
public MarketplaceInitialConfig(Ether initialEth, TestToken initialTestTokens, bool isValidator)
{
InitialEth = initialEth;
InitialTestTokens = initialTestTokens;
IsValidator = isValidator;
}
public Ether InitialEth { get; }
public TestToken InitialTestTokens { get; }
public bool IsValidator { get; }
public int? AccountIndexOverride { get; set; }
}
}