holado 0.8.2__py3-none-any.whl → 0.8.4__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of holado might be problematic. Click here for more details.
- holado/common/handlers/undefined.py +3 -3
- {holado-0.8.2.dist-info → holado-0.8.4.dist-info}/METADATA +1 -1
- {holado-0.8.2.dist-info → holado-0.8.4.dist-info}/RECORD +12 -12
- holado_docker/tools/docker_controller/client/rest/docker_controller_client.py +7 -3
- holado_docker/tools/docker_controller/server/rest/api/os.py +6 -0
- holado_docker/tools/docker_controller/server/rest/openapi.yaml +4 -1
- holado_logging/common/logging/holado_logger.py +3 -2
- holado_rest/api/rest/rest_client.py +36 -9
- holado_rest/tests/behave/steps/private/api/rest_steps.py +15 -7
- holado_system/system/global_system.py +1 -1
- {holado-0.8.2.dist-info → holado-0.8.4.dist-info}/WHEEL +0 -0
- {holado-0.8.2.dist-info → holado-0.8.4.dist-info}/licenses/LICENSE +0 -0
|
@@ -39,12 +39,12 @@ not_applicable = Undefined("Not Applicable", 2)
|
|
|
39
39
|
to_be_defined = Undefined("To be defined", 3) # Usage: initial variable value defining it is to be defined. It is useful when undefined_value can be a possible value.
|
|
40
40
|
|
|
41
41
|
|
|
42
|
-
|
|
43
42
|
# Define specific default values
|
|
44
43
|
# Note: Real value is defined by methods managing these values as argument.
|
|
45
44
|
|
|
46
|
-
|
|
47
|
-
|
|
45
|
+
default = Undefined("Default", 10)
|
|
46
|
+
default_value = Undefined("Default value", 11)
|
|
47
|
+
default_context = Undefined("Default context", 12) # Example of real value: for ThreadsManager it means "current ScenarioContext" if a scenario context exists else "SessionContext".
|
|
48
48
|
|
|
49
49
|
|
|
50
50
|
# Define symbolic values
|
|
@@ -8,7 +8,7 @@ holado/common/context/session_context.py,sha256=pNiJlyLsIiwdBCUb3aMQmTJB7ZnO0NsD
|
|
|
8
8
|
holado/common/handlers/__init__.py,sha256=d0KDUpaAAw1eBXyX08gaRh4RECnJlXjYQ0TcU-Ndicc,1372
|
|
9
9
|
holado/common/handlers/enums.py,sha256=ieqKVoukEiNyfE3KrKmMOImdbFS1ocUMud8JHe2xNLs,1662
|
|
10
10
|
holado/common/handlers/object.py,sha256=rDaav8zHTYfKVEaLtEdeXMxYXATGVcs2a7um1f5MvCs,7205
|
|
11
|
-
holado/common/handlers/undefined.py,sha256=
|
|
11
|
+
holado/common/handlers/undefined.py,sha256=IzWu2HA8P7eaSEbJvdbZZ89ce-EGjb4Q_LgMA9Y1M0s,2563
|
|
12
12
|
holado/common/tools/__init__.py,sha256=z-T6zX_tOVkJjniTDA0KSKmdtosjfEhjaNa1-3g8wTs,1374
|
|
13
13
|
holado/common/tools/gc_manager.py,sha256=TjQg7MisGRhxuiQ22hB3IuqNhnWCVEWpU253-rOjR0w,7611
|
|
14
14
|
holado_ais/__init__.py,sha256=Mudcgu_7p1hBDBs6LpSz757H4haB0yLHgT70sznG82c,1807
|
|
@@ -194,7 +194,7 @@ holado_docker/sdk/docker/docker_service.py,sha256=SvMSIZ7XTCbC7q5rur03lJhJVSHL3u
|
|
|
194
194
|
holado_docker/tests/behave/steps/__init__.py,sha256=lrP0btKLA3qQD2wp3zbOp0ug8RmgpaYWCrOAWehcPiI,1298
|
|
195
195
|
holado_docker/tests/behave/steps/tools/docker_controller/client_steps.py,sha256=Y26ZstOZrI3uVX6MGBQr88jjDEsCsNuik0ZBmpT5kDg,4800
|
|
196
196
|
holado_docker/tools/docker_controller/docker_controller_manager.py,sha256=q3oac2KIK9wGfMQqGIol65nHUmeuuV0rQ61tfH2APAk,2477
|
|
197
|
-
holado_docker/tools/docker_controller/client/rest/docker_controller_client.py,sha256=
|
|
197
|
+
holado_docker/tools/docker_controller/client/rest/docker_controller_client.py,sha256=1NiBNGRXozOK-92cyGdvW00Q8KuJNjfjMxgsuL4tqjw,4560
|
|
198
198
|
holado_docker/tools/docker_controller/server/Dockerfile,sha256=zuSkj3HYDhvpjOSXmxL4oDqhN7dRB1YTX5Fyur1cuDY,1774
|
|
199
199
|
holado_docker/tools/docker_controller/server/requirements.txt,sha256=0RvLV3t2DyBR2FsbAd1WVEcbsVc6FVUN2horQJU4POo,57
|
|
200
200
|
holado_docker/tools/docker_controller/server/run_docker_controller_in_docker.sh,sha256=Q56P8VA895I29kVSaSa2FpzvjxJUwLVZ9-7vjScXfc0,3406
|
|
@@ -204,12 +204,12 @@ holado_docker/tools/docker_controller/server/grpc/proto/compile_proto.py,sha256=
|
|
|
204
204
|
holado_docker/tools/docker_controller/server/grpc/proto/definitions/docker_controler.proto,sha256=n9bsXaQfnZX-R5HvfquCVt3QjpFtDJSH6p8gnTjm06k,1650
|
|
205
205
|
holado_docker/tools/docker_controller/server/rest/README,sha256=-uqu3drdPXkPkU4ha1IKcXGBHFIBEWH-uiTT74DExwE,167
|
|
206
206
|
holado_docker/tools/docker_controller/server/rest/initialize_holado.py,sha256=UxNphXyjs-xraorzMWjDe6-QYw_Q3mtykyY-ENYZB1o,3464
|
|
207
|
-
holado_docker/tools/docker_controller/server/rest/openapi.yaml,sha256=
|
|
207
|
+
holado_docker/tools/docker_controller/server/rest/openapi.yaml,sha256=8mhJdAYi-wftxdStsD6el0j1Zo8zqx1MzwqZndyKhMY,6864
|
|
208
208
|
holado_docker/tools/docker_controller/server/rest/run.py,sha256=8w5Xl7uOnjsYW59cmuUMOUd71fcXQn30k2jVis7cVNs,1748
|
|
209
209
|
holado_docker/tools/docker_controller/server/rest/api/__init__.py,sha256=FlLRagAiw1LDxnF0CmW7Y6bVXuj8x6volT8-DuHTTVY,2427
|
|
210
210
|
holado_docker/tools/docker_controller/server/rest/api/config.py,sha256=Ln__1bsigSzJZ-Iy3MQgmiZMnpBxC3TCQE0O72g5cAs,2459
|
|
211
211
|
holado_docker/tools/docker_controller/server/rest/api/container.py,sha256=6D612WF4chpDCzr4MBzZXzELxi-yOwrgxCxSBBVMcVo,2673
|
|
212
|
-
holado_docker/tools/docker_controller/server/rest/api/os.py,sha256=
|
|
212
|
+
holado_docker/tools/docker_controller/server/rest/api/os.py,sha256=EA3DCxGBCnMd2XJyn9kb6IWmtbaPIyv5UfZypCNzkhY,2123
|
|
213
213
|
holado_docker/tools/docker_viewer/docker_viewer_manager.py,sha256=tSLuIUdYjJoZIFUc1k4WnrRTUtjjTAmNTbrDmS-8SjI,2287
|
|
214
214
|
holado_docker/tools/docker_viewer/client/rest/docker_viewer_client.py,sha256=XNBt7QE-Elz9wUT32hdft7vU0ytcY8f-0AvlDZ8NWMo,2005
|
|
215
215
|
holado_docker/tools/docker_viewer/server/Dockerfile,sha256=012m7y_jg1Jh0NoqJSUTnmG9OppX2zlcFe-KhB71cVA,1750
|
|
@@ -300,7 +300,7 @@ holado_keycloak/tests/behave/steps/tools/keycloak_client_steps.py,sha256=Dc1xB3q
|
|
|
300
300
|
holado_keycloak/tools/keycloak/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
301
301
|
holado_keycloak/tools/keycloak/keycloak_client.py,sha256=QXAsf9rF0pKq1dHhXeZFZOxuEg_1uzp6vqXnwWDnegg,4019
|
|
302
302
|
holado_logging/__init__.py,sha256=EMmwm_jHe739gftVCmf6lb_dT20IVseVg0bbGGADn8w,2176
|
|
303
|
-
holado_logging/common/logging/holado_logger.py,sha256=
|
|
303
|
+
holado_logging/common/logging/holado_logger.py,sha256=FB5J_YbG41FGljAywMdCPVFJ2BdpMBS8AWPsT9B52S8,3160
|
|
304
304
|
holado_logging/common/logging/log_config.py,sha256=DdYEW-2YSZ6QZDZCeVn_IZOKQlwWvqi2NWEbPhvExxw,6578
|
|
305
305
|
holado_logging/common/logging/log_manager.py,sha256=gq92IAfnKEX-GKUHexNVgEI0UUrUdiWaC5GLcSTAaUE,13604
|
|
306
306
|
holado_multitask/__init__.py,sha256=EwuwiBmp8ICbPZ8CKPju8tHRTh2rG68PB_wGXczY9rw,2143
|
|
@@ -409,14 +409,14 @@ holado_report/report/reports/feature_report.py,sha256=i0wpk3LQLArVjWDsP9UcNSJzAU
|
|
|
409
409
|
holado_report/report/reports/scenario_report.py,sha256=eMyqw9EzaKMmX3pGFJN1rqAOQ5eqO2ISZdxAfK3XQR4,2945
|
|
410
410
|
holado_rest/__init__.py,sha256=BOeE6t6ejeqRYd44SE4vYJVTNz01BwcVCIWfwRQ5axg,1526
|
|
411
411
|
holado_rest/api/rest/TODO.txt,sha256=Oz8BYPkBEs9OAEgyYLLm7i5tJ1bRE5POBpT3SRFWTi4,29
|
|
412
|
-
holado_rest/api/rest/rest_client.py,sha256=
|
|
412
|
+
holado_rest/api/rest/rest_client.py,sha256=jC9fFz5rsiiCSa-pnUs6uOhprGYUX0wH_iiq649S25M,9549
|
|
413
413
|
holado_rest/api/rest/rest_manager.py,sha256=XldPjNgj73GlzAmlsEcQYaHiDRk7SGU6VEFOLBnHjQM,4010
|
|
414
414
|
holado_rest/tests/behave/steps/__init__.py,sha256=lEH5NYkKtpgDV2ZAO1qAGNN4ipwILWMpgvQgnamgYKk,1283
|
|
415
415
|
holado_rest/tests/behave/steps/api/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
416
416
|
holado_rest/tests/behave/steps/api/rest_client_steps.py,sha256=naN0YcRVQyM--RhV0jPhnlsjZS6luijwGvVC5lM0XCY,9749
|
|
417
417
|
holado_rest/tests/behave/steps/private/__init__.py,sha256=TGsd7qLZpPQRxphFzgepFa22NhHSoZgxAWSIqwvA4L8,1276
|
|
418
418
|
holado_rest/tests/behave/steps/private/api/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
419
|
-
holado_rest/tests/behave/steps/private/api/rest_steps.py,sha256=
|
|
419
|
+
holado_rest/tests/behave/steps/private/api/rest_steps.py,sha256=RpaGaMjOcqMJKrCx0Fp5Ks_e89GGpLaxaBbJmZ0jChk,3674
|
|
420
420
|
holado_s3/__init__.py,sha256=Gl285tg-QaPE-3etWwZql9sH26G7EnVoQn97B0NMvOI,1248
|
|
421
421
|
holado_s3/tests/behave/steps/__init__.py,sha256=q64qGCCey5QivEezEXq9LjABSBnjavTpq03PpaMSLkY,1320
|
|
422
422
|
holado_s3/tests/behave/steps/private/__init__.py,sha256=JmVFxoOewwdE3uAgX4u2Y3tLWL_GdYW3h2ZawNdpn38,1276
|
|
@@ -475,7 +475,7 @@ holado_swagger/swagger_hub/mockserver/mockserver_client.py,sha256=L7P8aNi5Zuh2xR
|
|
|
475
475
|
holado_swagger/swagger_hub/mockserver/mockserver_manager.py,sha256=eN843He06PLrEvT6M6UoT4xX_4Ks9GEd_3i-xJrGblw,1631
|
|
476
476
|
holado_swagger/tests/behave/steps/__init__.py,sha256=joCT_nKaotXBBMNTXxOBcmr98gjmjDkY1Zbu5lCL8B4,1290
|
|
477
477
|
holado_swagger/tests/behave/steps/swagger_hub/mockserver_steps.py,sha256=_M5WyF35qBjvDnXbohhMA9kV3D1H1aRnTBQ1iOtmxHA,3749
|
|
478
|
-
holado_system/system/global_system.py,sha256=
|
|
478
|
+
holado_system/system/global_system.py,sha256=ImNNXim2fvpcj4Wf-iLgCwWuCW6WQlNL7IrtDBUimk8,8253
|
|
479
479
|
holado_system/system/command/command.py,sha256=9lv9kgvvIq4Fqx6fJXU_HQA8pCO80Ws9rpd2FwzAn0I,9053
|
|
480
480
|
holado_system/system/command/command_result.py,sha256=sunGDegNVOtpK9s9r4HCAJlREu4iKS0w3HY4KKDEQkw,4613
|
|
481
481
|
holado_system/system/command/curl_command.py,sha256=CEMaO0_qLyKe4tLytMlHzmCuS_gi-oU479hwOaEyZ60,3743
|
|
@@ -655,7 +655,7 @@ test_holado/tools/django/api_rest/api_rest/api1/serializers.py,sha256=o_YxFr-tgC
|
|
|
655
655
|
test_holado/tools/django/api_rest/api_rest/api1/tests.py,sha256=mrbGGRNg5jwbTJtWWa7zSKdDyeB4vmgZCRc2nk6VY-g,60
|
|
656
656
|
test_holado/tools/django/api_rest/api_rest/api1/views.py,sha256=kOt2xT6bxO47_z__5yYR9kcYIWWv4qYzpX0K8Tqonik,758
|
|
657
657
|
test_holado/tools/django/api_rest/api_rest/api1/migrations/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
658
|
-
holado-0.8.
|
|
659
|
-
holado-0.8.
|
|
660
|
-
holado-0.8.
|
|
661
|
-
holado-0.8.
|
|
658
|
+
holado-0.8.4.dist-info/METADATA,sha256=Rpc-iJZqI6EVW-Q0gPQqyNShVX_KqbISFxtYE5VCwbQ,7671
|
|
659
|
+
holado-0.8.4.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
|
|
660
|
+
holado-0.8.4.dist-info/licenses/LICENSE,sha256=IgGmNlcFHnbp7UWrLJqAFvs_HIgjJDTmjCNRircJLsk,1070
|
|
661
|
+
holado-0.8.4.dist-info/RECORD,,
|
|
@@ -13,6 +13,7 @@
|
|
|
13
13
|
|
|
14
14
|
import logging
|
|
15
15
|
from holado_rest.api.rest.rest_client import RestClient
|
|
16
|
+
from holado.common.handlers.undefined import default_value
|
|
16
17
|
|
|
17
18
|
logger = logging.getLogger(__name__)
|
|
18
19
|
|
|
@@ -29,8 +30,8 @@ class DockerControllerClient(RestClient):
|
|
|
29
30
|
response = self.get(f"os/env", json=data)
|
|
30
31
|
return self.response_result(response, status_ok=[200])
|
|
31
32
|
|
|
32
|
-
def get_directory_filenames(self, path):
|
|
33
|
-
data = {'path':path}
|
|
33
|
+
def get_directory_filenames(self, path, extension='.yml'):
|
|
34
|
+
data = {'path':path, 'extension':extension}
|
|
34
35
|
response = self.get(f"os/ls", json=data)
|
|
35
36
|
return self.response_result(response, status_ok=[200])
|
|
36
37
|
|
|
@@ -45,11 +46,14 @@ class DockerControllerClient(RestClient):
|
|
|
45
46
|
return self.response_result(response, status_ok=[200,204])
|
|
46
47
|
|
|
47
48
|
def get_container_info(self, name, all_=False):
|
|
49
|
+
"""Get container info
|
|
50
|
+
@return container info if found, else None
|
|
51
|
+
"""
|
|
48
52
|
if all_:
|
|
49
53
|
response = self.get(f"container/{name}?all=true")
|
|
50
54
|
else:
|
|
51
55
|
response = self.get(f"container/{name}")
|
|
52
|
-
return self.response_result(response, status_ok=[200,204])
|
|
56
|
+
return self.response_result(response, status_ok=[200,204], result_on_statuses={204:None, default_value:None})
|
|
53
57
|
|
|
54
58
|
def restart_container(self, name, start_if_gone=False):
|
|
55
59
|
response = self.put(f"container/{name}/restart")
|
|
@@ -29,9 +29,15 @@ class LsView(MethodView):
|
|
|
29
29
|
|
|
30
30
|
def get(self, body: dict):
|
|
31
31
|
dir_path = body['path']
|
|
32
|
+
extension = body.get('extension', None)
|
|
33
|
+
|
|
34
|
+
if not os.path.exists(dir_path) or not os.path.isdir(dir_path):
|
|
35
|
+
return f"Directory '{dir_path}' doesn't exist", 406
|
|
32
36
|
|
|
33
37
|
res = []
|
|
34
38
|
for filename in os.listdir(dir_path):
|
|
39
|
+
if extension is not None and not filename.endswith(extension):
|
|
40
|
+
continue
|
|
35
41
|
if os.path.isfile(os.path.join(dir_path, filename)):
|
|
36
42
|
res.append(filename)
|
|
37
43
|
|
|
@@ -40,11 +40,14 @@ paths:
|
|
|
40
40
|
properties:
|
|
41
41
|
path:
|
|
42
42
|
type: string
|
|
43
|
+
extension:
|
|
44
|
+
type: string
|
|
45
|
+
nullable: true
|
|
43
46
|
responses:
|
|
44
47
|
200:
|
|
45
48
|
description: "Directory filenames"
|
|
46
49
|
content:
|
|
47
|
-
application/
|
|
50
|
+
application/json:
|
|
48
51
|
schema:
|
|
49
52
|
type: "array"
|
|
50
53
|
items:
|
|
@@ -12,6 +12,7 @@
|
|
|
12
12
|
#################################################
|
|
13
13
|
|
|
14
14
|
import logging
|
|
15
|
+
from holado.common.handlers.undefined import default_value
|
|
15
16
|
|
|
16
17
|
logger = logging.getLogger(__name__)
|
|
17
18
|
|
|
@@ -22,7 +23,7 @@ class HALogger(logging.Logger):
|
|
|
22
23
|
def __init__(self, name, level=logging.NOTSET):
|
|
23
24
|
super().__init__(name, level)
|
|
24
25
|
|
|
25
|
-
def _log(self, level, msg, args, exc_info=None, extra=None, stack_info=False, stacklevel=1, msg_size_limit=
|
|
26
|
+
def _log(self, level, msg, args, exc_info=None, extra=None, stack_info=False, stacklevel=1, msg_size_limit=default_value):
|
|
26
27
|
# def find_handlers(logger_):
|
|
27
28
|
# index = 0
|
|
28
29
|
# while len(logger_.handlers) == 0:
|
|
@@ -41,7 +42,7 @@ class HALogger(logging.Logger):
|
|
|
41
42
|
else:
|
|
42
43
|
raise exc
|
|
43
44
|
|
|
44
|
-
if msg_size_limit is
|
|
45
|
+
if msg_size_limit is default_value:
|
|
45
46
|
msg_size_limit = HALogger.default_message_size_limit
|
|
46
47
|
msg_to_log = Tools.truncate_text(msg, msg_size_limit)
|
|
47
48
|
|
|
@@ -20,6 +20,7 @@ from holado_core.common.tools.converters.converter import Converter
|
|
|
20
20
|
from holado_json.ipc.json_converter import JsonConverter
|
|
21
21
|
from holado.common.handlers.object import Object
|
|
22
22
|
from holado.holado_config import Config
|
|
23
|
+
from holado.common.handlers.undefined import to_be_defined, default
|
|
23
24
|
|
|
24
25
|
logger = logging.getLogger(__name__)
|
|
25
26
|
|
|
@@ -38,6 +39,11 @@ class RestClient(Object):
|
|
|
38
39
|
REST client
|
|
39
40
|
"""
|
|
40
41
|
|
|
42
|
+
default_result_on_statuses = {
|
|
43
|
+
# 204 == "No Content" => result is None
|
|
44
|
+
204: None
|
|
45
|
+
}
|
|
46
|
+
|
|
41
47
|
@classmethod
|
|
42
48
|
def is_available(cls):
|
|
43
49
|
return with_requests
|
|
@@ -82,12 +88,34 @@ class RestClient(Object):
|
|
|
82
88
|
res += "&".join([f"{k}={v}" for k,v in parameters.items()])
|
|
83
89
|
return res
|
|
84
90
|
|
|
85
|
-
def response_result(self, response, status_ok=200):
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
+
def response_result(self, response, status_ok=200, result_on_statuses=default_result_on_statuses):
|
|
92
|
+
"""Return the result of the request associated to given response
|
|
93
|
+
@param response Response of the request
|
|
94
|
+
@param status_ok The status code, or a list of status codes, for which the request is considered in success
|
|
95
|
+
@param result_on_statuses A dictionary with defined result associated to a status
|
|
96
|
+
Notes:
|
|
97
|
+
- If response status is not status_ok (or in status_ok if it is a list), an exception is raised telling request has failed
|
|
98
|
+
- result_on_statuses is by default RestClient.default_result_on_statuses (={204: None})
|
|
99
|
+
- When holado.common.handlers.undefined.default is in result_on_statuses as status, the associated result is returned in any other case and no failing exception is raised
|
|
100
|
+
"""
|
|
101
|
+
res = to_be_defined
|
|
102
|
+
is_res_default = False
|
|
103
|
+
is_ok = isinstance(status_ok, list) and response.status_code in status_ok or response.status_code == status_ok
|
|
104
|
+
|
|
105
|
+
# Find a result associated to response status
|
|
106
|
+
if result_on_statuses is not None:
|
|
107
|
+
for status, status_result in result_on_statuses.items():
|
|
108
|
+
if response.status_code == status:
|
|
109
|
+
res = status_result
|
|
110
|
+
break
|
|
111
|
+
elif status is default and not is_ok:
|
|
112
|
+
res = status_result
|
|
113
|
+
is_res_default = True
|
|
114
|
+
break
|
|
115
|
+
|
|
116
|
+
|
|
117
|
+
# If result is not defined, get it from response
|
|
118
|
+
if res is to_be_defined:
|
|
91
119
|
if "application/json" in response.headers['Content-Type'] and len(response.content) > 0:
|
|
92
120
|
res = response.json()
|
|
93
121
|
elif response.headers['Content-Type'].startswith('text'):
|
|
@@ -96,8 +124,7 @@ class RestClient(Object):
|
|
|
96
124
|
res = response.content
|
|
97
125
|
|
|
98
126
|
# Verify status
|
|
99
|
-
|
|
100
|
-
if not is_ok:
|
|
127
|
+
if not is_ok and not is_res_default:
|
|
101
128
|
raise FunctionalException(f"[{self.name}] Request failed with status {response.status_code} (expected success status: {status_ok}) on error: {res}")
|
|
102
129
|
|
|
103
130
|
return res
|
|
@@ -115,7 +142,7 @@ class RestClient(Object):
|
|
|
115
142
|
raise TechnicalException(f"[{self.name}] Failed to process {method} '{url}' with arguments {r_kwargs}") from exc
|
|
116
143
|
|
|
117
144
|
if Tools.do_log(logger, logging.TRACE): # @UndefinedVariable
|
|
118
|
-
logger.trace(f"[{self.name}] {method} on url '{url}' => {Tools.represent_object(res, 4)}")
|
|
145
|
+
logger.trace(f"[{self.name}] {method} on url '{url}' => {Tools.represent_object(res, 4)}", msg_size_limit=None)
|
|
119
146
|
elif Tools.do_log(logger, self.request_log_level):
|
|
120
147
|
logger.log(self.request_log_level, f"[{self.name}] {method} on url '{url}' => {Tools.represent_object(res, 4, max_level=1)}")
|
|
121
148
|
return res
|
|
@@ -17,6 +17,7 @@ from holado_test.behave.behave import * # @UnusedWildImport
|
|
|
17
17
|
import os.path
|
|
18
18
|
import logging
|
|
19
19
|
from holado_test.scenario.step_tools import StepTools
|
|
20
|
+
from holado_system.system.global_system import GlobalSystem
|
|
20
21
|
|
|
21
22
|
logger = logging.getLogger(__name__)
|
|
22
23
|
|
|
@@ -42,26 +43,33 @@ def step_impl(context, var_name):
|
|
|
42
43
|
here = os.path.abspath(os.path.dirname(__file__))
|
|
43
44
|
django_project_path = os.path.normpath(os.path.join(here, "..", "..", "..", "..", "..", "..", "..", "tests", "behave", "test_holado", "tools", "django", "api_rest"))
|
|
44
45
|
|
|
46
|
+
if 8000 in GlobalSystem.get_used_ports():
|
|
47
|
+
port = GlobalSystem.get_first_available_anonymous_port()
|
|
48
|
+
else:
|
|
49
|
+
port = 8000
|
|
50
|
+
__get_variable_manager().register_variable("__INTERNAL_REST_SERVER_PORT__", port)
|
|
51
|
+
|
|
45
52
|
execute_steps(u"""
|
|
46
53
|
Given {var_name} = new Django server
|
|
47
54
|
| Name | Value |
|
|
48
55
|
| 'name' | 'REST server for holado tests' |
|
|
49
56
|
| 'django_project_path' | '{django_project_path}' |
|
|
50
|
-
| 'port' |
|
|
57
|
+
| 'port' | {port} |
|
|
51
58
|
When start (Django server: {var_name})
|
|
52
|
-
""".format(var_name=var_name, django_project_path=django_project_path))
|
|
59
|
+
""".format(var_name=var_name, django_project_path=django_project_path, port=port))
|
|
53
60
|
|
|
54
61
|
|
|
55
62
|
|
|
56
63
|
@Given(r"(?P<var_name>{Variable}) = new internal REST client")
|
|
57
64
|
def step_impl(context, var_name):
|
|
58
65
|
var_name = StepTools.evaluate_variable_name(var_name)
|
|
66
|
+
port = __get_variable_manager().get_variable_value("__INTERNAL_REST_SERVER_PORT__")
|
|
59
67
|
execute_steps(u"""
|
|
60
68
|
Given {var_name} = new REST client
|
|
61
|
-
| Name | Value
|
|
62
|
-
| 'url' | 'http://localhost:
|
|
63
|
-
| 'headers.Content-Type' | 'application/json'
|
|
64
|
-
| 'authentication.user' | ('admin', 'admin')
|
|
65
|
-
""".format(var_name=var_name))
|
|
69
|
+
| Name | Value |
|
|
70
|
+
| 'url' | 'http://localhost:{port}' |
|
|
71
|
+
| 'headers.Content-Type' | 'application/json' |
|
|
72
|
+
| 'authentication.user' | ('admin', 'admin') |
|
|
73
|
+
""".format(var_name=var_name, port=port))
|
|
66
74
|
|
|
67
75
|
|
|
@@ -171,7 +171,7 @@ class GlobalSystem(object):
|
|
|
171
171
|
if cls.get_os_type() == OSTypes.Linux:
|
|
172
172
|
cmd = "netstat -tunlep | grep LISTEN | awk '{print $4}' | awk '{gsub(\".*:\",\"\");print}'"
|
|
173
173
|
result = cls.execute_command(cmd, do_log_output=False, do_raise_on_stderr=False)
|
|
174
|
-
res =
|
|
174
|
+
res = {Converter.to_integer(v) for v in result.output.split('\n') if len(v) > 0}
|
|
175
175
|
return res
|
|
176
176
|
else:
|
|
177
177
|
raise NotImplementedError(f"Not implemented for OS type '{cls.get_os_type().name}'")
|
|
File without changes
|
|
File without changes
|