Conversation
| timeout_value = float(timeout) | ||
| # update the request timeout for the requests | ||
| self.request_timeout = timeout_value | ||
| else: |
There was a problem hiding this comment.
Can you please add the comment related to 0, "0", "" values for else part.
tap_sftp/client.py
Outdated
| timeout_value = float(timeout) | ||
| # set the request timeout for the requests | ||
| # if value is 0,"0", "" or None then it will set default to default to 300.0 seconds if not passed in config. | ||
| self.request_timeout = timeout_value |
There was a problem hiding this comment.
| timeout_value = float(timeout) | |
| # set the request timeout for the requests | |
| # if value is 0,"0", "" or None then it will set default to default to 300.0 seconds if not passed in config. | |
| self.request_timeout = timeout_value | |
| self.request_timeout = float(timeout) |
| sorted_files = sorted(matching_files, key = lambda x: (x['last_modified']).timestamp()) | ||
| return sorted_files | ||
|
|
||
| @backoff.on_exception(backoff.expo, |
There was a problem hiding this comment.
@harshpatel4crest Add comments for this backoff
|
|
||
| return records_streamed | ||
|
|
||
| @backoff.on_exception(backoff.expo, |
There was a problem hiding this comment.
@harshpatel4crest add comments for this backoff
tap_sftp/client.py
Outdated
| self.transport.connect(username= self.username, password = self.password, hostkey = None, pkey = None) | ||
| self.sftp = paramiko.SFTPClient.from_transport(self.transport) | ||
| self.__active_connection = True | ||
| # get 'socket' |
There was a problem hiding this comment.
Please elaborate more, why do we need to get a socket?
There was a problem hiding this comment.
To set the timeout we need socket.
| Test case to verify the timeout value is set as expected | ||
| """ | ||
|
|
||
| def test_timeout_value_not_passed_in_config(self): |
There was a problem hiding this comment.
Please add comments for each function, what it is testing.
There was a problem hiding this comment.
Added comment for each test case function.
tap_sftp/client.py
Outdated
|
|
||
| def close(self): | ||
| if self.__active_connection: | ||
| # get socket |
There was a problem hiding this comment.
Please elaborate more, why do we need to get a socket?
There was a problem hiding this comment.
To set the timeout we need socket.
tap_sftp/client.py
Outdated
| # get 'socket' to set the timeout | ||
| socket = self.sftp.get_channel() | ||
| # set request timeout to 'None' ie. default value | ||
| socket.settimeout(None) |
There was a problem hiding this comment.
@harshpatel4crest Why do you have to set the timeout manually? Why not using the same request_timeout parameter?
There was a problem hiding this comment.
Here, before closing the connection, the timeout is set to None (Default value).
There was a problem hiding this comment.
Please use the default value/configured value provided in the tap. Request timeout should never have None value
There was a problem hiding this comment.
Removed the code as during the connection we are setting the desired timeout value.
tap_sftp/client.py
Outdated
|
|
||
| class SFTPConnection(): | ||
| def __init__(self, host, username, password=None, private_key_file=None, port=None): | ||
| def __init__(self, host, username, password=None, private_key_file=None, port=None, timeout=None): |
There was a problem hiding this comment.
@harshpatel4crest Why timeout = None? You can set it to REQUEST_TIMEOUT instead to denote that default value will be taken if not provided
There was a problem hiding this comment.
Added REQUEST_TIMEOUT instead of None.
| private_key_file=config.get('private_key_file'), | ||
| port=config.get('port')) | ||
| port=config.get('port'), | ||
| timeout=config.get('request_timeout')) |
There was a problem hiding this comment.
@harshpatel4crest Why have you used request_timeout from config directly? Can't we useself.request_timeout?
There was a problem hiding this comment.
Here we are initializing the connection. Hence we are passing the timeout value from the config.
| source /usr/local/share/virtualenvs/tap-sftp/bin/activate | ||
| pip install nose | ||
| nosetests tests/unittests/ | ||
| pip install nose coverage |
There was a problem hiding this comment.
Please update the tap-tester image to the latest stitch-tap-tester
There was a problem hiding this comment.
@kspeer825 When we are updating image we are getting ModuleNotFoundError: No module named 'paramiko' error. Please find the error reference
There was a problem hiding this comment.
That dependency will need to be imported directly in the circleci config. The preferred method for this is to use a test group under extras_require in the setup.py. Then this will have to be installed via pip under the integration test step in the workflow definition. This was one of the breaking changes to tap-tester that resulted in the image actually - removing tap dependencies from the test framework repo.
.circleci/config.yml
Outdated
| run-test --tap=tap-sftp \ | ||
| --target=target-stitch \ | ||
| --orchestrator=stitch-orchestrator \ | ||
| --email=harrison+sandboxtest@stitchdata.com \ | ||
| --password=$SANDBOX_PASSWORD \ | ||
| --token=$DEV_TOKEN \ | ||
| --client-id=50 \ | ||
| tests |
There was a problem hiding this comment.
something like pip install ../.[test] prior to the run-test command where the test group contains the same paramiko 2.6 dependency that is required by the tap.
There was a problem hiding this comment.
Added the test group to install paramiko.
Description of change
TDL-16353: Add request timeout
Manual QA steps
Risks
Rollback steps