-
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
Tdl 16328 implement request timeout #38
Conversation
tap_dynamodb/dynamodb.py
Outdated
# 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 |
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.
@namrata270998, Create a separate function to calculate request timeout based on provided config as we are calculating the same thing in multiple functions.
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.
done
@backoff.on_exception(backoff.expo, | ||
(ReadTimeoutError, ConnectTimeoutError), | ||
max_tries=5, | ||
factor=2) |
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.
@backoff.on_exception(backoff.expo, | |
(ReadTimeoutError, ConnectTimeoutError), | |
max_tries=5, | |
factor=2) | |
@backoff.on_exception(backoff.expo, | |
(ReadTimeoutError, ConnectTimeoutError), | |
max_tries=5, | |
factor=2) |
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.
done
@backoff.on_exception(backoff.expo, | ||
(ReadTimeoutError, ConnectTimeoutError), | ||
max_tries=5, | ||
factor=2) |
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.
@backoff.on_exception(backoff.expo, | |
(ReadTimeoutError, ConnectTimeoutError), | |
max_tries=5, | |
factor=2) | |
@backoff.on_exception(backoff.expo, | |
(ReadTimeoutError, ConnectTimeoutError), | |
max_tries=5, | |
factor=2) |
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.
done
@backoff.on_exception(backoff.expo, | ||
(ReadTimeoutError, ConnectTimeoutError), | ||
max_tries=5, | ||
factor=2) |
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.
@backoff.on_exception(backoff.expo, | |
(ReadTimeoutError, ConnectTimeoutError), | |
max_tries=5, | |
factor=2) | |
@backoff.on_exception(backoff.expo, | |
(ReadTimeoutError, ConnectTimeoutError), | |
max_tries=5, | |
factor=2) |
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.
done
.circleci/config.yml
Outdated
make lint | ||
pylint tap_dynamodb --disable 'duplicate-code,missing-module-docstring,missing-class-docstring,too-few-public-methods,line-too-long,fixme,missing-function-docstring,raise-missing-from,consider-using-f-string,too-many-locals,invalid-name,too-many-arguments' |
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.
@namrata270998 Do we need this change for any specific reason?.
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.
reverted the change
@@ -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 comment
The reason will be displayed to describe this comment to others. Learn more.
@namrata270998 Please add this bckoff expression above the scan_table
function instead. Update the test cases accordingly.
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.
@karanpanchal-crest The function scan_table
contains a yield
. Hence the backoff won't work on that function
Please refer
yield result |
for reference
from unittest import mock | ||
from unittest.mock import Mock | ||
from unittest.case import TestCase | ||
from botocore.exceptions import ClientError, ConnectTimeoutError, ReadTimeoutError |
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.
Remove ClientError
if not used
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.
done
Makefile
Outdated
@@ -4,6 +4,6 @@ lint-tests: | |||
pylint tests -d broad-except,chained-comparison,empty-docstring,fixme,invalid-name,line-too-long,missing-class-docstring,missing-function-docstring,missing-module-docstring,no-else-raise,no-else-return,too-few-public-methods,too-many-arguments,too-many-branches,too-many-lines,too-many-locals,ungrouped-imports,wrong-spelling-in-comment,wrong-spelling-in-docstring,duplicate-code,no-name-in-module,import-error,consider-using-f-string | |||
|
|||
lint-code: | |||
pylint tap_dynamodb -d broad-except,chained-comparison,empty-docstring,fixme,invalid-name,line-too-long,missing-class-docstring,missing-function-docstring,missing-module-docstring,no-else-raise,no-else-return,too-few-public-methods,too-many-arguments,too-many-branches,too-many-lines,too-many-locals,ungrouped-imports,wrong-spelling-in-comment,wrong-spelling-in-docstring,raise-missing-from,consider-using-f-string | |||
pylint tap_dynamodb -d broad-except,chained-comparison,empty-docstring,fixme,invalid-name,line-too-long,missing-class-docstring,missing-function-docstring,missing-module-docstring,no-else-raise,no-else-return,too-few-public-methods,too-many-arguments,too-many-branches,too-many-lines,too-many-locals,ungrouped-imports,wrong-spelling-in-comment,wrong-spelling-in-docstring,raise-missing-from,consider-using-f-string,duplicate-code |
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.
Remove the duplicate-code
from the global level. Instead handle it where needed
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.
done
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.
The tests look great. One improvement I see would be using variables on repeated values in those unittests to ensure typo's cannot hurt us.
@@ -19,6 +19,17 @@ jobs: | |||
command: | | |||
source /usr/local/share/virtualenvs/tap-dynamodb/bin/activate | |||
make lint | |||
- run: |
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.
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
""" | ||
Check whether the request backoffs properly for discover_streams for 5 times in case of ReadTimeoutError error. | ||
""" | ||
with self.assertRaises(ReadTimeoutError): |
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.
I like this pattern
config = {"region_name": "dummy_region", "request_timeout": "100"} | ||
dynamodb.get_client(config) | ||
mock_config.assert_called_with(connect_timeout=100, read_timeout=100) |
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.
The only thing I can think to change is it would be better to set the default timeout value as a reusable variable for expectations. Also repeated values could be replaced with variables as well within each test. Just a suggestion though. I think they are readable and maintainable as-is, which is the important part.
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 the code and replaced values with reusable variables.
|
||
def get_stream_client(config): | ||
# get the request_timeout |
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.
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 comment
The 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 get_stream_client
. Whereas, the get_client
returns a low-level client representing Amazon DynamoDB
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.
Just a couple config changes. Tests look good.
.circleci/config.yml
Outdated
- 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 |
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.
These environment variables are not the up-to-date set. Please use tap-tester-sandbox
over sandbox
.
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.
Update to tap-tester-sandbox env variables set
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 comment
The reason will be displayed to describe this comment to others. Learn more.
Can you add the tap-tester-user
context as well.
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.
Added the tap-tester-user context
* Tdl 16328 implement request timeout (#38) * added request timeout * added test cases for the backoff * resolved pylint errors * updated pylint * fixd pylint * updated config.yml * resolved comments * resolved comments * resolved pylint errors * resolved comments * resolved comments * resolved comments * resolved slack-on-notify failure * removed scenarios * added tap-tester-user in config * TDL-16291 added code comments (#36) * added code comments * fixed typo * TDL-13692: Missing parent objects from projection expression causes key error and TDL-16140: Fix key error and index error while applying projection expression (#35) * added code change for handling key error and index error * resolve pylint error * updated the unittests * updated config.yml to run unittest to run on CCi * added unittests * updated the code to handle child dict data * added comments with example for projection * updated config.yml file and resolved PR review comments * resolve slack failure error in config file * updated version 2 to 2.1 * remoed SCENARIO from the test cases * resolved comments * reverted changes * added tap-tester-venv, tap_tester_sandbox and check for verifying that we replicated records Co-authored-by: namrata270998 <namrata.brahmbhatt@crestdatasys.com> * Tdl 15171 implement expression attributes (#37) * Initial commit for expression attributes * Updated circleci and full_table.py * resolved pylint error * Updated circleci * Updated unittest case path in circleci * Updated expression attribute * resolved pylint error * Updated prepare exprssion logic * Handled empty projection * added logic for nested expressions * added in log_based test and comments * added code comments * Updated comments * Resolved review comments * added comment * resolved comments * resolved pylint errors * updated config.yml and a typo * resolved slack-on-notify failure * removed scenarios * Changed the expressionattribute logic as suggested * resolved pylint error * fixed typo * added test case for '.' in fields * added testcase for prepare_projection() * resolved comments * added check for empty expression * handled corner case * resolved comments and updated unittests * removed unused import * resolved comments * fixed pylint failure * updated comment * changed the name of catalog's expression to expression-attributes * added tap-tester-user to the config, updated to nosetests * updated to nosetests * Changed expression-attributes to expression-attribute * Changed expression-attributes to expression-attribute * added tests for primary and replication key reserved words * renamed the file * added funciton comments * fixed pylint * changed the parameter name to attribute * changed the attribute name in new files added * expression-attribute -> expression-attributes in full table * test fixes for pk and hash key as expression-attributes * expression-attribute -> expression-attributes in one more test * fix log sync ref and log projection test name * Changed from attribute to attributes Co-authored-by: namrata270998 <namrata.brahmbhatt@crestdatasys.com> Co-authored-by: KrishnanG <kgurusamy@talend.com> Co-authored-by: kspeer <kspeer@stitchdata.com> Co-authored-by: Harsh <80324346+harshpatel4crest@users.noreply.github.com> Co-authored-by: Prijen Khokhani <88327452+prijendev@users.noreply.github.com> Co-authored-by: KrishnanG <kgurusamy@talend.com> Co-authored-by: kspeer <kspeer@stitchdata.com>
Description of change
Added request timeout for SDK library functions with default timeout 300 seconds
Manual QA steps
Risks
Rollback steps