Skip to content

Commit 8d74d80

Browse files
committed
Socket Timeout added. PyYAML upgraded to 6.0.
1 parent af74e08 commit 8d74d80

File tree

11 files changed

+23
-9
lines changed

11 files changed

+23
-9
lines changed

CHANGELIST.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,9 @@ Future Themes (In-Progress or Planned):
2121

2222
1.2.13
2323
------
24+
- BUGFIX: HTTP layer tests at times got stuck after one test. This seems to happen when the socket library is not passed a timeout.
25+
- A default socket timeout of 60 seconds is now configured.
26+
- It can be changed at project level or in CLI options using SOCKET_TIMEOUT property.
2427

2528
1.2.12
2629
------

arjuna/configure/stage.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,7 @@
9292
"HTTP_PROXY_ENABLED",
9393
"HTTP_PROXY_HOST",
9494
"HTTP_PROXY_PORT",
95+
"SOCKET_TIMEOUT"
9596
},
9697

9798
ConfigStage.REFERENCE: {

arjuna/engine/pytestplug.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515
from arjuna.tpi.error import *
1616
from arjuna.tpi.parser.yaml import Yaml
1717

18-
1918
_ARJUNA_CLI_ARGS = {
2019
"project": ("--project", {
2120
"dest":"project",

arjuna/interact/http/session.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,7 @@ def _send(self, request) -> HttpResponse:
192192
Returns
193193
`HttpResponse` object. In case of redirections, this is the last HttpResponse object, which encapsulates all redirections which can be retrieved from it.
194194
'''
195-
from arjuna import Arjuna, log_info
195+
from arjuna import Arjuna, log_info, C
196196
from arjuna.tpi.helper.arjtype import NetworkPacketInfo
197197
log_info(request.label)
198198
max_connection_retries = 5
@@ -203,10 +203,13 @@ def _send(self, request) -> HttpResponse:
203203
while counter < max_connection_retries:
204204
counter += 1
205205
try:
206+
timeout = C("socket.timeout")
207+
if request.timeout is not None:
208+
timeout = request.timeout
206209
if self._session.proxies:
207-
response = HttpResponse(self, self._session.send(request._request, allow_redirects=request.allow_redirects, timeout=request.timeout, proxies=self._session.proxies, verify=False))
210+
response = HttpResponse(self, self._session.send(request._request, allow_redirects=request.allow_redirects, timeout=timeout, proxies=self._session.proxies, verify=False))
208211
else:
209-
response = HttpResponse(self, self._session.send(request._request, allow_redirects=request.allow_redirects, timeout=request.timeout))
212+
response = HttpResponse(self, self._session.send(request._request, allow_redirects=request.allow_redirects, timeout=timeout))
210213
except (ProxyError, InvalidProxyURL) as e:
211214
raise HttpConnectError(request, "There is an error in connecting to the configured proxy. Proxy settings: {}. Error: {}".format(self.__session.proxies, str(e)))
212215
except ConnectionError as f:

arjuna/res/arjuna.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
12
function openModal(event){
23
var source = event.target || event.srcElement;
34
var modal = document.getElementById("modal-packet");

arjuna/res/arjuna.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@ arjuna_options:
6767

6868
app.url: NOT_SET
6969

70+
socket.timeout: 60
7071
http.proxy.enabled: False
7172
http.proxy.host: localhost
7273
http.proxy.port: 8080

arjuna/res/arjuna_conf_desc.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ data.file.dir: absolute_dir_path
6464

6565
app.url: web_url
6666

67+
socket.timeout: int
6768
http.proxy.enabled: bool
6869
http.proxy.host: str
6970
http.proxy.port: int

arjuna/tpi/constant.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -198,6 +198,9 @@ class ArjunaOption(Enum):
198198
APP_URL = auto()
199199
'''Base URL for a Web App. Used by launch() method if url is not specified for GuiApp.'''
200200

201+
SOCKET_TIMEOUT = auto()
202+
'''Timeout for socket connections. Default is 60 seconds.'''
203+
201204
HTTP_PROXY_ENABLED = auto()
202205
'''Is a proxy enabled for HTTP requests (GUIAuto as well as HttpAuto)'''
203206

arjuna/tpi/engine/__init__.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -230,6 +230,8 @@ def copy_file(src, dest):
230230
self.__logger = Logger(self.ref_config)
231231
from arjuna import ArjunaOption
232232
self.__allowed_log_contexts = self.ref_config.value(ArjunaOption.LOG_ALLOWED_CONTEXTS)
233+
import socket
234+
socket.setdefaulttimeout(self.ref_config.value(ArjunaOption.SOCKET_TIMEOUT))
233235

234236
from arjuna.tpi.hook.config import Configurator
235237
configurator = Configurator()

arjuna/tpi/engine/test.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -39,9 +39,9 @@ def _call_func(func, request_wrapper, data=None, *args, **kwargs):
3939
log_info("Begin test function: {}".format(qual_name))
4040
try:
4141
if data:
42-
func(request=request_wrapper, data=data, *args, **kwargs)
42+
return func(request=request_wrapper, data=data, *args, **kwargs)
4343
else:
44-
func(request=request_wrapper, *args, **kwargs)
44+
return func(request=request_wrapper, *args, **kwargs)
4545
except Exception as e:
4646
log_info("End test function (with failure/error): {}. Exception Message: {}".format(qual_name, str(e)))
4747
raise e
@@ -289,12 +289,12 @@ def format_test_func(func):
289289
@functools.wraps(orig_func)
290290
def wrapper_without_data(request, *args, **kwargs):
291291
my.set_req_obj(request)
292-
_call_func(func, my, *args, **kwargs)
292+
return _call_func(func, my, *args, **kwargs)
293293

294294
@functools.wraps(orig_func)
295295
def wrapper_with_data(request, data, *args, **kwargs):
296296
my.set_req_obj(request)
297-
_call_func(func, my, data, *args, **kwargs)
297+
return _call_func(func, my, data, *args, **kwargs)
298298

299299
if drive_with:
300300
return wrapper_with_data

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@
7070
"pytest==6.2.1",
7171
"pytest-html==2.1.1",
7272
"pytest-dependency==0.4.0",
73-
"PyYAML==5.3",
73+
"PyYAML==6.0",
7474
"mimesis==4.1.3",
7575
"jsonpath-rw==1.4.0",
7676
"jsonpath-rw-ext==1.2.2",

0 commit comments

Comments
 (0)