Readies k8sCluster class for run against online cluster.

This commit is contained in:
benbierens 2023-05-31 13:50:52 +02:00
parent 3d1d82f582
commit 3ecdce7b07
No known key found for this signature in database
GPG Key ID: FE44815D96D0A1AA
6 changed files with 16 additions and 13 deletions

View File

@ -91,7 +91,7 @@ namespace DistTestCore.Codex
private Http Http(TimeSpan? timeoutOverride = null) private Http Http(TimeSpan? timeoutOverride = null)
{ {
var ip = Container.Pod.Cluster.IP; var ip = Container.Pod.Cluster.HostAddress;
var port = Container.ServicePorts[0].Number; var port = Container.ServicePorts[0].Number;
return new Http(log, timeSet, ip, port, baseUrl: "/api/codex/v1", timeoutOverride); return new Http(log, timeSet, ip, port, baseUrl: "/api/codex/v1", timeoutOverride);
} }

View File

@ -24,6 +24,7 @@ namespace DistTestCore.Codex
AddExposedPortAndVar("API_PORT"); AddExposedPortAndVar("API_PORT");
AddEnvVar("DATA_DIR", $"datadir{ContainerNumber}"); AddEnvVar("DATA_DIR", $"datadir{ContainerNumber}");
AddInternalPortAndVar("DISC_PORT", DiscoveryPortTag); AddInternalPortAndVar("DISC_PORT", DiscoveryPortTag);
AddEnvVar("LOG_LEVEL", config.LogLevel.ToString()!.ToUpperInvariant());
var listenPort = AddInternalPort(); var listenPort = AddInternalPort();
AddEnvVar("LISTEN_ADDRS", $"/ip4/0.0.0.0/tcp/{listenPort.Number}"); AddEnvVar("LISTEN_ADDRS", $"/ip4/0.0.0.0/tcp/{listenPort.Number}");
@ -32,11 +33,6 @@ namespace DistTestCore.Codex
{ {
AddEnvVar("BOOTSTRAP_SPR", config.BootstrapSpr); AddEnvVar("BOOTSTRAP_SPR", config.BootstrapSpr);
} }
if (config.LogLevel != null)
{
AddEnvVar("LOG_LEVEL", config.LogLevel.ToString()!.ToUpperInvariant());
}
if (config.StorageQuota != null) if (config.StorageQuota != null)
{ {
AddEnvVar("STORAGE_QUOTA", config.StorageQuota.SizeInBytes.ToString()!); AddEnvVar("STORAGE_QUOTA", config.StorageQuota.SizeInBytes.ToString()!);

View File

@ -23,7 +23,7 @@ namespace DistTestCore.Marketplace
public NethereumInteraction StartInteraction(BaseLog log) public NethereumInteraction StartInteraction(BaseLog log)
{ {
var ip = RunningContainers.RunningPod.Cluster.IP; var ip = RunningContainers.RunningPod.Cluster.HostAddress;
var port = RunningContainers.Containers[0].ServicePorts[0].Number; var port = RunningContainers.Containers[0].ServicePorts[0].Number;
var account = Account; var account = Account;

View File

@ -17,7 +17,7 @@ namespace DistTestCore.Marketplace
public NethereumInteraction StartInteraction(BaseLog log, GethAccount account) public NethereumInteraction StartInteraction(BaseLog log, GethAccount account)
{ {
var ip = RunningContainer.Pod.Cluster.IP; var ip = RunningContainer.Pod.Cluster.HostAddress;
var port = RunningContainer.ServicePorts[0].Number; var port = RunningContainer.ServicePorts[0].Number;
var privateKey = account.PrivateKey; var privateKey = account.PrivateKey;

View File

@ -16,7 +16,7 @@ namespace DistTestCore.Metrics
http = new Http( http = new Http(
log, log,
timeSet, timeSet,
runningContainers.RunningPod.Cluster.IP, runningContainers.RunningPod.Cluster.HostAddress,
runningContainers.Containers[0].ServicePorts[0].Number, runningContainers.Containers[0].ServicePorts[0].Number,
"api/v1"); "api/v1");
} }

View File

@ -10,12 +10,12 @@ namespace KubernetesWorkflow
} }
public Configuration Configuration { get; } public Configuration Configuration { get; }
public string IP { get; private set; } = string.Empty; public string HostAddress { get; private set; } = string.Empty;
public KubernetesClientConfiguration GetK8sClientConfig() public KubernetesClientConfiguration GetK8sClientConfig()
{ {
var config = GetConfig(); var config = GetConfig();
UpdateIp(config); UpdateHostAddress(config);
return config; return config;
} }
@ -47,10 +47,17 @@ namespace KubernetesWorkflow
} }
} }
private void UpdateIp(KubernetesClientConfiguration config) private void UpdateHostAddress(KubernetesClientConfiguration config)
{ {
var host = config.Host.Replace("https://", ""); var host = config.Host.Replace("https://", "");
IP = host.Substring(0, host.IndexOf(':')); if (host.Contains(":"))
{
HostAddress = host.Substring(0, host.IndexOf(':'));
}
else
{
HostAddress = config.Host;
}
} }
} }
} }