2023-04-12 14:06:04 +00:00
|
|
|
|
using NUnit.Framework;
|
|
|
|
|
using Utils;
|
|
|
|
|
|
|
|
|
|
namespace DistTestCore
|
|
|
|
|
{
|
|
|
|
|
[AttributeUsage(AttributeTargets.Method, AllowMultiple = false)]
|
|
|
|
|
public class UseLongTimeoutsAttribute : PropertyAttribute
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static class Timing
|
|
|
|
|
{
|
2023-04-27 13:55:33 +00:00
|
|
|
|
public static bool UseLongTimeouts { get; set; }
|
|
|
|
|
|
2023-04-12 14:06:04 +00:00
|
|
|
|
|
|
|
|
|
public static TimeSpan HttpCallTimeout()
|
|
|
|
|
{
|
|
|
|
|
return GetTimes().HttpCallTimeout();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static int HttpCallRetryCount()
|
|
|
|
|
{
|
|
|
|
|
return GetTimes().HttpCallRetryCount();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static void HttpCallRetryDelay()
|
|
|
|
|
{
|
|
|
|
|
Time.Sleep(GetTimes().HttpCallRetryDelay());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static TimeSpan K8sServiceDelay()
|
|
|
|
|
{
|
|
|
|
|
return GetTimes().WaitForK8sServiceDelay();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static TimeSpan K8sOperationTimeout()
|
|
|
|
|
{
|
|
|
|
|
return GetTimes().K8sOperationTimeout();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static TimeSpan WaitForMetricTimeout()
|
|
|
|
|
{
|
|
|
|
|
return GetTimes().WaitForMetricTimeout();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private static ITimeSet GetTimes()
|
|
|
|
|
{
|
2023-04-27 13:55:33 +00:00
|
|
|
|
if (UseLongTimeouts) return new LongTimeSet();
|
2023-04-12 14:06:04 +00:00
|
|
|
|
return new DefaultTimeSet();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public interface ITimeSet
|
|
|
|
|
{
|
|
|
|
|
TimeSpan HttpCallTimeout();
|
|
|
|
|
int HttpCallRetryCount();
|
|
|
|
|
TimeSpan HttpCallRetryDelay();
|
|
|
|
|
TimeSpan WaitForK8sServiceDelay();
|
|
|
|
|
TimeSpan K8sOperationTimeout();
|
|
|
|
|
TimeSpan WaitForMetricTimeout();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public class DefaultTimeSet : ITimeSet
|
|
|
|
|
{
|
|
|
|
|
public TimeSpan HttpCallTimeout()
|
|
|
|
|
{
|
|
|
|
|
return TimeSpan.FromSeconds(10);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public int HttpCallRetryCount()
|
|
|
|
|
{
|
|
|
|
|
return 5;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public TimeSpan HttpCallRetryDelay()
|
|
|
|
|
{
|
|
|
|
|
return TimeSpan.FromSeconds(3);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public TimeSpan WaitForK8sServiceDelay()
|
|
|
|
|
{
|
|
|
|
|
return TimeSpan.FromSeconds(1);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public TimeSpan K8sOperationTimeout()
|
|
|
|
|
{
|
|
|
|
|
return TimeSpan.FromMinutes(5);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public TimeSpan WaitForMetricTimeout()
|
|
|
|
|
{
|
|
|
|
|
return TimeSpan.FromSeconds(30);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public class LongTimeSet : ITimeSet
|
|
|
|
|
{
|
|
|
|
|
public TimeSpan HttpCallTimeout()
|
|
|
|
|
{
|
|
|
|
|
return TimeSpan.FromHours(2);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public int HttpCallRetryCount()
|
|
|
|
|
{
|
|
|
|
|
return 2;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public TimeSpan HttpCallRetryDelay()
|
|
|
|
|
{
|
|
|
|
|
return TimeSpan.FromMinutes(5);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public TimeSpan WaitForK8sServiceDelay()
|
|
|
|
|
{
|
|
|
|
|
return TimeSpan.FromSeconds(10);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public TimeSpan K8sOperationTimeout()
|
|
|
|
|
{
|
|
|
|
|
return TimeSpan.FromMinutes(15);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public TimeSpan WaitForMetricTimeout()
|
|
|
|
|
{
|
|
|
|
|
return TimeSpan.FromMinutes(5);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|