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:
Kjell Winblad 2024-07-11 16:36:01 +02:00 committed by GitHub
commit a4cc3ba9e8
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 51 additions and 8 deletions

View File

@ -212,16 +212,29 @@ short_paths_fields() ->
short_paths_fields(Importance) ->
[
{Name,
?HOCON(rate_type(), #{
desc => ?DESC(Name),
required => false,
importance => Importance,
example => Example
})}
?HOCON(
rate_type(),
maps:merge(
#{
desc => ?DESC(Name),
required => false,
importance => Importance,
example => Example
},
short_paths_fields_extra(Name)
)
)}
|| {Name, Example} <-
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) ->
"Settings for the rate limiter.";
desc(node_opts) ->

View File

@ -816,8 +816,8 @@ t_no_limiter_for_listener(_) ->
CfgStr = <<>>,
ok = emqx_common_test_helpers:load_config(emqx_schema, CfgStr),
ListenerOpt = emqx:get_config([listeners, tcp, default]),
?assertEqual(
undefined,
?assertMatch(
#{connection := #{rate := infinity}},
emqx_limiter_utils:get_listener_opts(ListenerOpt)
).

View File

@ -418,6 +418,35 @@ t_update_listener_zone(_Config) ->
?assertMatch({error, {_, 400, _}}, request(put, Path, [], AddConf1)),
?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) ->
NonExist = emqx_mgmt_api_test_util:api_path(["listeners", "tcp:nonexistent"]),
?assertMatch(

View File

@ -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.