Skip to content

Commit 9ae0816

Browse files
authored
when checking for changes, ensure request timeout is higher than the … (#303)
1 parent 70070fe commit 9ae0816

File tree

5 files changed

+18
-17
lines changed

5 files changed

+18
-17
lines changed

cterasdk/asynchronous/core/notifications.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,11 @@ async def changes(self, cursor, cloudfolders=None, timeout=None):
6969
param = await self._create_parameter(cloudfolders, cursor)
7070
param.timeout = timeout if timeout else 10000
7171
logger.debug('Checking for updates. %s', {'timeout': param.timeout})
72-
return (await self._core.v2.api.post('/metadata/longpoll', param)).changes
72+
return (await self._core.v2.api.post('/metadata/longpoll', param, **{
73+
'timeout': {
74+
'sock_read': param.timeout + 10000
75+
}
76+
})).changes
7377

7478
async def ancestors(self, descendant):
7579
"""

cterasdk/edge/network.py

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -126,11 +126,7 @@ def tcp_connect(self, service):
126126

127127
logger.info("Testing connection. %s", {'host': service.host, 'port': service.port})
128128

129-
task = self._edge.api.execute("/status/network", "tcpconnect", param, {
130-
'timeout': {
131-
'sock_read': 120
132-
}
133-
})
129+
task = self._edge.api.execute("/status/network", "tcpconnect", param)
134130
try:
135131
task = self._edge.tasks.wait(task)
136132
logger.debug("Obtained connection status. %s", {'status': task.result.rc})

cterasdk/settings.yml

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,12 @@ core:
3333
# CTERA Edge Filer synchronous client configuration.
3434
edge:
3535
syn:
36-
<<: *default_settings
36+
settings:
37+
<<: *cookie_jar
38+
<<: *connector
39+
timeout:
40+
sock_connect: 30
41+
sock_read: 60
3742
services:
3843
ssl: prompt
3944
asyn:

tests/ut/aio/test_notifications.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,9 @@ async def generator():
7777
async def test_changes_defaults_no_changes(self):
7878
self._init_global_admin(post_response=TestAsyncCoreNotifications._create_changes_response(False))
7979
await notifications.Notifications(self._global_admin).changes(self._cursor)
80-
self._global_admin.v2.api.post.assert_called_once_with('/metadata/longpoll', mock.ANY)
80+
self._global_admin.v2.api.post.assert_called_once_with('/metadata/longpoll', mock.ANY, timeout={
81+
'sock_read': 20000
82+
})
8183
expected_param = TestAsyncCoreNotifications._create_parameter(cursor=self._cursor, timeout=10000)
8284
actual_param = self._global_admin.v2.api.post.call_args[0][1]
8385
self.assert_equal_objects(actual_param, expected_param)

tests/ut/edge/test_network.py

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -49,12 +49,6 @@ def setUp(self):
4949
self._proxy_user = 'admin'
5050
self._proxy_pass = 'password'
5151

52-
self._timeout = {
53-
'timeout': {
54-
'sock_read': 120
55-
}
56-
}
57-
5852
def test_network_status(self):
5953
get_response = 'Success'
6054
self._init_filer(get_response=get_response)
@@ -143,7 +137,7 @@ def test_tcp_connect_success(self):
143137

144138
ret = network.Network(self._filer).tcp_connect(TCPService(self._tcp_connect_address, self._tcp_connect_port))
145139

146-
self._filer.api.execute.assert_called_once_with('/status/network', 'tcpconnect', mock.ANY, self._timeout)
140+
self._filer.api.execute.assert_called_once_with('/status/network', 'tcpconnect', mock.ANY)
147141
self._filer.tasks.wait.assert_called_once_with(self._task_id)
148142

149143
expected_param = self._get_tcp_connect_object()
@@ -163,7 +157,7 @@ def test_tcp_connect_failure(self):
163157

164158
ret = network.Network(self._filer).tcp_connect(TCPService(self._tcp_connect_address, self._tcp_connect_port))
165159

166-
self._filer.api.execute.assert_called_once_with('/status/network', 'tcpconnect', mock.ANY, self._timeout)
160+
self._filer.api.execute.assert_called_once_with('/status/network', 'tcpconnect', mock.ANY)
167161
self._filer.tasks.wait.assert_called_once_with(self._task_id)
168162

169163
expected_param = self._get_tcp_connect_object()
@@ -206,7 +200,7 @@ def test_tcp_connect_task_error(self):
206200

207201
ret = network.Network(self._filer).tcp_connect(TCPService(self._tcp_connect_address, self._tcp_connect_port))
208202

209-
self._filer.api.execute.assert_called_once_with('/status/network', 'tcpconnect', mock.ANY, self._timeout)
203+
self._filer.api.execute.assert_called_once_with('/status/network', 'tcpconnect', mock.ANY)
210204
self._filer.tasks.wait.assert_called_once_with(self._task_id)
211205

212206
expected_param = self._get_tcp_connect_object()

0 commit comments

Comments
 (0)