-
Notifications
You must be signed in to change notification settings - Fork 25
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
Tdl 16328 implement request timeout #38
Changes from all commits
2405054
1392579
3a9c8fc
e658b3d
f7977e2
4ab905a
2d6145e
b301a06
68439cf
30e21ad
def4770
45b9b80
3f42e0f
764bae6
0e85aee
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,11 @@ | ||
version: 2 | ||
version: 2.1 | ||
orbs: | ||
slack: circleci/slack@3.4.2 | ||
|
||
jobs: | ||
build: | ||
docker: | ||
- image: 218546966473.dkr.ecr.us-east-1.amazonaws.com/circle-ci:tap-tester-v4 | ||
- image: 218546966473.dkr.ecr.us-east-1.amazonaws.com/circle-ci:stitch-tap-tester | ||
- image: amazon/dynamodb-local | ||
entrypoint: ["java", "-Xmx1G", "-jar", "DynamoDBLocal.jar"] | ||
steps: | ||
|
@@ -19,25 +22,34 @@ jobs: | |
command: | | ||
source /usr/local/share/virtualenvs/tap-dynamodb/bin/activate | ||
make lint | ||
- run: | ||
name: 'Unit Tests' | ||
command: | | ||
source /usr/local/share/virtualenvs/tap-dynamodb/bin/activate | ||
pip install nose coverage | ||
nosetests --with-coverage --cover-erase --cover-package=tap_dynamodb --cover-html-dir=htmlcov tests/unittests | ||
coverage html | ||
- store_test_results: | ||
path: test_output/report.xml | ||
- store_artifacts: | ||
path: htmlcov | ||
- run: | ||
name: 'Tap Tester' | ||
command: | | ||
aws s3 cp s3://com-stitchdata-dev-deployment-assets/environments/tap-tester/sandbox tap-tester.env | ||
aws s3 cp s3://com-stitchdata-dev-deployment-assets/environments/tap-tester/tap_tester_sandbox tap-tester.env | ||
source tap-tester.env | ||
source /usr/local/share/virtualenvs/tap-tester/bin/activate | ||
run-test --tap=tap-dynamodb \ | ||
--target=target-stitch \ | ||
--orchestrator=stitch-orchestrator \ | ||
--email=harrison+sandboxtest@stitchdata.com \ | ||
--password=$SANDBOX_PASSWORD \ | ||
--client-id=50 \ | ||
tests | ||
run-test --tap=tap-dynamodb tests | ||
- slack/notify-on-failure: | ||
only_for_branches: master | ||
workflows: | ||
version: 2 | ||
commit: | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can you add the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Added the tap-tester-user context |
||
jobs: | ||
- build: | ||
context: circleci-user | ||
context: | ||
- circleci-user | ||
- tap-tester-user | ||
build_daily: | ||
triggers: | ||
- schedule: | ||
|
@@ -48,4 +60,6 @@ workflows: | |
- master | ||
jobs: | ||
- build: | ||
context: circleci-user | ||
context: | ||
- circleci-user | ||
- tap-tester-user |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,14 +8,16 @@ | |
DeferredRefreshableCredentials, | ||
JSONFileCache | ||
) | ||
from botocore.exceptions import ClientError | ||
from botocore.session import Session | ||
from botocore.config import Config | ||
from botocore.exceptions import ClientError, ConnectTimeoutError, ReadTimeoutError | ||
|
||
LOGGER = singer.get_logger() | ||
REQUEST_TIMEOUT = 300 | ||
|
||
def retry_pattern(): | ||
return backoff.on_exception(backoff.expo, | ||
ClientError, | ||
(ClientError, ConnectTimeoutError, ReadTimeoutError), | ||
max_tries=5, | ||
on_backoff=log_backoff_attempt, | ||
factor=10) | ||
|
@@ -65,17 +67,42 @@ def setup_aws_client(config): | |
LOGGER.info("Attempting to assume_role on RoleArn: %s", role_arn) | ||
boto3.setup_default_session(botocore_session=refreshable_session) | ||
|
||
def get_request_timeout(config): | ||
# if request_timeout is other than 0,"0" or "" then use request_timeout | ||
request_timeout = config.get('request_timeout') | ||
if request_timeout and float(request_timeout): | ||
request_timeout = float(request_timeout) | ||
else: # If value is 0,"0" or "" then set default to 300 seconds. | ||
request_timeout = REQUEST_TIMEOUT | ||
return request_timeout | ||
|
||
def get_client(config): | ||
# get the request_timeout | ||
request_timeout = get_request_timeout(config) | ||
# add the request_timeout in both connect_timeout as well as read_timeout | ||
timeout_config = Config(connect_timeout=request_timeout, read_timeout=request_timeout) | ||
if config.get('use_local_dynamo'): | ||
return boto3.client('dynamodb', | ||
endpoint_url='http://localhost:8000', | ||
region_name=config['region_name']) | ||
return boto3.client('dynamodb', config['region_name']) | ||
region_name=config['region_name'], | ||
config=timeout_config # pass the config to add the request_timeout | ||
) | ||
return boto3.client('dynamodb', config['region_name'], | ||
config=timeout_config # pass the config to add the request_timeout | ||
) | ||
|
||
def get_stream_client(config): | ||
# get the request_timeout | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What is the difference between get_stream_client and get_client function? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @KrisPersonal Amazon DynamoDB Streams provides API actions for accessing streams and processing stream records, which can be done through |
||
request_timeout = get_request_timeout(config) | ||
# add the request_timeout in both connect_timeout as well as read_timeout | ||
timeout_config = Config(connect_timeout=request_timeout, read_timeout=request_timeout) | ||
if config.get('use_local_dynamo'): | ||
return boto3.client('dynamodbstreams', | ||
endpoint_url='http://localhost:8000', | ||
region_name=config['region_name']) | ||
region_name=config['region_name'], | ||
config=timeout_config # pass the config to add the request_timeout | ||
) | ||
return boto3.client('dynamodbstreams', | ||
region_name=config['region_name']) | ||
region_name=config['region_name'], | ||
config=timeout_config # pass the config to add the request_timeout | ||
) |
Original file line number | Diff line number | Diff line change | ||
---|---|---|---|---|
|
@@ -2,8 +2,10 @@ | |||
|
||||
import singer | ||||
from singer import metadata | ||||
from tap_dynamodb import dynamodb | ||||
import backoff | ||||
from botocore.exceptions import ConnectTimeoutError, ReadTimeoutError | ||||
from tap_dynamodb.deserialize import Deserializer | ||||
from tap_dynamodb import dynamodb | ||||
|
||||
LOGGER = singer.get_logger() | ||||
|
||||
|
@@ -35,7 +37,11 @@ def scan_table(table_name, projection, last_evaluated_key, config): | |||
|
||||
has_more = result.get('LastEvaluatedKey', False) | ||||
|
||||
|
||||
# Backoff for both ReadTimeout and ConnectTimeout error for 5 times | ||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @namrata270998 Please add this bckoff expression above the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @karanpanchal-crest The function
for reference |
||||
@backoff.on_exception(backoff.expo, | ||||
(ReadTimeoutError, ConnectTimeoutError), | ||||
max_tries=5, | ||||
factor=2) | ||||
def sync(config, state, stream): | ||||
table_name = stream['tap_stream_id'] | ||||
|
||||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please update this file in line with the changes required on PR #37 and #35
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@kspeer825 Updated this file as requested