Fixes port clashes for multiple geth nodes per pod
This commit is contained in:
parent
ab8318e102
commit
230f9f3bd0
|
@ -96,6 +96,7 @@ namespace CodexDistTestCore
|
|||
servicePort: groupContainerFactory.GetNextServicePort(),
|
||||
servicePortName: groupContainerFactory.GetNextServicePortName(),
|
||||
apiPort: codexPortSource.GetNextNumber(),
|
||||
rpcPort: codexPortSource.GetNextNumber(),
|
||||
containerPortName: $"geth-{n}"
|
||||
);
|
||||
}
|
||||
|
|
|
@ -4,12 +4,13 @@ namespace CodexDistTestCore.Marketplace
|
|||
{
|
||||
public class GethCompanionNodeContainer
|
||||
{
|
||||
public GethCompanionNodeContainer(string name, int servicePort, string servicePortName, int apiPort, string containerPortName)
|
||||
public GethCompanionNodeContainer(string name, int servicePort, string servicePortName, int apiPort, int rpcPort, string containerPortName)
|
||||
{
|
||||
Name = name;
|
||||
ServicePort = servicePort;
|
||||
ServicePortName = servicePortName;
|
||||
ApiPort = apiPort;
|
||||
RpcPort = rpcPort;
|
||||
ContainerPortName = containerPortName;
|
||||
}
|
||||
|
||||
|
@ -17,6 +18,7 @@ namespace CodexDistTestCore.Marketplace
|
|||
public int ServicePort { get; }
|
||||
public string ServicePortName { get; }
|
||||
public int ApiPort { get; }
|
||||
public int RpcPort { get; }
|
||||
public string ContainerPortName { get; }
|
||||
|
||||
public V1Container CreateDeploymentContainer(GethInfo gethInfo)
|
||||
|
@ -34,7 +36,19 @@ namespace CodexDistTestCore.Marketplace
|
|||
}
|
||||
},
|
||||
// todo: use env vars to connect this node to the bootstrap node provided by gethInfo.podInfo & gethInfo.servicePort & gethInfo.genesisJsonBase64
|
||||
//Env = dockerImage.CreateEnvironmentVariables(offline, container)
|
||||
Env = new List<V1EnvVar>
|
||||
{
|
||||
new V1EnvVar
|
||||
{
|
||||
Name = "GETH_ARGS",
|
||||
Value = $"--port {ApiPort} --discovery.port {ApiPort} --authrpc.port {RpcPort}"
|
||||
},
|
||||
new V1EnvVar
|
||||
{
|
||||
Name = "GENESIS_JSON",
|
||||
Value = gethInfo.GenesisJsonBase64
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
@ -31,8 +31,12 @@ namespace CodexDistTestCore.Marketplace
|
|||
|
||||
private void ExtractAccountAndGenesisJson()
|
||||
{
|
||||
bootstrapAccount = ExecuteCommand("cat", "account_string.txt");
|
||||
bootstrapGenesisJson = ExecuteCommand("cat", "genesis.json");
|
||||
FetchAccountAndGenesisJson();
|
||||
if (string.IsNullOrEmpty(bootstrapAccount) || string.IsNullOrEmpty(bootstrapGenesisJson))
|
||||
{
|
||||
Thread.Sleep(TimeSpan.FromSeconds(15));
|
||||
FetchAccountAndGenesisJson();
|
||||
}
|
||||
|
||||
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.");
|
||||
|
@ -40,6 +44,12 @@ namespace CodexDistTestCore.Marketplace
|
|||
gethBootstrapNode!.GenesisJsonBase64 = Convert.ToBase64String(Encoding.ASCII.GetBytes(bootstrapGenesisJson));
|
||||
}
|
||||
|
||||
private void FetchAccountAndGenesisJson()
|
||||
{
|
||||
bootstrapAccount = ExecuteCommand("cat", "account_string.txt");
|
||||
bootstrapGenesisJson = ExecuteCommand("cat", "genesis.json");
|
||||
}
|
||||
|
||||
private string ExecuteCommand(string command, params string[] arguments)
|
||||
{
|
||||
return k8sManager.ExecuteCommand(gethBootstrapNode!.Pod, K8sGethBoostrapSpecs.ContainerName, command, arguments);
|
||||
|
|
|
@ -34,7 +34,7 @@ namespace Tests.BasicTests
|
|||
[Test]
|
||||
public void MarketplaceExample()
|
||||
{
|
||||
var primary = SetupCodexNodes(1)
|
||||
var primary = SetupCodexNodes(4)
|
||||
.WithStorageQuota(10.GB())
|
||||
.EnableMarketplace(initialBalance: 20)
|
||||
.BringOnline()[0];
|
||||
|
|
Loading…
Reference in New Issue