mirror of
https://github.com/ansible-collections/community.general.git
synced 2026-05-07 22:02:50 +00: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:
committed by
Ryan Brown
parent
3b7b78b25f
commit
7551e8c921
@@ -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'}}
|
||||
|
||||
Reference in New Issue
Block a user