public void TestRetryOnApiCondition() { var product = "ecs"; var version = "2014-05-26"; var apiName = "DescribeInstances"; var retryPolicyContext = new RetryPolicyContext(null, "200", 1, product, version, apiName, RetryCondition.BlankStatus); var retryOnApiCondition = new RetryOnApiCondition(); var shouldRetry = retryOnApiCondition.ShouldRetry(retryPolicyContext); Assert.Equal(RetryCondition.ShouldRetry, shouldRetry); apiName = "DescribeTestInstance"; retryPolicyContext = new RetryPolicyContext(null, "200", 1, product, version, apiName, RetryCondition.BlankStatus); shouldRetry = retryOnApiCondition.ShouldRetry(retryPolicyContext); Assert.Equal(RetryCondition.NoRetry, shouldRetry); product = "vpc"; retryPolicyContext = new RetryPolicyContext(null, "200", 1, product, version, "DescribeInstances", RetryCondition.BlankStatus); shouldRetry = retryOnApiCondition.ShouldRetry(retryPolicyContext); Assert.Equal(RetryCondition.NoRetry, shouldRetry); }
public void TestAndRetryCondition() { var retryPolicyContext = new RetryPolicyContext(null, "200", 2, "ecs", "2014-05-26", "DescribeInstances", RetryCondition.BlankStatus); var retryOnApiCondition = new RetryOnApiCondition(); var orList = new List <IAlibabaRetryCondition> { retryOnApiCondition }; var orRetryCondition = new OrRetryCondition(orList); var maxRetryTimesCondition = new MaxRetryTimesCondition(3); var andList = new List <IAlibabaRetryCondition> { orRetryCondition, maxRetryTimesCondition }; var andRetryCondition = new AndRetryCondition(andList); var shouldRetry = andRetryCondition.ShouldRetry(retryPolicyContext); Assert.Equal(RetryCondition.ShouldRetry, 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); }