holado 0.2.7__py3-none-any.whl → 0.3.0__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 +7 -1
- {holado-0.2.7.dist-info → holado-0.3.0.dist-info}/METADATA +7 -1
- {holado-0.2.7.dist-info → holado-0.3.0.dist-info}/RECORD +116 -107
- holado_ais/ais/ais_messages.py +97 -6
- holado_ais/tests/behave/steps/ais/ais_manager_steps.py +1 -1
- holado_ais/tests/behave/steps/ais/ais_messages_steps.py +45 -6
- holado_binary/ipc/bit_series.py +3 -3
- holado_binary/tests/behave/steps/ipc/binary_steps.py +1 -1
- holado_binary/tests/behave/steps/ipc/bit_series_steps.py +4 -3
- holado_context/tests/behave/steps/private/common/context_steps.py +1 -1
- holado_core/common/resource/persisted_data_manager.py +13 -16
- holado_core/common/resource/resource_manager.py +10 -10
- holado_core/common/tables/converters/table_converter.py +47 -9
- holado_core/common/tables/table.py +2 -2
- holado_core/common/tables/table_manager.py +6 -7
- holado_core/common/tables/table_with_header.py +6 -0
- holado_core/common/tools/string_tools.py +9 -0
- holado_core/tests/behave/steps/common/common_steps.py +2 -1
- holado_core/tests/behave/steps/common/config_steps.py +1 -1
- holado_core/tests/behave/steps/common/resource_steps.py +1 -1
- holado_core/tests/behave/steps/common/tables_steps.py +27 -4
- holado_data/data/generator/generator_manager.py +39 -0
- holado_data/tests/behave/steps/data/generator_steps.py +1 -1
- holado_data/tests/behave/steps/tools/utils_steps.py +1 -2
- holado_db/tests/behave/steps/tools/db/db_client_steps.py +1 -1
- holado_db/tests/behave/steps/tools/db/postgresql_client_steps.py +1 -1
- holado_db/tests/behave/steps/tools/db/sqlite_client_steps.py +1 -1
- holado_db/tools/db/clients/base/db_client.py +81 -28
- holado_db/tools/db/clients/postgresql/postgresql_client.py +17 -7
- holado_db/tools/db/query/base/query_builder.py +58 -7
- holado_db/tools/db/query/pypika/pypika_query_builder.py +73 -21
- holado_docker/tests/behave/steps/tools/docker_steps.py +1 -1
- holado_grpc/tests/behave/steps/api/grpc_client_steps.py +1 -1
- holado_grpc/tests/behave/steps/private/api/grpc_steps.py +1 -1
- holado_helper/script/action.py +16 -7
- holado_json/tests/behave/steps/ipc/json_steps.py +1 -1
- holado_keycloak/tests/behave/steps/tools/keycloak_client_steps.py +1 -1
- holado_multitask/tests/behave/steps/multiprocessing_steps.py +1 -1
- holado_multitask/tests/behave/steps/multithreading_steps.py +1 -1
- holado_protobuf/ipc/protobuf/types/google/protobuf.py +1 -1
- holado_protobuf/tests/behave/steps/ipc/protobuf_steps.py +1 -1
- holado_python/common/tools/datetime.py +31 -12
- holado_python/standard_library/socket/blocking_socket.py +112 -42
- holado_python/standard_library/socket/echo_server.py +4 -3
- holado_python/standard_library/socket/message_socket.py +69 -22
- holado_python/standard_library/socket/non_blocking_socket.py +65 -67
- holado_python/standard_library/socket/socket.py +272 -32
- holado_python/standard_library/ssl/resources/certificates/NOTES.txt +1 -1
- holado_python/standard_library/ssl/resources/certificates/rootCACert.pem +24 -0
- holado_python/standard_library/ssl/resources/certificates/tcpbin.crt +21 -0
- holado_python/standard_library/ssl/resources/certificates/tcpbin.key +28 -0
- holado_python/standard_library/ssl/ssl.py +138 -21
- holado_python/tests/behave/steps/convert_steps.py +1 -1
- holado_python/tests/behave/steps/iterable_steps.py +1 -1
- holado_python/tests/behave/steps/standard_library/csv_steps.py +1 -1
- holado_python/tests/behave/steps/standard_library/datetime_steps.py +1 -1
- holado_python/tests/behave/steps/standard_library/hashlib_steps.py +1 -1
- holado_python/tests/behave/steps/standard_library/multiprocessing_steps.py +1 -1
- holado_python/tests/behave/steps/standard_library/queue_steps.py +1 -1
- holado_python/tests/behave/steps/standard_library/socket_steps.py +147 -21
- holado_python/tests/behave/steps/standard_library/ssl_steps.py +87 -16
- holado_rabbitmq/tests/behave/steps/tools/rabbitmq_client_steps.py +48 -20
- holado_rabbitmq/tests/behave/steps/tools/rabbitmq_server_steps.py +1 -1
- holado_rabbitmq/tools/rabbitmq/rabbitmq_client.py +19 -13
- holado_rabbitmq/tools/rabbitmq/rabbitmq_manager.py +2 -29
- holado_redis/tests/behave/steps/tools/redis_client_steps.py +1 -1
- holado_rest/tests/behave/steps/api/rest_client_steps.py +1 -1
- holado_rest/tests/behave/steps/private/api/rest_steps.py +1 -1
- holado_s3/tests/behave/steps/private/tools/s3_steps.py +1 -1
- holado_s3/tests/behave/steps/tools/s3_client_steps.py +1 -1
- holado_s3/tests/behave/steps/tools/s3_server_steps.py +1 -1
- holado_scripting/tests/behave/steps/common/tools/variable_convert_steps.py +3 -2
- holado_scripting/tests/behave/steps/common/tools/variable_new_steps.py +1 -1
- holado_scripting/tests/behave/steps/common/tools/variable_steps.py +1 -1
- holado_scripting/tests/behave/steps/common/tools/variable_verify_steps.py +1 -1
- holado_scripting/tests/behave/steps/scenario/function_steps.py +1 -1
- holado_scripting/tests/behave/steps/scenario/if_steps.py +1 -1
- holado_scripting/tests/behave/steps/scenario/loop_steps.py +1 -1
- holado_scripting/text/interpreter/functions/function_apply_function.py +60 -0
- holado_scripting/text/interpreter/functions/function_to_string.py +50 -0
- holado_scripting/text/interpreter/text_interpreter.py +4 -0
- holado_sftp/tests/behave/steps/private/tools/sftp_steps.py +1 -1
- holado_sftp/tests/behave/steps/tools/sftp_client_steps.py +1 -1
- holado_sftp/tests/behave/steps/tools/sftp_server_steps.py +1 -1
- holado_swagger/tests/behave/steps/swagger_hub/mockserver_steps.py +1 -1
- holado_system/system/command/command.py +14 -9
- holado_system/tests/behave/steps/system/commands_steps.py +1 -1
- holado_system/tests/behave/steps/system/file_steps.py +1 -1
- holado_system/tests/behave/steps/system/system_steps.py +1 -1
- holado_test/scenario/step_tools.py +5 -4
- holado_test/scenario/tester_tools.py +6 -3
- holado_test/tests/behave/steps/scenario/exception_steps.py +1 -1
- holado_test/tests/behave/steps/scenario/scenario_steps.py +1 -1
- holado_test/tests/behave/steps/scenario/tester_steps.py +4 -4
- holado_value/common/tables/converters/value_table_converter.py +52 -8
- holado_value/common/tables/value_table_cell.py +5 -0
- holado_value/common/tables/value_table_manager.py +0 -10
- holado_value/common/tables/value_table_row.py +0 -1
- holado_value/common/tools/value.py +5 -1
- holado_ws/tests/behave/steps/api/web_service_steps.py +1 -1
- holado_yaml/tests/behave/steps/yaml_steps.py +1 -1
- holado_yaml/yaml/yaml_manager.py +2 -2
- test_holado/features/NonReg/common/tables/table.feature +30 -24
- test_holado/features/NonReg/holado_ais/ais_message-bitarray_to_nmea.feature +1 -1
- test_holado/features/NonReg/holado_python/standard_library/socket/local_echo_server/socket_reset.feature +191 -0
- test_holado/features/NonReg/holado_python/standard_library/{socket_with_ssl.feature → socket/local_echo_server/socket_with_tls_and_verify.feature} +126 -27
- test_holado/features/NonReg/holado_python/standard_library/socket/local_echo_server/socket_with_tls_without_verify.feature +299 -0
- test_holado/features/NonReg/holado_python/standard_library/{socket.feature → socket/local_echo_server/socket_without_tls.feature} +63 -1
- test_holado/features/NonReg/holado_python/standard_library/socket/tcpbin.com/socket_with_mtls.feature +214 -0
- test_holado/features/NonReg/holado_python/standard_library/socket/tcpbin.com/socket_with_tls.feature +184 -0
- test_holado/features/NonReg/holado_python/standard_library/socket/tcpbin.com/socket_without_tls.feature +169 -0
- test_holado/features/NonReg/tools/RabbitMQ.feature +9 -9
- test_holado/features/NonReg/tools/RabbitMQ_steps.feature +8 -8
- test_holado/logging.conf +5 -3
- holado_core/common/transport/__init__.py +0 -0
- holado_core/common/transport/crc.py +0 -40
- {holado-0.2.7.dist-info → holado-0.3.0.dist-info}/WHEEL +0 -0
- {holado-0.2.7.dist-info → holado-0.3.0.dist-info}/licenses/LICENSE +0 -0
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
|
|
16
16
|
from holado_test.scenario.step_tools import StepTools
|
|
17
17
|
from holado.common.context.session_context import SessionContext
|
|
18
|
-
from holado_test.behave.behave import *
|
|
18
|
+
from holado_test.behave.behave import * # @UnusedWildImport
|
|
19
19
|
import logging
|
|
20
20
|
from holado_core.common.exceptions.verify_exception import VerifyException
|
|
21
21
|
from holado_core.common.tools.converters.converter import Converter
|
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
|
|
16
16
|
from holado_test.scenario.step_tools import StepTools
|
|
17
17
|
from holado.common.context.session_context import SessionContext
|
|
18
|
-
from holado_test.behave.behave import *
|
|
18
|
+
from holado_test.behave.behave import * # @UnusedWildImport
|
|
19
19
|
from holado_test.behave.behave import render_step_table
|
|
20
20
|
import logging
|
|
21
21
|
from holado_test.behave.scenario.behave_step_tools import BehaveStepTools
|
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
|
|
16
16
|
from holado_test.scenario.step_tools import StepTools
|
|
17
17
|
from holado.common.context.session_context import SessionContext
|
|
18
|
-
from holado_test.behave.behave import *
|
|
18
|
+
from holado_test.behave.behave import * # @UnusedWildImport
|
|
19
19
|
from datetime import datetime, timedelta
|
|
20
20
|
from holado_python.common.tools.datetime import DateTime, DurationUnit
|
|
21
21
|
import logging
|
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
|
|
16
16
|
from holado_test.scenario.step_tools import StepTools
|
|
17
17
|
from holado.common.context.session_context import SessionContext
|
|
18
|
-
from holado_test.behave.behave import *
|
|
18
|
+
from holado_test.behave.behave import * # @UnusedWildImport
|
|
19
19
|
import logging
|
|
20
20
|
from holado_core.common.exceptions.verify_exception import VerifyException
|
|
21
21
|
from holado_core.common.tools.converters.converter import Converter
|
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
#################################################
|
|
14
14
|
|
|
15
15
|
|
|
16
|
-
from holado_test.behave.behave import *
|
|
16
|
+
from holado_test.behave.behave import * # @UnusedWildImport
|
|
17
17
|
from holado.common.context.session_context import SessionContext
|
|
18
18
|
from holado_test.scenario.step_tools import StepTools
|
|
19
19
|
import logging
|
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
#################################################
|
|
14
14
|
|
|
15
15
|
|
|
16
|
-
from holado_test.behave.behave import *
|
|
16
|
+
from holado_test.behave.behave import * # @UnusedWildImport
|
|
17
17
|
from holado.common.context.session_context import SessionContext
|
|
18
18
|
from holado_test.scenario.step_tools import StepTools
|
|
19
19
|
import logging
|
|
@@ -15,14 +15,14 @@
|
|
|
15
15
|
|
|
16
16
|
from holado_test.scenario.step_tools import StepTools
|
|
17
17
|
from holado.common.context.session_context import SessionContext
|
|
18
|
-
from holado_test.behave.behave import *
|
|
18
|
+
from holado_test.behave.behave import * # @UnusedWildImport
|
|
19
19
|
import logging
|
|
20
20
|
from holado_test.behave.scenario.behave_step_tools import BehaveStepTools
|
|
21
21
|
from holado_value.common.tables.converters.value_table_converter import ValueTableConverter
|
|
22
22
|
from holado_python.standard_library.socket.blocking_socket import TCPBlockingSocketClient
|
|
23
23
|
from holado_python.standard_library.socket.echo_server import EchoTCPBlockingSocketServer
|
|
24
|
-
from holado_python.standard_library.socket.message_socket import
|
|
25
|
-
from holado_core.common.handlers.wait import WaitEndChange
|
|
24
|
+
from holado_python.standard_library.socket.message_socket import MessageTCPNonBlockingSocketClient, MessageTCPBlockingSocketClient
|
|
25
|
+
from holado_core.common.handlers.wait import WaitEndChange, WaitChange
|
|
26
26
|
from holado_core.common.exceptions.functional_exception import FunctionalException
|
|
27
27
|
from holado_python.standard_library.socket.non_blocking_socket import TCPNonBlockingSocketClient
|
|
28
28
|
|
|
@@ -74,14 +74,20 @@ def step_impl(context, var_name):
|
|
|
74
74
|
kwargs = ValueTableConverter.convert_name_value_table_2_dict(table)
|
|
75
75
|
|
|
76
76
|
separator = kwargs.pop('separator') if 'separator' in kwargs else '\n'
|
|
77
|
-
|
|
77
|
+
blocking = kwargs.pop('blocking') if 'blocking' in kwargs else True
|
|
78
|
+
if blocking:
|
|
79
|
+
res = MessageTCPBlockingSocketClient(separator, create_ipv4_socket_kwargs=kwargs)
|
|
80
|
+
else:
|
|
81
|
+
res = MessageTCPNonBlockingSocketClient(separator, create_ipv4_socket_kwargs=kwargs)
|
|
78
82
|
|
|
79
83
|
__get_variable_manager().register_variable(var_name, res)
|
|
80
84
|
|
|
81
85
|
|
|
82
86
|
@Step(r"start \(socket client: (?P<server_varname>{Variable})\)")
|
|
83
87
|
def step_impl(context, server_varname):
|
|
84
|
-
"""Start a
|
|
88
|
+
"""Start a socket client.
|
|
89
|
+
It starts a thread listening incoming data.
|
|
90
|
+
This step is needed for non blocking socket clients to manage incoming data.
|
|
85
91
|
Note: current implementation uses 'start' method parameters default values.
|
|
86
92
|
"""
|
|
87
93
|
server = StepTools.evaluate_scenario_parameter(server_varname)
|
|
@@ -139,6 +145,14 @@ def step_impl(context, server_varname):
|
|
|
139
145
|
################################################################
|
|
140
146
|
|
|
141
147
|
|
|
148
|
+
@Step(r"ensure SSL handshake is done \(socket: (?P<socket_varname>{Variable})\)")
|
|
149
|
+
def step_impl(context, socket_varname):
|
|
150
|
+
"""Ensure SSL handshake is done.
|
|
151
|
+
"""
|
|
152
|
+
sock = StepTools.evaluate_scenario_parameter(socket_varname)
|
|
153
|
+
|
|
154
|
+
sock.ensure_ssl_handshake_is_done()
|
|
155
|
+
|
|
142
156
|
@Step(r"write (?P<data>{Bytes}) \(socket: (?P<socket_varname>{Variable})\)")
|
|
143
157
|
def step_impl(context, data, socket_varname):
|
|
144
158
|
"""Send data
|
|
@@ -161,6 +175,89 @@ def step_impl(context, var_name, socket_varname):
|
|
|
161
175
|
|
|
162
176
|
__get_variable_manager().register_variable(var_name, res)
|
|
163
177
|
|
|
178
|
+
@Step(r"(?P<var_name>{Variable}) = received data \(socket: (?P<socket_varname>{Variable})\)")
|
|
179
|
+
def step_impl(context, var_name, socket_varname):
|
|
180
|
+
"""Get currently received data
|
|
181
|
+
This step works only with clients that are started, so that listening thread is started.
|
|
182
|
+
"""
|
|
183
|
+
var_name = StepTools.evaluate_variable_name(var_name)
|
|
184
|
+
sock = StepTools.evaluate_scenario_parameter(socket_varname)
|
|
185
|
+
|
|
186
|
+
res = sock.received_data
|
|
187
|
+
|
|
188
|
+
__get_variable_manager().register_variable(var_name, res)
|
|
189
|
+
|
|
190
|
+
@Step(r"(?P<var_name>{Variable}) = size of received data \(socket: (?P<socket_varname>{Variable})\)")
|
|
191
|
+
def step_impl(context, var_name, socket_varname):
|
|
192
|
+
"""Get received messages without removing from socket
|
|
193
|
+
"""
|
|
194
|
+
var_name = StepTools.evaluate_variable_name(var_name)
|
|
195
|
+
sock = StepTools.evaluate_scenario_parameter(socket_varname)
|
|
196
|
+
|
|
197
|
+
res = sock.received_data_size
|
|
198
|
+
|
|
199
|
+
__get_variable_manager().register_variable(var_name, res)
|
|
200
|
+
|
|
201
|
+
@Step(r"socket (?P<socket_varname>{Variable}) doesn't receive any data(?: \((?:timeout: (?P<timeout_sec>{Float}) s)?(?: ; )?(?:polling: (?P<polling_sec>{Float}) s)?\))?")
|
|
202
|
+
def step_impl(context, socket_varname, timeout_sec, polling_sec):
|
|
203
|
+
"""Wait and verify socket doesn't receive any data
|
|
204
|
+
"""
|
|
205
|
+
sock = StepTools.evaluate_scenario_parameter(socket_varname)
|
|
206
|
+
timeout_sec = StepTools.evaluate_scenario_parameter(timeout_sec)
|
|
207
|
+
polling_sec = StepTools.evaluate_scenario_parameter(polling_sec)
|
|
208
|
+
|
|
209
|
+
if timeout_sec is None:
|
|
210
|
+
timeout_sec = 10
|
|
211
|
+
|
|
212
|
+
wait = WaitChange(f"Verify no data is received (socket: {sock})",
|
|
213
|
+
lambda: sock.received_data_size,
|
|
214
|
+
timeout_seconds=timeout_sec, polling_seconds=polling_sec)
|
|
215
|
+
wait.without_raise_on_timeout()
|
|
216
|
+
data_size = wait.execute()
|
|
217
|
+
if data_size > 0:
|
|
218
|
+
raise FunctionalException(f"[{sock.name}] Socket has received data of size {data_size}")
|
|
219
|
+
|
|
220
|
+
@Step(r"await socket (?P<socket_varname>{Variable}) receives a data(?: \((?:timeout: (?P<timeout_sec>{Float}) s)?(?: ; )?(?:polling: (?P<polling_sec>{Float}) s)?\))?")
|
|
221
|
+
def step_impl(context, socket_varname, timeout_sec, polling_sec):
|
|
222
|
+
"""Wait socket receives at least one data
|
|
223
|
+
"""
|
|
224
|
+
sock = StepTools.evaluate_scenario_parameter(socket_varname)
|
|
225
|
+
timeout_sec = StepTools.evaluate_scenario_parameter(timeout_sec)
|
|
226
|
+
polling_sec = StepTools.evaluate_scenario_parameter(polling_sec)
|
|
227
|
+
|
|
228
|
+
if timeout_sec is None:
|
|
229
|
+
timeout_sec = 10
|
|
230
|
+
|
|
231
|
+
wait = WaitChange(f"Wait data reception (socket: {sock})",
|
|
232
|
+
lambda: sock.received_data_size,
|
|
233
|
+
timeout_seconds=timeout_sec, polling_seconds=polling_sec)
|
|
234
|
+
wait.without_raise_on_timeout()
|
|
235
|
+
data_size = wait.execute()
|
|
236
|
+
if data_size == 0:
|
|
237
|
+
raise FunctionalException(f"[{sock.name}] No data was received (timeout: {wait.timeout} seconds)")
|
|
238
|
+
|
|
239
|
+
@Step(r"await socket (?P<socket_varname>{Variable}) receives data(?: \((?:first timeout: (?P<first_timeout_sec>{Float}) s)?(?: ; )?(?:window: (?P<window_sec>{Float}) s)?(?: ; )?(?:polling: (?P<polling_sec>{Float}) s)?\))?")
|
|
240
|
+
def step_impl(context, socket_varname, first_timeout_sec, window_sec, polling_sec):
|
|
241
|
+
"""Wait socket stop to receive data
|
|
242
|
+
"""
|
|
243
|
+
sock = StepTools.evaluate_scenario_parameter(socket_varname)
|
|
244
|
+
first_timeout_sec = StepTools.evaluate_scenario_parameter(first_timeout_sec)
|
|
245
|
+
window_sec = StepTools.evaluate_scenario_parameter(window_sec)
|
|
246
|
+
polling_sec = StepTools.evaluate_scenario_parameter(polling_sec)
|
|
247
|
+
|
|
248
|
+
wait = WaitEndChange(f"Wait end of data reception (socket: {sock})",
|
|
249
|
+
lambda: sock.received_data_size,
|
|
250
|
+
first_timeout_seconds=first_timeout_sec, window_seconds=window_sec, polling_seconds=polling_sec)
|
|
251
|
+
wait.without_raise_on_timeout()
|
|
252
|
+
data_size = wait.execute()
|
|
253
|
+
if data_size == 0:
|
|
254
|
+
raise FunctionalException(f"[{sock.name}] No data was received (timeout: {wait.timeout} seconds)")
|
|
255
|
+
|
|
256
|
+
@Given(r"reset stored received data in socket (?P<socket_varname>{Variable})")
|
|
257
|
+
def step_impl(context, socket_varname):
|
|
258
|
+
sock = StepTools.evaluate_scenario_parameter(socket_varname)
|
|
259
|
+
sock.reset_received_data()
|
|
260
|
+
|
|
164
261
|
|
|
165
262
|
|
|
166
263
|
# For client and servers managing messages
|
|
@@ -216,43 +313,72 @@ def step_impl(context, var_name, socket_varname):
|
|
|
216
313
|
var_name = StepTools.evaluate_variable_name(var_name)
|
|
217
314
|
sock = StepTools.evaluate_scenario_parameter(socket_varname)
|
|
218
315
|
|
|
219
|
-
res =
|
|
316
|
+
res = sock.nb_messages
|
|
220
317
|
|
|
221
318
|
__get_variable_manager().register_variable(var_name, res)
|
|
222
319
|
|
|
223
|
-
@Step(r"
|
|
224
|
-
def step_impl(context, socket_varname,
|
|
225
|
-
"""
|
|
320
|
+
@Step(r"socket (?P<socket_varname>{Variable}) doesn't receive any message(?: \((?:timeout: (?P<timeout_sec>{Float}) s)?(?: ; )?(?:polling: (?P<polling_sec>{Float}) s)?\))?")
|
|
321
|
+
def step_impl(context, socket_varname, timeout_sec, polling_sec):
|
|
322
|
+
"""Wait and verify socket doesn't receive any message
|
|
323
|
+
"""
|
|
324
|
+
sock = StepTools.evaluate_scenario_parameter(socket_varname)
|
|
325
|
+
timeout_sec = StepTools.evaluate_scenario_parameter(timeout_sec)
|
|
326
|
+
polling_sec = StepTools.evaluate_scenario_parameter(polling_sec)
|
|
327
|
+
|
|
328
|
+
if timeout_sec is None:
|
|
329
|
+
timeout_sec = 10
|
|
330
|
+
|
|
331
|
+
wait = WaitChange(f"Wait end of message reception (socket: {sock})",
|
|
332
|
+
lambda: sock.nb_messages,
|
|
333
|
+
timeout_seconds=timeout_sec, polling_seconds=polling_sec)
|
|
334
|
+
wait.without_raise_on_timeout()
|
|
335
|
+
nb_messages = wait.execute()
|
|
336
|
+
if nb_messages > 0:
|
|
337
|
+
raise FunctionalException(f"[{sock.name}] Socket has received {nb_messages} messages (timeout: {wait.timeout} seconds)")
|
|
338
|
+
|
|
339
|
+
@Step(r"await socket (?P<socket_varname>{Variable}) receives (?:(?P<no_str>no) )?messages(?: \((?:first timeout: (?P<first_timeout_sec>{Float}) s)?(?: ; )?(?:window: (?P<window_sec>{Float}) s)?(?: ; )?(?:polling: (?P<polling_sec>{Float}) s)?\))?")
|
|
340
|
+
def step_impl(context, socket_varname, no_str, first_timeout_sec, window_sec, polling_sec):
|
|
341
|
+
"""Wait until socket receives messages or no messages.
|
|
342
|
+
Wait during max first_timeout_sec duration for a first message, then, and after each new message, wait during max window_sec duration for a new message.
|
|
343
|
+
If no message is received during first_timeout_sec duration, an error is raised only if messages are waited (ie 'no ' is not added when calling step).
|
|
226
344
|
"""
|
|
227
345
|
sock = StepTools.evaluate_scenario_parameter(socket_varname)
|
|
346
|
+
no_messages = no_str is not None
|
|
228
347
|
first_timeout_sec = StepTools.evaluate_scenario_parameter(first_timeout_sec)
|
|
229
348
|
window_sec = StepTools.evaluate_scenario_parameter(window_sec)
|
|
230
349
|
polling_sec = StepTools.evaluate_scenario_parameter(polling_sec)
|
|
231
350
|
|
|
232
|
-
wait = WaitEndChange(f"Wait
|
|
233
|
-
lambda: sock.
|
|
351
|
+
wait = WaitEndChange(f"Wait until socket receives {no_str if no_str is not None else ''}messages (socket: {sock})",
|
|
352
|
+
lambda: sock.nb_messages,
|
|
234
353
|
first_timeout_seconds=first_timeout_sec, window_seconds=window_sec, polling_seconds=polling_sec)
|
|
235
354
|
wait.without_raise_on_timeout()
|
|
236
|
-
|
|
237
|
-
if
|
|
238
|
-
raise FunctionalException(f"[{sock.name}] No
|
|
355
|
+
nb_messages = wait.execute()
|
|
356
|
+
if not no_messages and nb_messages == 0:
|
|
357
|
+
raise FunctionalException(f"[{sock.name}] No message was received (timeout: {wait.timeout} seconds)")
|
|
239
358
|
|
|
240
|
-
@Step(r"
|
|
241
|
-
def step_impl(context, socket_varname,
|
|
359
|
+
@Step(r"await socket (?P<socket_varname>{Variable}) receives a message(?: \((?:timeout: (?P<timeout_sec>{Float}) s)?(?: ; )?(?:polling: (?P<polling_sec>{Float}) s)?\))?")
|
|
360
|
+
def step_impl(context, socket_varname, timeout_sec, polling_sec):
|
|
242
361
|
"""Get received messages without removing from socket
|
|
243
362
|
"""
|
|
244
363
|
sock = StepTools.evaluate_scenario_parameter(socket_varname)
|
|
245
|
-
|
|
246
|
-
window_sec = StepTools.evaluate_scenario_parameter(window_sec)
|
|
364
|
+
timeout_sec = StepTools.evaluate_scenario_parameter(timeout_sec)
|
|
247
365
|
polling_sec = StepTools.evaluate_scenario_parameter(polling_sec)
|
|
248
366
|
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
367
|
+
if timeout_sec is None:
|
|
368
|
+
timeout_sec = 10
|
|
369
|
+
|
|
370
|
+
wait = WaitChange(f"Wait a message reception (socket: {sock})",
|
|
371
|
+
lambda: sock.nb_messages,
|
|
372
|
+
timeout_seconds=timeout_sec, polling_seconds=polling_sec)
|
|
252
373
|
wait.without_raise_on_timeout()
|
|
253
374
|
nb_messages = wait.execute()
|
|
254
375
|
if nb_messages == 0:
|
|
255
376
|
raise FunctionalException(f"[{sock.name}] No message was received (timeout: {wait.timeout} seconds)")
|
|
256
377
|
|
|
378
|
+
@Given(r"reset stored received messages in socket (?P<socket_varname>{Variable})")
|
|
379
|
+
def step_impl(context, socket_varname):
|
|
380
|
+
sock = StepTools.evaluate_scenario_parameter(socket_varname)
|
|
381
|
+
sock.reset_received_messages()
|
|
382
|
+
|
|
257
383
|
|
|
258
384
|
|
|
@@ -15,16 +15,11 @@
|
|
|
15
15
|
|
|
16
16
|
from holado_test.scenario.step_tools import StepTools
|
|
17
17
|
from holado.common.context.session_context import SessionContext
|
|
18
|
-
from holado_test.behave.behave import *
|
|
18
|
+
from holado_test.behave.behave import * # @UnusedWildImport
|
|
19
19
|
import logging
|
|
20
|
+
from holado_python.standard_library.ssl.ssl import SslManager
|
|
20
21
|
from holado_test.behave.scenario.behave_step_tools import BehaveStepTools
|
|
21
22
|
from holado_value.common.tables.converters.value_table_converter import ValueTableConverter
|
|
22
|
-
from holado_python.standard_library.socket.blocking_socket import TCPBlockingSocketClient
|
|
23
|
-
from holado_python.standard_library.socket.echo_server import EchoTCPBlockingSocketServer
|
|
24
|
-
from holado_python.standard_library.socket.message_socket import MessageTCPSocketClient
|
|
25
|
-
from holado_core.common.handlers.wait import WaitFuncResultVerifying, WaitEndChange
|
|
26
|
-
from holado_core.common.exceptions.functional_exception import FunctionalException
|
|
27
|
-
from holado_python.standard_library.ssl.ssl import SslManager
|
|
28
23
|
|
|
29
24
|
logger = logging.getLogger(__name__)
|
|
30
25
|
|
|
@@ -40,28 +35,104 @@ def __get_variable_manager():
|
|
|
40
35
|
|
|
41
36
|
|
|
42
37
|
|
|
43
|
-
@Given(r"(?P<var_name>{Variable}) =
|
|
38
|
+
@Given(r"(?P<var_name>{Variable}) = default CA certs file path")
|
|
44
39
|
def step_impl(context, var_name):
|
|
45
|
-
"""Return path to cert file
|
|
46
|
-
Note: It
|
|
40
|
+
"""Return path to default cert file.
|
|
41
|
+
Note: It uses ssl.get_default_verify_paths method.
|
|
47
42
|
"""
|
|
48
43
|
var_name = StepTools.evaluate_variable_name(var_name)
|
|
49
44
|
|
|
50
|
-
|
|
45
|
+
default_certs = SslManager.get_default_certificates()
|
|
51
46
|
|
|
52
|
-
__get_variable_manager().register_variable(var_name,
|
|
47
|
+
__get_variable_manager().register_variable(var_name, default_certs[0])
|
|
48
|
+
|
|
49
|
+
|
|
50
|
+
@Given(r"(?P<var_name>{Variable}) = default certs directory path")
|
|
51
|
+
def step_impl(context, var_name):
|
|
52
|
+
"""Return path to default certs folder.
|
|
53
|
+
Note: It uses ssl.get_default_verify_paths method.
|
|
54
|
+
"""
|
|
55
|
+
var_name = StepTools.evaluate_variable_name(var_name)
|
|
56
|
+
|
|
57
|
+
default_certs = SslManager.get_default_certificates()
|
|
58
|
+
|
|
59
|
+
__get_variable_manager().register_variable(var_name, default_certs[1])
|
|
53
60
|
|
|
54
61
|
|
|
55
|
-
@Given(r"(?P<var_name>{Variable}) =
|
|
62
|
+
@Given(r"(?P<var_name>{Variable}) = CA certs file path \(from certifi package\)")
|
|
56
63
|
def step_impl(context, var_name):
|
|
57
|
-
"""Return path to
|
|
58
|
-
Note: It is an autosigned certificate.
|
|
64
|
+
"""Return path to CA certs file from 'certifi' package.
|
|
59
65
|
"""
|
|
60
66
|
var_name = StepTools.evaluate_variable_name(var_name)
|
|
61
67
|
|
|
62
|
-
|
|
68
|
+
cacerts_path = SslManager.get_certifi_ca_certs_file_path()
|
|
63
69
|
|
|
70
|
+
__get_variable_manager().register_variable(var_name, cacerts_path)
|
|
71
|
+
|
|
72
|
+
|
|
73
|
+
# @Given(r"(?P<var_name>{Variable}) = certfile path for localhost")
|
|
74
|
+
# def step_impl(context, var_name):
|
|
75
|
+
# """Return path to cert file for localhost stored in internal resources.
|
|
76
|
+
# Note: It is an autosigned certificate.
|
|
77
|
+
# """
|
|
78
|
+
# var_name = StepTools.evaluate_variable_name(var_name)
|
|
79
|
+
#
|
|
80
|
+
# cert_paths = SslManager.get_localhost_certificate()
|
|
81
|
+
#
|
|
82
|
+
# __get_variable_manager().register_variable(var_name, cert_paths[0])
|
|
83
|
+
#
|
|
84
|
+
#
|
|
85
|
+
# @Given(r"(?P<var_name>{Variable}) = keyfile path for localhost")
|
|
86
|
+
# def step_impl(context, var_name):
|
|
87
|
+
# """Return path to key file for localhost stored in internal resources.
|
|
88
|
+
# Note: It is an autosigned certificate.
|
|
89
|
+
# """
|
|
90
|
+
# var_name = StepTools.evaluate_variable_name(var_name)
|
|
91
|
+
#
|
|
92
|
+
# cert_paths = SslManager.get_localhost_certificate()
|
|
93
|
+
#
|
|
94
|
+
# __get_variable_manager().register_variable(var_name, cert_paths[1])
|
|
95
|
+
|
|
96
|
+
@Given(r"generate new self-signed key files for localhost")
|
|
97
|
+
def step_impl(context):
|
|
98
|
+
"""Generate public and private keys for a localhost use.
|
|
99
|
+
"""
|
|
100
|
+
table = BehaveStepTools.convert_step_table_2_value_table_with_header(context.table)
|
|
101
|
+
kwargs = ValueTableConverter.convert_name_value_table_2_dict(table)
|
|
102
|
+
|
|
103
|
+
SslManager.generate_new_self_signed_key_files_for_localhost(**kwargs)
|
|
104
|
+
|
|
105
|
+
|
|
106
|
+
@Given(r"(?P<var_name>{Variable}) = certfile path for tcpbin.com")
|
|
107
|
+
def step_impl(context, var_name):
|
|
108
|
+
"""Return path to cert file for tcpbin.com stored in internal resources.
|
|
109
|
+
Note: If certificate has expired, a new one is generated.
|
|
110
|
+
"""
|
|
111
|
+
var_name = StepTools.evaluate_variable_name(var_name)
|
|
112
|
+
|
|
113
|
+
cert_paths = SslManager.get_tcpbin_certificates()
|
|
114
|
+
|
|
115
|
+
__get_variable_manager().register_variable(var_name, cert_paths[0])
|
|
116
|
+
|
|
117
|
+
@Given(r"(?P<var_name>{Variable}) = keyfile path for tcpbin.com")
|
|
118
|
+
def step_impl(context, var_name):
|
|
119
|
+
"""Return path to key file for tcpbin.com stored in internal resources.
|
|
120
|
+
Note: If certificate has expired, a new one is generated.
|
|
121
|
+
"""
|
|
122
|
+
var_name = StepTools.evaluate_variable_name(var_name)
|
|
123
|
+
|
|
124
|
+
cert_paths = SslManager.get_tcpbin_certificates()
|
|
125
|
+
|
|
64
126
|
__get_variable_manager().register_variable(var_name, cert_paths[1])
|
|
65
127
|
|
|
128
|
+
@Given(r"(?P<var_name>{Variable}) = CA certfile path for tcpbin.com")
|
|
129
|
+
def step_impl(context, var_name):
|
|
130
|
+
"""Return path to cert file for tcpbin.com stored in internal resources.
|
|
131
|
+
Note: If certificate has expired, a new one is generated.
|
|
132
|
+
"""
|
|
133
|
+
var_name = StepTools.evaluate_variable_name(var_name)
|
|
134
|
+
|
|
135
|
+
cert_paths = SslManager.get_tcpbin_certificates()
|
|
66
136
|
|
|
137
|
+
__get_variable_manager().register_variable(var_name, cert_paths[2])
|
|
67
138
|
|
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
from holado_value.common.tables.comparators.table_2_value_table_comparator import Table2ValueTable_Comparator
|
|
17
17
|
from holado_test.scenario.step_tools import StepTools
|
|
18
18
|
from holado.common.context.session_context import SessionContext
|
|
19
|
-
from holado_test.behave.behave import *
|
|
19
|
+
from holado_test.behave.behave import * # @UnusedWildImport
|
|
20
20
|
from holado_rabbitmq.tools.rabbitmq import rabbitmq_client
|
|
21
21
|
from holado_core.common.tables.table_manager import TableManager
|
|
22
22
|
from holado_core.common.exceptions.functional_exception import FunctionalException
|
|
@@ -369,43 +369,41 @@ if rabbitmq_client.RMQClient.is_available():
|
|
|
369
369
|
rate = counter / (end - beg)
|
|
370
370
|
logger.print(f"[Queue {q_name} -> Publisher {pub_name}] Mean rate: {int(rate)} msg/s ; Nb messages: {counter}")
|
|
371
371
|
|
|
372
|
-
@When(r"
|
|
373
|
-
def step_impl(context, var_con, timeout_sec, polling_sec
|
|
372
|
+
@When(r"await consumer (?P<var_con>{Variable}) receives a message(?: \(timeout: (?P<timeout_sec>{Float}) s(?: ; polling: (?P<polling_sec>{Float}) s)?\))?")
|
|
373
|
+
def step_impl(context, var_con, timeout_sec, polling_sec):
|
|
374
374
|
con = StepTools.evaluate_variable_value(var_con)
|
|
375
375
|
timeout_sec = StepTools.evaluate_scenario_parameter(timeout_sec)
|
|
376
376
|
polling_sec = StepTools.evaluate_scenario_parameter(polling_sec)
|
|
377
|
-
do_raise = StepTools.evaluate_scenario_parameter(do_raise)
|
|
378
377
|
|
|
379
|
-
__get_rabbitmq_manager().
|
|
378
|
+
__get_rabbitmq_manager().await_message_reception([con], timeout_seconds=timeout_sec, polling_seconds=polling_sec)
|
|
380
379
|
|
|
381
|
-
@When(r"
|
|
382
|
-
def step_impl(context, list_consumers, timeout_sec, polling_sec
|
|
380
|
+
@When(r"await consumers (?P<list_consumers>{List}) receive a message(?: \(timeout: (?P<timeout_sec>{Float}) s(?: ; polling: (?P<polling_sec>{Float}) s)?\))?")
|
|
381
|
+
def step_impl(context, list_consumers, timeout_sec, polling_sec):
|
|
383
382
|
consumers = StepTools.evaluate_list_scenario_parameter(list_consumers, "list_consumers")
|
|
384
383
|
timeout_sec = StepTools.evaluate_scenario_parameter(timeout_sec)
|
|
385
384
|
polling_sec = StepTools.evaluate_scenario_parameter(polling_sec)
|
|
386
|
-
do_raise = StepTools.evaluate_scenario_parameter(do_raise)
|
|
387
385
|
|
|
388
|
-
__get_rabbitmq_manager().
|
|
386
|
+
__get_rabbitmq_manager().await_message_reception(consumers, timeout_seconds=timeout_sec, polling_seconds=polling_sec)
|
|
389
387
|
|
|
390
|
-
@When(r"
|
|
391
|
-
def step_impl(context, var_con, first_timeout_sec, window_sec, polling_sec
|
|
388
|
+
@When(r"await consumer (?P<var_con>{Variable}) receives (?:(?P<no_str>no) )?messages(?: \((?:first timeout: (?P<first_timeout_sec>{Float}) s)?(?: ; )?(?:window: (?P<window_sec>{Float}) s)?(?: ; )?(?:polling: (?P<polling_sec>{Float}) s)?\))?")
|
|
389
|
+
def step_impl(context, var_con, no_str, first_timeout_sec, window_sec, polling_sec):
|
|
392
390
|
con = StepTools.evaluate_variable_value(var_con)
|
|
393
391
|
first_timeout_sec = StepTools.evaluate_scenario_parameter(first_timeout_sec)
|
|
394
392
|
window_sec = StepTools.evaluate_scenario_parameter(window_sec)
|
|
395
393
|
polling_sec = StepTools.evaluate_scenario_parameter(polling_sec)
|
|
396
|
-
do_raise =
|
|
394
|
+
do_raise = no_str is None
|
|
397
395
|
|
|
398
|
-
__get_rabbitmq_manager().
|
|
396
|
+
__get_rabbitmq_manager().await_messages_reception([con], first_timeout_seconds=first_timeout_sec, window_seconds=window_sec, polling_seconds=polling_sec, raise_exception=do_raise)
|
|
399
397
|
|
|
400
|
-
@When(r"
|
|
401
|
-
def step_impl(context, list_consumers, first_timeout_sec, window_sec, polling_sec
|
|
398
|
+
@When(r"await consumers (?P<list_consumers>{List}) receive (?:(?P<no_str>no) )?messages(?: \((?:first timeout: (?P<first_timeout_sec>{Float}) s)?(?: ; )?(?:window: (?P<window_sec>{Float}) s)?(?: ; )?(?:polling: (?P<polling_sec>{Float}) s)?\))?")
|
|
399
|
+
def step_impl(context, list_consumers, no_str, first_timeout_sec, window_sec, polling_sec):
|
|
402
400
|
consumers = StepTools.evaluate_list_scenario_parameter(list_consumers, "list_consumers")
|
|
403
401
|
first_timeout_sec = StepTools.evaluate_scenario_parameter(first_timeout_sec)
|
|
404
402
|
window_sec = StepTools.evaluate_scenario_parameter(window_sec)
|
|
405
403
|
polling_sec = StepTools.evaluate_scenario_parameter(polling_sec)
|
|
406
|
-
do_raise =
|
|
404
|
+
do_raise = no_str is None
|
|
407
405
|
|
|
408
|
-
__get_rabbitmq_manager().
|
|
406
|
+
__get_rabbitmq_manager().await_messages_reception(consumers, first_timeout_seconds=first_timeout_sec, window_seconds=window_sec, polling_seconds=polling_sec, raise_exception=do_raise)
|
|
409
407
|
|
|
410
408
|
@Then(r"consumer (?P<var_con>{Variable}) doesn't receive any message \(timeout: (?P<timeout_sec>{Float}) s ; polling: (?P<polling_sec>{Float}) s\)")
|
|
411
409
|
def step_impl(context, var_con, timeout_sec, polling_sec):
|
|
@@ -413,7 +411,7 @@ if rabbitmq_client.RMQClient.is_available():
|
|
|
413
411
|
timeout_sec = StepTools.evaluate_scenario_parameter(timeout_sec)
|
|
414
412
|
polling_sec = StepTools.evaluate_scenario_parameter(polling_sec)
|
|
415
413
|
|
|
416
|
-
nb = __get_rabbitmq_manager().
|
|
414
|
+
nb = __get_rabbitmq_manager().await_message_reception([con], timeout_seconds=timeout_sec, polling_seconds=polling_sec, raise_exception=False)
|
|
417
415
|
if nb > 0:
|
|
418
416
|
raise FunctionalException(f"Consumer has received {nb} messages")
|
|
419
417
|
|
|
@@ -423,7 +421,7 @@ if rabbitmq_client.RMQClient.is_available():
|
|
|
423
421
|
timeout_sec = StepTools.evaluate_scenario_parameter(timeout_sec)
|
|
424
422
|
polling_sec = StepTools.evaluate_scenario_parameter(polling_sec)
|
|
425
423
|
|
|
426
|
-
nb = __get_rabbitmq_manager().
|
|
424
|
+
nb = __get_rabbitmq_manager().await_message_reception(consumers, timeout_seconds=timeout_sec, polling_seconds=polling_sec, raise_exception=False)
|
|
427
425
|
if nb > 0:
|
|
428
426
|
raise FunctionalException(f"Consumer has received {nb} messages")
|
|
429
427
|
|
|
@@ -533,5 +531,35 @@ if rabbitmq_client.RMQClient.is_available():
|
|
|
533
531
|
def step_impl(context, queue, var_client):
|
|
534
532
|
queue = StepTools.evaluate_scenario_parameter(queue)
|
|
535
533
|
client = StepTools.evaluate_variable_value(var_client)
|
|
536
|
-
client.
|
|
534
|
+
client.purge_queue(queue)
|
|
537
535
|
|
|
536
|
+
@Step(r"delete and recreate stream queue (?P<queue>{Str}) \(RMQ client: (?P<var_client>{Variable})\)")
|
|
537
|
+
def step_impl(context, queue, var_client):
|
|
538
|
+
queue_name = StepTools.evaluate_scenario_parameter(queue)
|
|
539
|
+
client = StepTools.evaluate_variable_value(var_client)
|
|
540
|
+
client.delete_queue(queue_name)
|
|
541
|
+
client._queue_declare(
|
|
542
|
+
channel=client.connection.channel(),
|
|
543
|
+
queue=queue_name,
|
|
544
|
+
queue_args={
|
|
545
|
+
'durable': True,
|
|
546
|
+
"x-queue-type": "stream",
|
|
547
|
+
"x-stream-max-segment-size-bytes": 100000000
|
|
548
|
+
})
|
|
549
|
+
|
|
550
|
+
@Step(r"bind queue (?P<queue>{Str}) to exchange (?P<exchange>{Str})(?: with routine key (?P<routine_key>{Str}))? \(RMQ client: (?P<var_client>{Variable})\)")
|
|
551
|
+
def step_impl(context, queue, exchange, routine_key, var_client):
|
|
552
|
+
queue_name = StepTools.evaluate_scenario_parameter(queue)
|
|
553
|
+
exchange = StepTools.evaluate_scenario_parameter(exchange)
|
|
554
|
+
routine_key = StepTools.evaluate_scenario_parameter(routine_key)
|
|
555
|
+
client = StepTools.evaluate_variable_value(var_client)
|
|
556
|
+
bind_args={
|
|
557
|
+
'routing_key': routine_key
|
|
558
|
+
}
|
|
559
|
+
client._queue_bind(
|
|
560
|
+
channel=client.connection.channel(),
|
|
561
|
+
queue=queue_name,
|
|
562
|
+
exchange=exchange,
|
|
563
|
+
bind_args=bind_args
|
|
564
|
+
)
|
|
565
|
+
|
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
|
|
15
15
|
|
|
16
16
|
from holado.common.context.session_context import SessionContext
|
|
17
|
-
from holado_test.behave.behave import *
|
|
17
|
+
from holado_test.behave.behave import * # @UnusedWildImport
|
|
18
18
|
from holado_rabbitmq.tools.rabbitmq import rabbitmq_server
|
|
19
19
|
import logging
|
|
20
20
|
from holado_test.scenario.step_tools import StepTools
|