2023-03-21 08:58:13 +00:00
|
|
|
|
using NUnit.Framework;
|
|
|
|
|
|
2023-03-21 12:20:21 +00:00
|
|
|
|
namespace CodexDistTestCore
|
2023-03-17 10:43:29 +00:00
|
|
|
|
{
|
2023-03-21 08:58:13 +00:00
|
|
|
|
[AttributeUsage(AttributeTargets.Method, AllowMultiple = false)]
|
|
|
|
|
public class UseLongTimeoutsAttribute : PropertyAttribute
|
|
|
|
|
{
|
|
|
|
|
public UseLongTimeoutsAttribute()
|
|
|
|
|
: base(Timing.UseLongTimeoutsKey)
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2023-03-17 10:43:29 +00:00
|
|
|
|
public static class Timing
|
|
|
|
|
{
|
2023-03-21 08:58:13 +00:00
|
|
|
|
public const string UseLongTimeoutsKey = "UseLongTimeouts";
|
|
|
|
|
|
2023-03-17 10:43:29 +00:00
|
|
|
|
public static TimeSpan HttpCallTimeout()
|
|
|
|
|
{
|
2023-03-21 08:58:13 +00:00
|
|
|
|
return GetTimes().HttpCallTimeout();
|
2023-03-19 10:40:05 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static int HttpCallRetryCount()
|
|
|
|
|
{
|
2023-03-21 08:58:13 +00:00
|
|
|
|
return GetTimes().HttpCallRetryCount();
|
2023-03-17 10:43:29 +00:00
|
|
|
|
}
|
|
|
|
|
|
2023-03-23 11:35:03 +00:00
|
|
|
|
public static void HttpCallRetryDelay()
|
2023-03-17 10:43:29 +00:00
|
|
|
|
{
|
2023-03-23 11:35:03 +00:00
|
|
|
|
Utils.Sleep(GetTimes().HttpCallRetryDelay());
|
2023-03-17 10:43:29 +00:00
|
|
|
|
}
|
2023-03-19 07:22:38 +00:00
|
|
|
|
|
2023-03-19 10:40:05 +00:00
|
|
|
|
public static void WaitForK8sServiceDelay()
|
2023-03-19 07:22:38 +00:00
|
|
|
|
{
|
2023-03-21 08:58:13 +00:00
|
|
|
|
Utils.Sleep(GetTimes().WaitForK8sServiceDelay());
|
2023-03-19 07:22:38 +00:00
|
|
|
|
}
|
2023-03-19 10:40:05 +00:00
|
|
|
|
|
|
|
|
|
public static TimeSpan K8sOperationTimeout()
|
2023-03-21 08:58:13 +00:00
|
|
|
|
{
|
|
|
|
|
return GetTimes().K8sOperationTimeout();
|
|
|
|
|
}
|
|
|
|
|
|
2023-03-29 08:07:16 +00:00
|
|
|
|
public static TimeSpan WaitForMetricTimeout()
|
|
|
|
|
{
|
|
|
|
|
return GetTimes().WaitForMetricTimeout();
|
|
|
|
|
}
|
|
|
|
|
|
2023-03-21 08:58:13 +00:00
|
|
|
|
private static ITimeSet GetTimes()
|
|
|
|
|
{
|
|
|
|
|
var testProperties = TestContext.CurrentContext.Test.Properties;
|
|
|
|
|
if (testProperties.ContainsKey(UseLongTimeoutsKey)) return new LongTimeSet();
|
|
|
|
|
return new DefaultTimeSet();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public interface ITimeSet
|
|
|
|
|
{
|
|
|
|
|
TimeSpan HttpCallTimeout();
|
|
|
|
|
int HttpCallRetryCount();
|
2023-03-23 11:35:03 +00:00
|
|
|
|
TimeSpan HttpCallRetryDelay();
|
2023-03-21 08:58:13 +00:00
|
|
|
|
TimeSpan WaitForK8sServiceDelay();
|
|
|
|
|
TimeSpan K8sOperationTimeout();
|
2023-03-29 08:07:16 +00:00
|
|
|
|
TimeSpan WaitForMetricTimeout();
|
2023-03-21 08:58:13 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public class DefaultTimeSet : ITimeSet
|
|
|
|
|
{
|
|
|
|
|
public TimeSpan HttpCallTimeout()
|
|
|
|
|
{
|
|
|
|
|
return TimeSpan.FromSeconds(10);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public int HttpCallRetryCount()
|
|
|
|
|
{
|
|
|
|
|
return 5;
|
|
|
|
|
}
|
|
|
|
|
|
2023-03-23 11:35:03 +00:00
|
|
|
|
public TimeSpan HttpCallRetryDelay()
|
2023-03-21 08:58:13 +00:00
|
|
|
|
{
|
|
|
|
|
return TimeSpan.FromSeconds(3);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public TimeSpan WaitForK8sServiceDelay()
|
|
|
|
|
{
|
|
|
|
|
return TimeSpan.FromSeconds(1);
|
|
|
|
|
}
|
2023-03-21 12:20:21 +00:00
|
|
|
|
|
2023-03-21 08:58:13 +00:00
|
|
|
|
public TimeSpan K8sOperationTimeout()
|
|
|
|
|
{
|
|
|
|
|
return TimeSpan.FromMinutes(5);
|
|
|
|
|
}
|
2023-03-29 08:07:16 +00:00
|
|
|
|
|
|
|
|
|
public TimeSpan WaitForMetricTimeout()
|
|
|
|
|
{
|
|
|
|
|
return TimeSpan.FromSeconds(30);
|
|
|
|
|
}
|
2023-03-21 08:58:13 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public class LongTimeSet : ITimeSet
|
|
|
|
|
{
|
|
|
|
|
public TimeSpan HttpCallTimeout()
|
|
|
|
|
{
|
2023-03-21 10:41:05 +00:00
|
|
|
|
return TimeSpan.FromHours(2);
|
2023-03-21 08:58:13 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public int HttpCallRetryCount()
|
|
|
|
|
{
|
|
|
|
|
return 2;
|
|
|
|
|
}
|
|
|
|
|
|
2023-03-23 11:35:03 +00:00
|
|
|
|
public TimeSpan HttpCallRetryDelay()
|
2023-03-19 10:40:05 +00:00
|
|
|
|
{
|
|
|
|
|
return TimeSpan.FromMinutes(5);
|
|
|
|
|
}
|
2023-03-21 08:58:13 +00:00
|
|
|
|
|
|
|
|
|
public TimeSpan WaitForK8sServiceDelay()
|
|
|
|
|
{
|
|
|
|
|
return TimeSpan.FromSeconds(10);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public TimeSpan K8sOperationTimeout()
|
|
|
|
|
{
|
|
|
|
|
return TimeSpan.FromMinutes(15);
|
|
|
|
|
}
|
2023-03-29 08:07:16 +00:00
|
|
|
|
|
|
|
|
|
public TimeSpan WaitForMetricTimeout()
|
|
|
|
|
{
|
|
|
|
|
return TimeSpan.FromMinutes(5);
|
|
|
|
|
}
|
2023-03-17 10:43:29 +00:00
|
|
|
|
}
|
|
|
|
|
}
|