cleanup config
This commit is contained in:
parent
3359b10929
commit
107bb0f76b
|
@ -1,37 +1,39 @@
|
||||||
using k8s;
|
using k8s;
|
||||||
using NUnit.Framework;
|
|
||||||
|
|
||||||
namespace CodexDistTestCore.Config
|
namespace CodexDistTestCore.Config
|
||||||
{
|
{
|
||||||
public class K8sCluster
|
public class K8sCluster
|
||||||
{
|
{
|
||||||
public const string K8sNamespace = "codex-test-namespace";
|
public const string K8sNamespace = "codex-test-namespace";
|
||||||
|
private const string KubeConfigFile = "C:\\kube\\config";
|
||||||
|
private readonly Dictionary<Location, string> K8sNodeLocationMap = new Dictionary<Location, string>
|
||||||
|
{
|
||||||
|
{ Location.BensLaptop, "worker01" },
|
||||||
|
{ Location.BensOldGamingMachine, "worker02" },
|
||||||
|
};
|
||||||
|
|
||||||
|
private KubernetesClientConfiguration? config;
|
||||||
|
|
||||||
public KubernetesClientConfiguration GetK8sClientConfig()
|
public KubernetesClientConfiguration GetK8sClientConfig()
|
||||||
{
|
{
|
||||||
// todo: If the default KubeConfig file does not suffice, change it here:
|
if (config != null) return config;
|
||||||
return KubernetesClientConfiguration.BuildConfigFromConfigFile();
|
config = KubernetesClientConfiguration.BuildConfigFromConfigFile(KubeConfigFile);
|
||||||
|
return config;
|
||||||
}
|
}
|
||||||
|
|
||||||
public string GetIp()
|
public string GetIp()
|
||||||
{
|
{
|
||||||
return "127.0.0.1";
|
var c = GetK8sClientConfig();
|
||||||
|
|
||||||
|
var host = c.Host.Replace("https://", "");
|
||||||
|
|
||||||
|
return host.Substring(0, host.IndexOf(':'));
|
||||||
}
|
}
|
||||||
|
|
||||||
public string GetNodeLabelForLocation(Location location)
|
public string GetNodeLabelForLocation(Location location)
|
||||||
{
|
{
|
||||||
switch (location)
|
if (location == Location.Unspecified) return string.Empty;
|
||||||
{
|
return K8sNodeLocationMap[location];
|
||||||
case Location.Unspecified:
|
|
||||||
return string.Empty;
|
|
||||||
case Location.BensLaptop:
|
|
||||||
return "worker01";
|
|
||||||
case Location.BensOldGamingMachine:
|
|
||||||
return "worker02";
|
|
||||||
}
|
|
||||||
|
|
||||||
Assert.Fail("Unknown location selected: " + location);
|
|
||||||
throw new InvalidOperationException();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
using NUnit.Framework;
|
using CodexDistTestCore.Config;
|
||||||
|
using NUnit.Framework;
|
||||||
|
|
||||||
namespace CodexDistTestCore
|
namespace CodexDistTestCore
|
||||||
{
|
{
|
||||||
|
@ -41,7 +42,10 @@ namespace CodexDistTestCore
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
var dockerImage = new CodexDockerImage();
|
||||||
log = new TestLog();
|
log = new TestLog();
|
||||||
|
log.Log($"Using docker image '{dockerImage.GetImageTag()}'");
|
||||||
|
|
||||||
fileManager = new FileManager(log);
|
fileManager = new FileManager(log);
|
||||||
k8sManager = new K8sManager(log, fileManager);
|
k8sManager = new K8sManager(log, fileManager);
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,7 +8,7 @@ namespace CodexDistTestCore
|
||||||
public class K8sOperations
|
public class K8sOperations
|
||||||
{
|
{
|
||||||
private readonly CodexDockerImage dockerImage = new CodexDockerImage();
|
private readonly CodexDockerImage dockerImage = new CodexDockerImage();
|
||||||
private readonly K8sCluster k8SCluster = new K8sCluster();
|
private readonly K8sCluster k8sCluster = new K8sCluster();
|
||||||
private readonly Kubernetes client;
|
private readonly Kubernetes client;
|
||||||
private readonly KnownK8sPods knownPods;
|
private readonly KnownK8sPods knownPods;
|
||||||
|
|
||||||
|
@ -16,7 +16,7 @@ namespace CodexDistTestCore
|
||||||
{
|
{
|
||||||
this.knownPods = knownPods;
|
this.knownPods = knownPods;
|
||||||
|
|
||||||
client = new Kubernetes(k8SCluster.GetK8sClientConfig());
|
client = new Kubernetes(k8sCluster.GetK8sClientConfig());
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Close()
|
public void Close()
|
||||||
|
@ -222,7 +222,7 @@ namespace CodexDistTestCore
|
||||||
|
|
||||||
return new Dictionary<string, string>
|
return new Dictionary<string, string>
|
||||||
{
|
{
|
||||||
{ "codex-test-location", k8SCluster.GetNodeLabelForLocation(offline.Location) }
|
{ "codex-test-location", k8sCluster.GetNodeLabelForLocation(offline.Location) }
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -16,7 +16,7 @@ namespace CodexDistTestCore
|
||||||
private const string SuccessfullyConnectedMessage = "Successfully connected to peer";
|
private const string SuccessfullyConnectedMessage = "Successfully connected to peer";
|
||||||
private const string UploadFailedMessage = "Unable to store block";
|
private const string UploadFailedMessage = "Unable to store block";
|
||||||
|
|
||||||
private readonly K8sCluster k8SCluster = new K8sCluster();
|
private readonly K8sCluster k8sCluster = new K8sCluster();
|
||||||
private readonly TestLog log;
|
private readonly TestLog log;
|
||||||
private readonly IFileManager fileManager;
|
private readonly IFileManager fileManager;
|
||||||
|
|
||||||
|
@ -103,7 +103,7 @@ namespace CodexDistTestCore
|
||||||
|
|
||||||
private Http Http()
|
private Http Http()
|
||||||
{
|
{
|
||||||
return new Http(ip: k8SCluster.GetIp(), port: Container.ServicePort, baseUrl: "/api/codex/v1");
|
return new Http(ip: k8sCluster.GetIp(), port: Container.ServicePort, baseUrl: "/api/codex/v1");
|
||||||
}
|
}
|
||||||
|
|
||||||
private void Log(string msg)
|
private void Log(string msg)
|
||||||
|
|
Loading…
Reference in New Issue