mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-05-02 23:31:25 -07:00
AWSRetry: allow retrying on additional ClientError exceptions (#28483)
* Added the ability to extend the exception list in CloudRetry * AWSRetry boto and boto compatible * Updated tests to reflect boto/boto3 * Added boto to shippable requirements * Have base_class and added_exceptions default to None in CloudRetry AWSRetry - only retry on boto3 exceptions and remove boto requirement from tests * Make requested changes.
This commit is contained in:
parent
3b7b78b25f
commit
7551e8c921
3 changed files with 29 additions and 14 deletions
|
@ -44,6 +44,22 @@ class RetryTestCase(unittest.TestCase):
|
|||
r = no_failures()
|
||||
self.assertEqual(self.counter, 1)
|
||||
|
||||
def test_extend_boto3_failures(self):
|
||||
self.counter = 0
|
||||
err_msg = {'Error': {'Code': 'MalformedPolicyDocument'}}
|
||||
|
||||
@AWSRetry.backoff(tries=2, delay=0.1, catch_extra_error_codes=['MalformedPolicyDocument'])
|
||||
def extend_failures():
|
||||
self.counter += 1
|
||||
if self.counter < 2:
|
||||
raise botocore.exceptions.ClientError(err_msg, 'Could not find you')
|
||||
else:
|
||||
return 'success'
|
||||
|
||||
r = extend_failures()
|
||||
self.assertEqual(r, 'success')
|
||||
self.assertEqual(self.counter, 2)
|
||||
|
||||
def test_retry_once(self):
|
||||
self.counter = 0
|
||||
err_msg = {'Error': {'Code': 'InstanceId.NotFound'}}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue