public void TestGetRetryableList() { var list = RetryConfig.GetRetryableApiList(product, version, sectionName); Assert.True(79 == list.Count); sectionName = "RetryableNormalErrors"; list = RetryConfig.GetRetryableApiList(product, version, sectionName); Assert.True(3 == list.Count); }
public RetryCondition ShouldRetry(RetryPolicyContext retryPolicyContext) { var product = retryPolicyContext.Product; var version = retryPolicyContext.Version; var currentApiName = retryPolicyContext.ApiName; var apiList = RetryConfig.GetRetryableApiList(product, version, ApiSectionName); if (apiList == null) { return(RetryCondition.NoRetry); } return(apiList.Contains(currentApiName) ? RetryCondition.ShouldRetry : RetryCondition.NoRetry); }
public RetryCondition ShouldRetry(RetryPolicyContext retryPolicyContext) { var exception = retryPolicyContext.Exception; if (exception == null) { return(RetryCondition.NoRetry); } if (exception.ErrorCode != null && exception.ErrorCode.Equals(SdkHttpError)) { return(RetryCondition.ShouldRetry); } if (exception is ServerException) { var serverException = (ServerException)exception; var errorCode = serverException.ErrorCode; var product = retryPolicyContext.Product; var version = retryPolicyContext.Version; var normalErrorList = RetryConfig.GetRetryableApiList(product, version, NormalErrorSectionName); if (normalErrorList != null && normalErrorList.Contains(errorCode)) { return(RetryCondition.ShouldRetry); } var throttlingErrorList = RetryConfig.GetRetryableApiList(product, version, ThrottlingErrorSectionName); if (throttlingErrorList == null) { return(RetryCondition.NoRetry); } var shouldThrottlingFromConfig = throttlingErrorList.Contains(errorCode); var localShouldRetry = shouldThrottlingFromConfig ? RetryCondition.ShouldRetry : RetryCondition.NoRetry; return(localShouldRetry | RetryCondition.ShouldRetryWithThrottlingBackoff); } return(RetryCondition.NoRetry); }
public void TestInvalidJsonSection() { product = "fakeProduct"; var list = RetryConfig.GetRetryableApiList(product, version, sectionName); Assert.Null(list); product = "ecs"; version = "2014-05-27"; list = RetryConfig.GetRetryableApiList(product, version, sectionName); Assert.Null(list); sectionName = "RetryableAPIsTest"; list = RetryConfig.GetRetryableApiList(product, version, sectionName); Assert.Null(list); }