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"]), []),
?assertMatch(
#{
<<"metrics">> := #{<<"success">> := 1},
<<"metrics">> := #{<<"success">> := _},
<<"node_metrics">> := [_ | _]
},
jsx:decode(Bridge3Str)
@ -729,7 +729,7 @@ t_metrics(Config) ->
?assertMatch(
[
#{
<<"metrics">> := #{<<"success">> := 1},
<<"metrics">> := #{<<"success">> := _},
<<"node_metrics">> := [_ | _]
}
],

View File

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

View File

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

View File

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