-
Notifications
You must be signed in to change notification settings - Fork 38
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-6756: Fix Infinite Loop for Users #103
Conversation
tap_zendesk/streams.py
Outdated
users = self.client.search("", updated_after=parsed_start, updated_before=parsed_end, type="user") | ||
|
||
# NB: Zendesk will return an error on the 1001st record, so we | ||
# need to check total response size before iterating | ||
# See: https://develop.zendesk.com/hc/en-us/articles/360022563994--BREAKING-New-Search-API-Result-Limits | ||
if users.count > 1000: | ||
if search_window_size > 1: | ||
# to avoid infinite loop behavior we should reduce the window if it is greater than 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.
# to avoid infinite loop behavior we should reduce the window if it is greater than 2 | |
# To avoid infinite loop behavior we should reduce the window if it is greater than 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.
Added suggested changes
@@ -244,20 +244,21 @@ def sync(self, state): | |||
while start < sync_end: | |||
parsed_start = singer.strftime(start, "%Y-%m-%dT%H:%M:%SZ") | |||
parsed_end = min(singer.strftime(end, "%Y-%m-%dT%H:%M:%SZ"), parsed_sync_end) |
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.
Good to have, elaborate why we need to take min of 2 timestamps.
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.
Tap is using window so if 'end' is minimum than window size then consider it otherwise it will use normal 'end' (start + date window)
|
||
class TestUserSyncCheck(unittest.TestCase): | ||
|
||
def test_many_records_in_one_seconds_for_user(self): |
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.
On local env, this unit test is failing,
$ nosetests test/unittests/test_user_infinite_loop.py:TestUserSyncCheck.test_many_records_in_one_seconds_for_user
.
.
======================================================================
FAIL: Reproduce infinite looping behavior for Users stream when user have many record in single seconds
----------------------------------------------------------------------
Traceback (most recent call last):
File "/opt/code/tap-zendesk/test/unittests/test_user_infinite_loop.py", line 36, in test_many_records_in_one_seconds_for_user
self.assertEqual(str(e.exception), 'users - Unable to get all users within minimum window of a single second (2022-03-30T08:45:21Z), found 1001 users within this timestamp. Zendesk can only provide a maximum of 1000 users per request. See: https://de/
velop.zendesk.com/hc/en-us/articles/360022563994--BREAKING-New-Search-API-Result-Limits')
AssertionError: 'user[71 chars]022-04-14T08:45:20Z), found 1001 users within [176 chars]mits' != 'user[71 chars]022-03-30T08:45:21Z), found 1001 users within [176 chars]mits'
Diff is 801 characters long. Set self.maxDiff to None to see it.
-------------------- >> begin captured stdout << ---------------------
{"type": "STATE", "value": {"bookmarks": {"users": {"updated_at": "2022-04-14T08:45:20Z"}}}}
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.
We expect static datetime in the exception message, but the unit test is internally using the current datetime. So, we mocked now() with static datetime
…p.py' and correct that behaviour
bb081e1
to
bb939de
Compare
* Reproduce infinite loop behaviour in unittest 'test_user_infinite_loop.py' and correct that behaviour * Correct exception mesaage in unittest * change logger message * correct logger message * add comment in streams.py and add 2sec window test case * add comment in streams.py and add 2sec window test case * Change exception message * Correct comment message * resolved unitetst error * update behaviour for 1 second window size * changelog and verison bump --------- Co-authored-by: Rushikesh Todkar <98420315+RushiT0122@users.noreply.github.com> Co-authored-by: kethan1122 <kcherukuri@talend.com>
Description of change
Manual QA steps
Risks
Rollback steps