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
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static void RetryDelay()
|
|
|
|
|
{
|
2023-03-21 08:58:13 +00:00
|
|
|
|
Utils.Sleep(GetTimes().RetryDelay());
|
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();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
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();
|
|
|
|
|
TimeSpan RetryDelay();
|
|
|
|
|
TimeSpan WaitForK8sServiceDelay();
|
|
|
|
|
TimeSpan K8sOperationTimeout();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public class DefaultTimeSet : ITimeSet
|
|
|
|
|
{
|
|
|
|
|
public TimeSpan HttpCallTimeout()
|
|
|
|
|
{
|
|
|
|
|
return TimeSpan.FromSeconds(10);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public int HttpCallRetryCount()
|
|
|
|
|
{
|
|
|
|
|
return 5;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public TimeSpan RetryDelay()
|
|
|
|
|
{
|
|
|
|
|
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);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
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;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public TimeSpan RetryDelay()
|
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-17 10:43:29 +00:00
|
|
|
|
}
|
|
|
|
|
}
|