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

TDL-16355 Implement request timeouts #43

Merged
merged 6 commits into from
Dec 20, 2021

Conversation

prijendev
Copy link
Contributor

@prijendev prijendev commented Nov 16, 2021

Description of change

  • Implemented request timeout.
  • Added unittest case for the same.
  • If config parameter does not pass or pass the value "", "0", 0, "0.0" then set timeout to default value 5min

Manual QA steps

  • Set small timeout and verify that sync calls are backing off for timeout error.
  • Provide timeout in integer, float, and string format and verify that it's used in the request.

Risks

Rollback steps

  • revert this branch

@prijendev prijendev changed the title Initial commit for request timeout TDL-16355 Implement request timeouts Nov 17, 2021
self.assertEqual(kwargs.get('timeout'), REQUEST_TIMEOUT_FLOAT) # Verify timeout argument

# Verify that requests.Session.request is called 5 times
self.assertEqual(mocked_request.call_count, 5)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@prijendev Please modularize this code to check the backoff mechanism in a separate file

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated.

pass

# Verify that requests.Session.request is called 5 times
self.assertEqual(mocked_request.call_count, 5)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@prijendev the test case name and the assertion that you are making is different. Can you please verify it?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, updated test case name.


# Verify requests.Session.request is called with expected timeout
args, kwargs = mocked_request.call_args
self.assertEqual(kwargs.get('timeout'), REQUEST_TIMEOUT_FLOAT) # Verify timeout argument

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@prijendev Can you please add comment in the code regarding why you are expecting float value when you pass integer value in the config

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If none zero positive integer or string value passed in the config then it converted to float value. So, here it verifies the same. Added comment in the code also.


# Verify requests.Session.request is called with expected timeout
args, kwargs = mocked_request.call_args
self.assertEqual(kwargs.get('timeout'), REQUEST_TIMEOUT_INT) # Verify timeout argument

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@prijendev Why int value is expected in this test case?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If the request_timeout value is not passed in the config then the default value that is int value(300) is used.

Copy link
Contributor

@kspeer825 kspeer825 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approving, but with one comment. This workflow is using an old image for tap-tester. Please fix before moving forward.

@@ -12,6 +12,7 @@ jobs:
source /usr/local/share/virtualenvs/tap-mailchimp/bin/activate
pip install -U 'pip<19.2' 'setuptools<51.0.0'
pip install .[dev]
pip install coverage
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please use latest tap-tester image.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated tap-tester image

@KrisPersonal KrisPersonal merged commit aa7f299 into master Dec 20, 2021
@dsprayberry dsprayberry deleted the TDL-16355-implement-request-timeouts branch September 7, 2023 14:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants