Exemple #1
0
    def test_handle_botocore_response_parser_error(self, get_delay_mock,
                                                   set_operation_mock):
        get_delay_mock.return_value = 0
        operation_mock = MagicMock(side_effect=[
            botocore.parsers.ResponseParserError(
                os.linesep.join([
                    "Unable to parse response (no element found: line 1, column 0), invalid XML received:",
                    "b''"
                ])),
            botocore.parsers.ResponseParserError(
                os.linesep.join([
                    "Unable to parse response (no element found: line 1, column 0), invalid XML received:",
                    "b''"
                ])), {
                    'Events': [],
                    'ResponseMetadata': {
                        'RequestId': 'd0ac21eb-c138-42cb-a679-eea1a6e56fe0',
                        'HTTPStatusCode': 200,
                        'date': 'Wed, 21 Feb 2018 09:09:16 GMT',
                        'RetryAttempts': 0
                    }
                }
        ])
        set_operation_mock.return_value = operation_mock

        aws.make_api_call('some_aws_service', 'some_operation')
Exemple #2
0
    def test_make_api_call__failure__status_code_5xx(self, _sleep_mock,
                                                     _set_operation_mock,
                                                     _get_delay_mock):
        self.maxDiff = None

        operation = MagicMock(side_effect=botocore.exceptions.ClientError(
            self.response_data, 'some_operation'))

        _set_operation_mock.return_value = operation
        _get_delay_mock.side_effect = None
        _sleep_mock.side_effect = None

        with self.assertRaises(aws.MaxRetriesError) as cm:
            aws.make_api_call('some_service', 'some_operation')

        exception_message = r"""Max retries exceeded for service error (5XX)
Received 5XX error during attempt #1
   500 Internal Server Error

Received 5XX error during attempt #2
   500 Internal Server Error

Received 5XX error during attempt #3
   500 Internal Server Error

Received 5XX error during attempt #4
   500 Internal Server Error

Received 5XX error during attempt #5
   500 Internal Server Error

Received 5XX error during attempt #6
   500 Internal Server Error

Received 5XX error during attempt #7
   500 Internal Server Error

Received 5XX error during attempt #8
   500 Internal Server Error

Received 5XX error during attempt #9
   500 Internal Server Error

Received 5XX error during attempt #10
   500 Internal Server Error

Received 5XX error during attempt #11
   500 Internal Server Error
"""

        self.assertEqual(exception_message, str(cm.exception))
Exemple #3
0
    def test_handle_botocore_response_parser_error__max_attempts_reached(
            self, get_delay_mock, set_operation_mock):
        self.maxDiff = None
        get_delay_mock.return_value = 0

        botocore_parse_errors = []
        for i in range(1, 12):
            botocore_parse_errors.append(
                botocore.parsers.ResponseParserError(
                    os.linesep.join([
                        "Unable to parse response (no element found: line 1, column 0), invalid XML received:",
                        "b''"
                    ])))

        operation_mock = MagicMock(side_effect=botocore_parse_errors)
        set_operation_mock.return_value = operation_mock

        with self.assertRaises(aws.MaxRetriesError) as context_manager:
            aws.make_api_call('some_aws_service', 'some_operation')

        self.assertEqual(
            """Max retries exceeded for ResponseParserErrorsUnable to parse response (no element found: line 1, column 0), invalid XML received:
b''
Unable to parse response (no element found: line 1, column 0), invalid XML received:
b''
Unable to parse response (no element found: line 1, column 0), invalid XML received:
b''
Unable to parse response (no element found: line 1, column 0), invalid XML received:
b''
Unable to parse response (no element found: line 1, column 0), invalid XML received:
b''
Unable to parse response (no element found: line 1, column 0), invalid XML received:
b''
Unable to parse response (no element found: line 1, column 0), invalid XML received:
b''
Unable to parse response (no element found: line 1, column 0), invalid XML received:
b''
Unable to parse response (no element found: line 1, column 0), invalid XML received:
b''
Unable to parse response (no element found: line 1, column 0), invalid XML received:
b''""",
            str(context_manager.exception).replace('\r\n',
                                                   '\n').replace(r'\s$', ""))
Exemple #4
0
def _make_api_call(operation_name, **operation_options):
    try:
        result = aws.make_api_call('codecommit', operation_name, **operation_options)
    except ServiceError as ex:
        if ex.code == 'AccessDeniedException':
            io.echo("EB CLI does not have the right permissions to access CodeCommit."
                    " List of IAM policies needed by EB CLI, please configure and try again.\n "
                    "codecommit:CreateRepository\n codecommit:CreateBranch\n codecommit:GetRepository\n "
                    "codecommit:ListRepositories\n codecommit:ListBranches\n"
                    "To learn more, see Docs: http://docs.aws.amazon.com/codecommit/latest/userguide/access-permissions.html")
        raise ex
    return result
def _make_api_call(operation_name, **operation_options):
    try:
        result = aws.make_api_call('codebuild', operation_name, **operation_options)
    except ServiceError as ex:
        if ex.code == 'AccessDeniedException':
            io.echo(
                "EB CLI does not have the right permissions to access CodeBuild.\n"
                "To learn more, see Docs: https://docs-aws.amazon.com/codebuild/"
                "latest/userguide/auth-and-access-control-permissions-reference.html"
            )
        raise ex
    except EndpointConnectionError:
        LOG.debug(
            "Caught endpoint timeout for CodeBuild."
            " We are assuming this is because they are not supported in that region yet."
        )
        raise ServiceError("Elastic Beanstalk does not support AWS CodeBuild in this region.")
    return result
Exemple #6
0
def _make_api_call(operation_name, **operation_options):
    return aws.make_api_call('s3', operation_name, **operation_options)
def _make_api_call(operation_name, **operation_options):
    return aws.make_api_call('logs', operation_name, **operation_options)
def _make_api_call(operation_name, **operation_options):
    return aws.make_api_call('elasticbeanstalk',
                             operation_name,
                             **operation_options)
def _make_api_call(operation_name, **operation_options):
    return aws.make_api_call('cloudformation', operation_name, **operation_options)
Exemple #10
0
def _make_api_call(operation_name, **operation_options):
    return aws.make_api_call('elasticbeanstalk', operation_name,
                             **operation_options)
def _make_api_call(operation_name, **operation_options):
    return aws.make_api_call('cloudformation', operation_name, **operation_options)