test: refactor test structure

This commit is contained in:
Thales Macedo Garitezi 2024-08-01 14:27:25 -03:00
parent ba2d4f3df3
commit baf2b96cbc
1 changed files with 27 additions and 35 deletions

View File

@ -410,45 +410,37 @@ t_connect_with_more_clients_than_the_broker_accepts(_) ->
NewConf = OrgConf#{<<"max_connections">> => 3}, NewConf = OrgConf#{<<"max_connections">> => 3},
{ok, _} = emqx_mgmt_listeners_conf:update(tcp, default, NewConf), {ok, _} = emqx_mgmt_listeners_conf:update(tcp, default, NewConf),
BridgeName = atom_to_binary(?FUNCTION_NAME), BridgeName = atom_to_binary(?FUNCTION_NAME),
BridgeID = create_bridge( ?check_trace(
?SERVER_CONF#{ #{timetrap => 10_000},
<<"name">> => BridgeName, begin
<<"ingress">> => #{ BridgeID = create_bridge(
<<"pool_size">> => PoolSize, ?SERVER_CONF#{
<<"remote">> => #{ <<"name">> => BridgeName,
<<"topic">> => <<"$share/ingress/", ?INGRESS_REMOTE_TOPIC, "/#">>, <<"ingress">> => #{
<<"qos">> => 1 <<"pool_size">> => PoolSize,
}, <<"remote">> => #{
<<"local">> => #{ <<"topic">> => <<"$share/ingress/", ?INGRESS_REMOTE_TOPIC, "/#">>,
<<"topic">> => <<?INGRESS_LOCAL_TOPIC, "/${topic}">>, <<"qos">> => 1
<<"qos">> => <<"${qos}">>, },
<<"payload">> => <<"${clientid}">>, <<"local">> => #{
<<"retain">> => <<"${retain}">> <<"topic">> => <<?INGRESS_LOCAL_TOPIC, "/${topic}">>,
<<"qos">> => <<"${qos}">>,
<<"payload">> => <<"${clientid}">>,
<<"retain">> => <<"${retain}">>
}
}
} }
} ),
} ?block_until(#{?snk_kind := emqx_bridge_mqtt_connector_tcp_closed}),
), {ok, 204, <<>>} = request(delete, uri(["bridges", BridgeID]), []),
snabbkaffe:block_until( ok
fun
(#{msg := emqx_bridge_mqtt_connector_tcp_closed}) ->
true;
(_) ->
false
end, end,
5000 fun(Trace) ->
), ?assertMatch([_ | _], ?of_kind(emqx_bridge_mqtt_connector_tcp_closed, Trace)),
Trace = snabbkaffe:collect_trace(), ok
?assert( end
lists:any(
fun(K) ->
maps:get(msg, K, not_found) =:=
emqx_bridge_mqtt_connector_tcp_closed
end,
Trace
)
), ),
{ok, 204, <<>>} = request(delete, uri(["bridges", BridgeID]), []),
ok. ok.
t_mqtt_egress_bridge_warns_clean_start(_) -> t_mqtt_egress_bridge_warns_clean_start(_) ->