Merge pull request #13375 from kjellwinblad/kjell/fix_connector_lister_speed_limit_clearing/EMQX-12514
fix: default value for max_conn_rate etc should be set to infinity
This commit is contained in:
commit
a4cc3ba9e8
|
@ -212,16 +212,29 @@ short_paths_fields() ->
|
||||||
short_paths_fields(Importance) ->
|
short_paths_fields(Importance) ->
|
||||||
[
|
[
|
||||||
{Name,
|
{Name,
|
||||||
?HOCON(rate_type(), #{
|
?HOCON(
|
||||||
desc => ?DESC(Name),
|
rate_type(),
|
||||||
required => false,
|
maps:merge(
|
||||||
importance => Importance,
|
#{
|
||||||
example => Example
|
desc => ?DESC(Name),
|
||||||
})}
|
required => false,
|
||||||
|
importance => Importance,
|
||||||
|
example => Example
|
||||||
|
},
|
||||||
|
short_paths_fields_extra(Name)
|
||||||
|
)
|
||||||
|
)}
|
||||||
|| {Name, Example} <-
|
|| {Name, Example} <-
|
||||||
lists:zip(short_paths(), [<<"1000/s">>, <<"1000/s">>, <<"100MB/s">>])
|
lists:zip(short_paths(), [<<"1000/s">>, <<"1000/s">>, <<"100MB/s">>])
|
||||||
].
|
].
|
||||||
|
|
||||||
|
short_paths_fields_extra(max_conn_rate) ->
|
||||||
|
#{
|
||||||
|
default => infinity
|
||||||
|
};
|
||||||
|
short_paths_fields_extra(_Name) ->
|
||||||
|
#{}.
|
||||||
|
|
||||||
desc(limiter) ->
|
desc(limiter) ->
|
||||||
"Settings for the rate limiter.";
|
"Settings for the rate limiter.";
|
||||||
desc(node_opts) ->
|
desc(node_opts) ->
|
||||||
|
|
|
@ -816,8 +816,8 @@ t_no_limiter_for_listener(_) ->
|
||||||
CfgStr = <<>>,
|
CfgStr = <<>>,
|
||||||
ok = emqx_common_test_helpers:load_config(emqx_schema, CfgStr),
|
ok = emqx_common_test_helpers:load_config(emqx_schema, CfgStr),
|
||||||
ListenerOpt = emqx:get_config([listeners, tcp, default]),
|
ListenerOpt = emqx:get_config([listeners, tcp, default]),
|
||||||
?assertEqual(
|
?assertMatch(
|
||||||
undefined,
|
#{connection := #{rate := infinity}},
|
||||||
emqx_limiter_utils:get_listener_opts(ListenerOpt)
|
emqx_limiter_utils:get_listener_opts(ListenerOpt)
|
||||||
).
|
).
|
||||||
|
|
||||||
|
|
|
@ -418,6 +418,35 @@ t_update_listener_zone(_Config) ->
|
||||||
?assertMatch({error, {_, 400, _}}, request(put, Path, [], AddConf1)),
|
?assertMatch({error, {_, 400, _}}, request(put, Path, [], AddConf1)),
|
||||||
?assertMatch(#{<<"zone">> := <<"zone1">>}, request(put, Path, [], AddConf2)).
|
?assertMatch(#{<<"zone">> := <<"zone1">>}, request(put, Path, [], AddConf2)).
|
||||||
|
|
||||||
|
t_update_listener_max_conn_rate({init, Config}) ->
|
||||||
|
Config;
|
||||||
|
t_update_listener_max_conn_rate({'end', _Config}) ->
|
||||||
|
ok;
|
||||||
|
t_update_listener_max_conn_rate(_Config) ->
|
||||||
|
ListenerId = <<"tcp:default">>,
|
||||||
|
Path = emqx_mgmt_api_test_util:api_path(["listeners", ListenerId]),
|
||||||
|
Conf = request(get, Path, [], []),
|
||||||
|
%% Check that default is infinity
|
||||||
|
?assertMatch(#{<<"max_conn_rate">> := <<"infinity">>}, Conf),
|
||||||
|
%% Update to infinity
|
||||||
|
UpdateConfToInfinity = Conf#{<<"max_conn_rate">> => <<"infinity">>},
|
||||||
|
?assertMatch(
|
||||||
|
#{<<"max_conn_rate">> := <<"infinity">>},
|
||||||
|
request(put, Path, [], UpdateConfToInfinity)
|
||||||
|
),
|
||||||
|
%% Update to 42/s
|
||||||
|
UpdateConfTo42PerSec = Conf#{<<"max_conn_rate">> => <<"42/s">>},
|
||||||
|
?assertMatch(
|
||||||
|
#{<<"max_conn_rate">> := <<"42/s">>},
|
||||||
|
request(put, Path, [], UpdateConfTo42PerSec)
|
||||||
|
),
|
||||||
|
%% Update back to infinity
|
||||||
|
UpdateConfToInfinity = Conf#{<<"max_conn_rate">> => <<"infinity">>},
|
||||||
|
?assertMatch(
|
||||||
|
#{<<"max_conn_rate">> := <<"infinity">>},
|
||||||
|
request(put, Path, [], UpdateConfToInfinity)
|
||||||
|
).
|
||||||
|
|
||||||
t_delete_nonexistent_listener(Config) when is_list(Config) ->
|
t_delete_nonexistent_listener(Config) when is_list(Config) ->
|
||||||
NonExist = emqx_mgmt_api_test_util:api_path(["listeners", "tcp:nonexistent"]),
|
NonExist = emqx_mgmt_api_test_util:api_path(["listeners", "tcp:nonexistent"]),
|
||||||
?assertMatch(
|
?assertMatch(
|
||||||
|
|
|
@ -0,0 +1 @@
|
||||||
|
The value infinity has been added as default value to the listener configuration fields max_conn_rate, messages_rate and bytes_rate.
|
Loading…
Reference in New Issue