2023-09-20 13:33:58 +02:00
|
|
|
|
using CodexPlugin;
|
|
|
|
|
using Core;
|
|
|
|
|
using DistTestCore;
|
2023-09-11 10:43:27 +02:00
|
|
|
|
using FileUtils;
|
2023-06-21 09:27:59 +02:00
|
|
|
|
using Logging;
|
2023-09-26 14:32:28 +02:00
|
|
|
|
using MetricsPlugin;
|
2023-06-21 09:27:59 +02:00
|
|
|
|
|
|
|
|
|
namespace ContinuousTests
|
|
|
|
|
{
|
|
|
|
|
public abstract class ContinuousTestLongTimeouts : ContinuousTest
|
|
|
|
|
{
|
|
|
|
|
public override ITimeSet TimeSet => new LongTimeSet();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public abstract class ContinuousTest
|
|
|
|
|
{
|
2023-06-23 11:38:30 +02:00
|
|
|
|
protected const int Zero = 0;
|
2023-06-25 10:50:01 +02:00
|
|
|
|
protected const int MinuteOne = 60;
|
|
|
|
|
protected const int MinuteFive = MinuteOne * 5;
|
|
|
|
|
protected const int HourOne = MinuteOne * 60;
|
2023-06-26 15:37:16 +02:00
|
|
|
|
protected const int HourThree = HourOne * 3;
|
2023-06-23 11:38:30 +02:00
|
|
|
|
protected const int DayOne = HourOne * 24;
|
|
|
|
|
protected const int DayThree = DayOne * 3;
|
|
|
|
|
|
2023-09-20 13:33:58 +02:00
|
|
|
|
public void Initialize(ICodexNode[] nodes, ILog log, IFileManager fileManager, Configuration configuration, CancellationToken cancelToken)
|
2023-06-21 09:27:59 +02:00
|
|
|
|
{
|
|
|
|
|
Nodes = nodes;
|
|
|
|
|
Log = log;
|
|
|
|
|
FileManager = fileManager;
|
2023-06-26 15:37:16 +02:00
|
|
|
|
Configuration = configuration;
|
2023-06-28 16:19:37 +02:00
|
|
|
|
CancelToken = cancelToken;
|
2023-06-28 11:48:05 +02:00
|
|
|
|
|
|
|
|
|
if (nodes != null)
|
|
|
|
|
{
|
2023-09-20 13:33:58 +02:00
|
|
|
|
NodeRunner = new NodeRunner(Nodes, configuration, Log, CustomK8sNamespace);
|
2023-06-28 11:48:05 +02:00
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
NodeRunner = null!;
|
|
|
|
|
}
|
2023-06-21 09:27:59 +02:00
|
|
|
|
}
|
|
|
|
|
|
2023-09-20 13:33:58 +02:00
|
|
|
|
public ICodexNode[] Nodes { get; private set; } = null!;
|
|
|
|
|
public ILog Log { get; private set; } = null!;
|
2023-06-21 09:27:59 +02:00
|
|
|
|
public IFileManager FileManager { get; private set; } = null!;
|
2023-06-26 15:37:16 +02:00
|
|
|
|
public Configuration Configuration { get; private set; } = null!;
|
2023-06-21 09:27:59 +02:00
|
|
|
|
public virtual ITimeSet TimeSet { get { return new DefaultTimeSet(); } }
|
2023-06-29 10:23:04 +02:00
|
|
|
|
public CancellationToken CancelToken { get; private set; } = new CancellationToken();
|
2023-06-28 11:48:05 +02:00
|
|
|
|
public NodeRunner NodeRunner { get; private set; } = null!;
|
2023-06-21 09:27:59 +02:00
|
|
|
|
|
2023-09-26 14:32:28 +02:00
|
|
|
|
public IMetricsAccess CreateMetricsAccess(IHasMetricsScrapeTarget target)
|
|
|
|
|
{
|
|
|
|
|
return CreateMetricsAccess(target.MetricsScrapeTarget);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public IMetricsAccess CreateMetricsAccess(IMetricsScrapeTarget target)
|
|
|
|
|
{
|
|
|
|
|
if (Configuration.CodexDeployment.PrometheusContainer == null) throw new Exception("Expected prometheus to be part of Codex deployment.");
|
|
|
|
|
|
|
|
|
|
var entryPointFactory = new EntryPointFactory();
|
|
|
|
|
var entryPoint = entryPointFactory.CreateEntryPoint(Configuration.KubeConfigFile, Configuration.DataPath, Configuration.CodexDeployment.Metadata.KubeNamespace, Log);
|
|
|
|
|
return entryPoint.CreateInterface().WrapMetricsCollector(Configuration.CodexDeployment.PrometheusContainer, target);
|
|
|
|
|
}
|
|
|
|
|
|
2023-06-21 09:27:59 +02:00
|
|
|
|
public abstract int RequiredNumberOfNodes { get; }
|
2023-06-25 09:53:10 +02:00
|
|
|
|
public abstract TimeSpan RunTestEvery { get; }
|
|
|
|
|
public abstract TestFailMode TestFailMode { get; }
|
2023-06-28 11:01:10 +02:00
|
|
|
|
public virtual string CustomK8sNamespace { get { return string.Empty; } }
|
2023-06-21 09:27:59 +02:00
|
|
|
|
|
|
|
|
|
public string Name
|
|
|
|
|
{
|
|
|
|
|
get
|
|
|
|
|
{
|
|
|
|
|
return GetType().Name;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2023-06-25 09:53:10 +02:00
|
|
|
|
|
|
|
|
|
public enum TestFailMode
|
|
|
|
|
{
|
|
|
|
|
StopAfterFirstFailure,
|
|
|
|
|
AlwaysRunAllMoments
|
|
|
|
|
}
|
2023-06-21 09:27:59 +02:00
|
|
|
|
}
|