public void VerifyCanNotRetryHttp400Error() { var failedRequestsManager = new FailedRequestsManager(failedRequestRetryWaitTime); failedRequestsManager.RegisterFetchFailure(testInstrumentationKey, HttpStatusCode.NotFound); Assert.IsFalse(failedRequestsManager.CanRetry(testInstrumentationKey)); Thread.Sleep(failedRequestRetryWaitTime + failedRequestRetryWaitTime); // wait for timeout to expire (2x timeout). Assert.IsFalse(failedRequestsManager.CanRetry(testInstrumentationKey)); }
public void VerifyRetryTimeout() { var stopWatch = new Stopwatch(); var failedRequestsManager = new FailedRequestsManager(failedRequestRetryWaitTime); stopWatch.Start(); failedRequestsManager.RegisterFetchFailure(testInstrumentationKey, new Exception()); Assert.IsFalse(failedRequestsManager.CanRetry(testInstrumentationKey)); while (!failedRequestsManager.CanRetry(testInstrumentationKey)) { Thread.Sleep(failedRequestRetryWaitTime); } stopWatch.Stop(); Assert.IsTrue(stopWatch.Elapsed >= failedRequestRetryWaitTime); }
public void VerifyCanRetryHttp500ErrorAfterTimeout() { var stopWatch = new Stopwatch(); var failedRequestsManager = new FailedRequestsManager(failedRequestRetryWaitTime); stopWatch.Start(); failedRequestsManager.RegisterFetchFailure(testInstrumentationKey, HttpStatusCode.InternalServerError); Assert.IsFalse(failedRequestsManager.CanRetry(testInstrumentationKey)); while (!failedRequestsManager.CanRetry(testInstrumentationKey)) { Thread.Sleep(failedRequestRetryWaitTime); } stopWatch.Stop(); Assert.IsTrue(stopWatch.Elapsed >= failedRequestRetryWaitTime); Assert.IsTrue(failedRequestsManager.CanRetry(testInstrumentationKey)); }