2023-09-12 11:32:06 +00:00
|
|
|
|
using Core;
|
2023-09-13 13:10:19 +00:00
|
|
|
|
using KubernetesWorkflow;
|
2023-04-12 14:06:04 +00:00
|
|
|
|
|
|
|
|
|
namespace DistTestCore
|
|
|
|
|
{
|
|
|
|
|
public class Configuration
|
|
|
|
|
{
|
2023-06-02 07:03:46 +00:00
|
|
|
|
private readonly string? kubeConfigFile;
|
|
|
|
|
private readonly string logPath;
|
|
|
|
|
private readonly string dataFilesPath;
|
|
|
|
|
|
|
|
|
|
public Configuration()
|
|
|
|
|
{
|
|
|
|
|
kubeConfigFile = GetNullableEnvVarOrDefault("KUBECONFIG", null);
|
|
|
|
|
logPath = GetEnvVarOrDefault("LOGPATH", "CodexTestLogs");
|
|
|
|
|
dataFilesPath = GetEnvVarOrDefault("DATAFILEPATH", "TestDataFiles");
|
2024-03-27 14:01:32 +00:00
|
|
|
|
AlwaysDownloadContainerLogs = !string.IsNullOrEmpty(GetEnvVarOrDefault("ALWAYS_LOGS", ""));
|
2023-06-22 08:17:12 +00:00
|
|
|
|
}
|
|
|
|
|
|
2023-11-08 08:24:39 +00:00
|
|
|
|
public Configuration(string? kubeConfigFile, string logPath, string dataFilesPath)
|
2023-06-22 08:17:12 +00:00
|
|
|
|
{
|
|
|
|
|
this.kubeConfigFile = kubeConfigFile;
|
|
|
|
|
this.logPath = logPath;
|
|
|
|
|
this.dataFilesPath = dataFilesPath;
|
2023-06-02 07:03:46 +00:00
|
|
|
|
}
|
|
|
|
|
|
2024-03-27 14:01:32 +00:00
|
|
|
|
public bool AlwaysDownloadContainerLogs { get; set; }
|
|
|
|
|
|
2023-09-12 12:50:18 +00:00
|
|
|
|
public KubernetesWorkflow.Configuration GetK8sConfiguration(ITimeSet timeSet, string k8sNamespace)
|
2023-09-13 13:10:19 +00:00
|
|
|
|
{
|
|
|
|
|
return GetK8sConfiguration(timeSet, new DoNothingK8sHooks(), k8sNamespace);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public KubernetesWorkflow.Configuration GetK8sConfiguration(ITimeSet timeSet, IK8sHooks hooks, string k8sNamespace)
|
2023-04-12 14:06:04 +00:00
|
|
|
|
{
|
2023-09-13 12:37:53 +00:00
|
|
|
|
var config = new KubernetesWorkflow.Configuration(
|
2023-06-02 07:03:46 +00:00
|
|
|
|
kubeConfigFile: kubeConfigFile,
|
2023-05-04 06:55:20 +00:00
|
|
|
|
operationTimeout: timeSet.K8sOperationTimeout(),
|
2023-09-12 12:50:18 +00:00
|
|
|
|
retryDelay: timeSet.WaitForK8sServiceDelay(),
|
|
|
|
|
kubernetesNamespace: k8sNamespace
|
2023-04-12 14:06:04 +00:00
|
|
|
|
);
|
2023-09-13 12:37:53 +00:00
|
|
|
|
|
|
|
|
|
config.AllowNamespaceOverride = false;
|
2023-09-13 13:10:19 +00:00
|
|
|
|
config.Hooks = hooks;
|
2023-09-13 12:37:53 +00:00
|
|
|
|
|
|
|
|
|
return config;
|
2023-04-12 14:06:04 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public Logging.LogConfig GetLogConfig()
|
|
|
|
|
{
|
2023-11-08 08:24:39 +00:00
|
|
|
|
return new Logging.LogConfig(logPath);
|
2023-04-12 14:06:04 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public string GetFileManagerFolder()
|
|
|
|
|
{
|
2023-06-02 07:03:46 +00:00
|
|
|
|
return dataFilesPath;
|
2023-04-12 14:06:04 +00:00
|
|
|
|
}
|
2023-05-31 11:34:12 +00:00
|
|
|
|
|
2023-06-02 07:03:46 +00:00
|
|
|
|
private static string GetEnvVarOrDefault(string varName, string defaultValue)
|
|
|
|
|
{
|
|
|
|
|
var v = Environment.GetEnvironmentVariable(varName);
|
|
|
|
|
if (v == null) return defaultValue;
|
|
|
|
|
return v;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private static string? GetNullableEnvVarOrDefault(string varName, string? defaultValue)
|
|
|
|
|
{
|
|
|
|
|
var v = Environment.GetEnvironmentVariable(varName);
|
|
|
|
|
if (v == null) return defaultValue;
|
|
|
|
|
return v;
|
|
|
|
|
}
|
2023-06-01 07:35:18 +00:00
|
|
|
|
}
|
2023-04-12 14:06:04 +00:00
|
|
|
|
}
|