local tests passed
This commit is contained in:
parent
01ec6f7d8b
commit
5a861df968
|
@ -6,6 +6,11 @@ namespace KubernetesWorkflow
|
||||||
{
|
{
|
||||||
private readonly Dictionary<string, string> labels = new Dictionary<string, string>();
|
private readonly Dictionary<string, string> labels = new Dictionary<string, string>();
|
||||||
|
|
||||||
|
private PodLabels(PodLabels source)
|
||||||
|
{
|
||||||
|
labels = source.labels.ToDictionary(p => p.Key, p => p.Value);
|
||||||
|
}
|
||||||
|
|
||||||
public PodLabels(string testsType, string codexId)
|
public PodLabels(string testsType, string codexId)
|
||||||
{
|
{
|
||||||
Add("tests-type", testsType);
|
Add("tests-type", testsType);
|
||||||
|
@ -17,14 +22,21 @@ namespace KubernetesWorkflow
|
||||||
Add("testname", NameUtils.GetTestMethodName());
|
Add("testname", NameUtils.GetTestMethodName());
|
||||||
}
|
}
|
||||||
|
|
||||||
public void AddAppName(string appName)
|
public PodLabels GetLabelsForAppName(string appName)
|
||||||
{
|
{
|
||||||
Add("app", appName);
|
var pl = new PodLabels(this);
|
||||||
|
pl.Add("app", appName);
|
||||||
|
return pl;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void Add(string key, string value)
|
private void Add(string key, string value)
|
||||||
{
|
{
|
||||||
labels.Add(key, value.ToLowerInvariant());
|
labels.Add(key,
|
||||||
|
value.ToLowerInvariant()
|
||||||
|
.Replace(":","-")
|
||||||
|
.Replace("/", "-")
|
||||||
|
.Replace("\\", "-")
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
internal Dictionary<string, string> GetLabels()
|
internal Dictionary<string, string> GetLabels()
|
||||||
|
|
|
@ -25,7 +25,7 @@ namespace KubernetesWorkflow
|
||||||
|
|
||||||
public RunningContainers Start(int numberOfContainers, Location location, ContainerRecipeFactory recipeFactory, StartupConfig startupConfig)
|
public RunningContainers Start(int numberOfContainers, Location location, ContainerRecipeFactory recipeFactory, StartupConfig startupConfig)
|
||||||
{
|
{
|
||||||
podLabels.AddAppName(recipeFactory.AppName);
|
var pl = podLabels.GetLabelsForAppName(recipeFactory.AppName);
|
||||||
|
|
||||||
return K8s(controller =>
|
return K8s(controller =>
|
||||||
{
|
{
|
||||||
|
@ -34,7 +34,7 @@ namespace KubernetesWorkflow
|
||||||
var runningPod = controller.BringOnline(recipes, location);
|
var runningPod = controller.BringOnline(recipes, location);
|
||||||
|
|
||||||
return new RunningContainers(startupConfig, runningPod, CreateContainers(runningPod, recipes, startupConfig));
|
return new RunningContainers(startupConfig, runningPod, CreateContainers(runningPod, recipes, startupConfig));
|
||||||
});
|
}, pl);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Stop(RunningContainers runningContainers)
|
public void Stop(RunningContainers runningContainers)
|
||||||
|
@ -163,6 +163,14 @@ namespace KubernetesWorkflow
|
||||||
controller.Dispose();
|
controller.Dispose();
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private T K8s<T>(Func<K8sController, T> action, PodLabels labels)
|
||||||
|
{
|
||||||
|
var controller = new K8sController(log, cluster, knownK8SPods, numberSource, testNamespace, labels);
|
||||||
|
var result = action(controller);
|
||||||
|
controller.Dispose();
|
||||||
|
return result;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public interface ILogHandler
|
public interface ILogHandler
|
||||||
|
|
Loading…
Reference in New Issue