public void TestRetryOnApiWithToken() { var product = "ecs"; var version = "2014-05-26"; var apiName = "CreateDisk"; var retryPolicyContext = new RetryPolicyContext(null, "200", 1, product, version, apiName, RetryCondition.BlankStatus); var retryOnApiCondition = new RetryOnApiWithClientTokenCondition(); var shouldRetry = retryOnApiCondition.ShouldRetry(retryPolicyContext); Assert.Equal(RetryCondition.ShouldRetry | RetryCondition.ShouldRetryWithThrottlingBackoff, shouldRetry); apiName = "DescribeInstances"; retryPolicyContext = new RetryPolicyContext(null, "200", 1, product, version, apiName, RetryCondition.BlankStatus); shouldRetry = retryOnApiCondition.ShouldRetry(retryPolicyContext); Assert.Equal(RetryCondition.NoRetry | RetryCondition.ShouldRetryWithThrottlingBackoff, shouldRetry); product = "vpc"; retryPolicyContext = new RetryPolicyContext(null, "200", 1, product, version, apiName, RetryCondition.BlankStatus); shouldRetry = retryOnApiCondition.ShouldRetry(retryPolicyContext); Assert.Equal(RetryCondition.NoRetry, shouldRetry); }
public void TestOrRetryCondition() { var retryPolicyContext = new RetryPolicyContext(null, "200", 2, "ecs", "2014-05-26", "DescribeInstances", RetryCondition.BlankStatus); var retryOnApiCondition = new RetryOnApiCondition(); var retryOnApiWithClientToken = new RetryOnApiWithClientTokenCondition(); var orList = new List <IAlibabaRetryCondition> { retryOnApiCondition, retryOnApiWithClientToken }; var orRetryCondition = new OrRetryCondition(orList); var shouldRetry = orRetryCondition.ShouldRetry(retryPolicyContext); Assert.Equal(RetryCondition.ShouldRetry | RetryCondition.ShouldRetryWithThrottlingBackoff, shouldRetry); }