test: refactor test structure

This commit is contained in:
Thales Macedo Garitezi 2024-08-01 15:34:58 -03:00
parent 3162fe7a27
commit bba9d085d6
3 changed files with 31 additions and 34 deletions

View File

@ -1154,7 +1154,7 @@ t_bridges_probe(Config) ->
?assertMatch(
{ok, 400, #{
<<"code">> := <<"TEST_FAILED">>,
<<"message">> := <<"Connection refused">>
<<"message">> := <<"Connection refused", _/binary>>
}},
request_json(
post,

View File

@ -563,6 +563,7 @@ log_connect_error_reason(Level, Reason, Name) ->
explain_error(econnrefused) ->
<<
"Connection refused. "
"This error indicates that your connection attempt to the MQTT server was rejected. "
"In simpler terms, the server you tried to connect to refused your request. "
"There can be multiple reasons for this. "

View File

@ -27,8 +27,6 @@
-include_lib("common_test/include/ct.hrl").
-include_lib("snabbkaffe/include/snabbkaffe.hrl").
-import(emqx_common_test_helpers, [on_exit/1]).
%% output functions
-export([inspect/3]).
@ -1027,6 +1025,8 @@ t_mqtt_conn_bridge_egress_async_reconnect(_) ->
ct:sleep(1000),
%% stop the listener 1883 to make the bridge disconnected
?check_trace(
begin
ok = emqx_listeners:stop_listener('tcp:default'),
ct:sleep(1500),
?assertMatch(
@ -1051,16 +1051,12 @@ t_mqtt_conn_bridge_egress_async_reconnect(_) ->
|| I <- lists:seq(1, N),
Payload <- [integer_to_binary(I)]
],
Trace = snabbkaffe:collect_trace(50),
?assert(
lists:any(
fun(K) ->
maps:get(msg, K, not_found) =:=
emqx_bridge_mqtt_connector_econnrefused_error
ok
end,
Trace
)
fun(Trace) ->
?assertMatch([_ | _], ?of_kind(emqx_bridge_mqtt_connector_econnrefused_error, Trace)),
ok
end
),
ok.