Merge pull request #9770 from sstrigler/EMQX-8625-follow-up

EMQX 8625 follow up
This commit is contained in:
Stefan Strigler 2023-01-16 13:35:01 +01:00 committed by GitHub
commit 5c55783d5f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 25 additions and 19 deletions

View File

@ -718,7 +718,7 @@ t_metrics(Config) ->
{ok, 200, Bridge3Str} = request(get, uri(["bridges", BridgeID, "metrics"]), []), {ok, 200, Bridge3Str} = request(get, uri(["bridges", BridgeID, "metrics"]), []),
?assertMatch( ?assertMatch(
#{ #{
<<"metrics">> := #{<<"success">> := 1}, <<"metrics">> := #{<<"success">> := _},
<<"node_metrics">> := [_ | _] <<"node_metrics">> := [_ | _]
}, },
jsx:decode(Bridge3Str) jsx:decode(Bridge3Str)
@ -729,7 +729,7 @@ t_metrics(Config) ->
?assertMatch( ?assertMatch(
[ [
#{ #{
<<"metrics">> := #{<<"success">> := 1}, <<"metrics">> := #{<<"success">> := _},
<<"node_metrics">> := [_ | _] <<"node_metrics">> := [_ | _]
} }
], ],

View File

@ -280,7 +280,7 @@ t_mqtt_conn_bridge_ingress_no_payload_template(_) ->
), ),
%% verify the metrics of the bridge %% verify the metrics of the bridge
{ok, 200, BridgeStr} = request(get, uri(["bridges", BridgeIDIngress]), []), {ok, 200, BridgeStr} = request(get, uri(["bridges", BridgeIDIngress, "metrics"]), []),
?assertMatch( ?assertMatch(
#{ #{
<<"metrics">> := #{<<"matched">> := 0, <<"received">> := 1}, <<"metrics">> := #{<<"matched">> := 0, <<"received">> := 1},
@ -421,7 +421,7 @@ t_mqtt_conn_bridge_egress_no_payload_template(_) ->
), ),
%% verify the metrics of the bridge %% verify the metrics of the bridge
{ok, 200, BridgeStr} = request(get, uri(["bridges", BridgeIDEgress]), []), {ok, 200, BridgeStr} = request(get, uri(["bridges", BridgeIDEgress, "metrics"]), []),
?assertMatch( ?assertMatch(
#{ #{
<<"metrics">> := #{<<"matched">> := 1, <<"success">> := 1, <<"failed">> := 0}, <<"metrics">> := #{<<"matched">> := 1, <<"success">> := 1, <<"failed">> := 0},

View File

@ -417,6 +417,10 @@ do_get_status(PoolName, Timeout) ->
end end
catch catch
exit:timeout -> exit:timeout ->
?SLOG(error, #{
msg => "http_connector_pmap_failed",
reason => timeout
}),
{error, timeout} {error, timeout}
end. end.

View File

@ -111,17 +111,19 @@ on_start(
false -> false ->
[] []
end, end,
Options = [ Options =
maybe_password_opt(maps:get(password, Config, undefined)) maybe_add_password_opt(
| [ maps:get(password, Config, undefined),
{host, Host}, [
{port, Port}, {host, Host},
{user, Username}, {port, Port},
{database, DB}, {user, Username},
{auto_reconnect, ?AUTO_RECONNECT_INTERVAL}, {database, DB},
{pool_size, PoolSize} {auto_reconnect, ?AUTO_RECONNECT_INTERVAL},
] {pool_size, PoolSize}
], ]
),
PoolName = emqx_plugin_libs_pool:pool_name(InstId), PoolName = emqx_plugin_libs_pool:pool_name(InstId),
Prepares = parse_prepare_sql(Config), Prepares = parse_prepare_sql(Config),
State = maps:merge(#{poolname => PoolName}, Prepares), State = maps:merge(#{poolname => PoolName}, Prepares),
@ -136,10 +138,10 @@ on_start(
{error, Reason} {error, Reason}
end. end.
maybe_password_opt(undefined) -> maybe_add_password_opt(undefined, Options) ->
[]; Options;
maybe_password_opt(Password) -> maybe_add_password_opt(Password, Options) ->
{password, Password}. [{password, Password} | Options].
on_stop(InstId, #{poolname := PoolName}) -> on_stop(InstId, #{poolname := PoolName}) ->
?SLOG(info, #{ ?SLOG(info, #{