diff --git a/BasicTests/DebugEndpointTests.cs b/BasicTests/DebugEndpointTests.cs index 40926e1..6c6ef4f 100644 --- a/BasicTests/DebugEndpointTests.cs +++ b/BasicTests/DebugEndpointTests.cs @@ -1,5 +1,6 @@ using CodexDistTests.TestCore; using NUnit.Framework; +using System; namespace CodexDistTests.BasicTests { @@ -36,6 +37,23 @@ namespace CodexDistTests.BasicTests testFile.AssertIsEqual(downloadedFile); } + [Test, UseLongTimeouts] + public void OneClientLargeFileTest() + { + var primary = SetupCodexNode() + .WithLogLevel(CodexLogLevel.Trace) + .WithStorageQuota(100.GB()) + .BringOnline(); + + var testFile = GenerateTestFile(40.GB()); + + var contentId = primary.UploadFile(testFile); + + var downloadedFile = primary.DownloadContent(contentId); + + testFile.AssertIsEqual(downloadedFile); + } + //[Test] //public void TwoClientTest() //{ diff --git a/TestCore/Timing.cs b/TestCore/Timing.cs index 02adea0..8fa9361 100644 --- a/TestCore/Timing.cs +++ b/TestCore/Timing.cs @@ -1,30 +1,115 @@ -namespace CodexDistTests.TestCore +using NUnit.Framework; + +namespace CodexDistTests.TestCore { + [AttributeUsage(AttributeTargets.Method, AllowMultiple = false)] + public class UseLongTimeoutsAttribute : PropertyAttribute + { + public UseLongTimeoutsAttribute() + : base(Timing.UseLongTimeoutsKey) + { + } + } + public static class Timing { + public const string UseLongTimeoutsKey = "UseLongTimeouts"; + public static TimeSpan HttpCallTimeout() { - return TimeSpan.FromSeconds(10); + return GetTimes().HttpCallTimeout(); } public static int HttpCallRetryCount() { - return 5; + return GetTimes().HttpCallRetryCount(); } public static void RetryDelay() { - Utils.Sleep(TimeSpan.FromSeconds(3)); + Utils.Sleep(GetTimes().RetryDelay()); } public static void WaitForK8sServiceDelay() { - Utils.Sleep(TimeSpan.FromSeconds(1)); + Utils.Sleep(GetTimes().WaitForK8sServiceDelay()); } public static TimeSpan K8sOperationTimeout() + { + 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); + } + + public TimeSpan K8sOperationTimeout() { return TimeSpan.FromMinutes(5); } } + + public class LongTimeSet : ITimeSet + { + public TimeSpan HttpCallTimeout() + { + return TimeSpan.FromMinutes(30); + } + + public int HttpCallRetryCount() + { + return 2; + } + + public TimeSpan RetryDelay() + { + return TimeSpan.FromMinutes(5); + } + + public TimeSpan WaitForK8sServiceDelay() + { + return TimeSpan.FromSeconds(10); + } + + public TimeSpan K8sOperationTimeout() + { + return TimeSpan.FromMinutes(15); + } + } }