Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

raising exceptions when error occurs while downloading from s3 #1281

Merged
merged 2 commits into from
Jul 29, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion streamalert/classifier/payload/s3.py
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ def _read_file(self):
client.download_fileobj(key, download)
except (IOError, ClientError):
LOGGER.exception('Failed to download object from S3')
return
raise

total_time = time.time() - start_time
LOGGER.info('Completed download in %s seconds', round(total_time, 2))
Expand Down
9 changes: 5 additions & 4 deletions tests/unit/streamalert/classifier/payload/test_payload_s3.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import tempfile

import boto3
from botocore.exceptions import ClientError

from mock import patch
from moto import mock_s3
Expand Down Expand Up @@ -168,12 +169,12 @@ def test_read_file(self):
assert_equal(read_lines, [(1, value)])

@mock_s3
@patch('logging.Logger.exception')
def test_read_file_error(self, log_mock):
def test_read_file_error(self):
"""S3Payload - Read File, Exception"""
boto3.resource('s3').Bucket(self._bucket).create()
list(S3Payload(None, self._record)._read_file())
log_mock.assert_called_with('Failed to download object from S3')
payload = S3Payload(None, self._record)
result = payload._read_file()
assert_raises(ClientError, list, result)

def test_pre_parse(self):
"""S3Payload - Pre Parse"""
Expand Down