From e291dcdd18279369042279f5445c9b978ba45bf4 Mon Sep 17 00:00:00 2001 From: Kjell Winblad Date: Mon, 1 Jul 2024 13:11:19 +0200 Subject: [PATCH] fix: default value for max_conn_rate etc should be set to infinity Before this commit the default value for the fields max_conn_rate, messages_rate and bytes_rate were not set. This is fixed by setting the default value to infinity. This breaks the corresponding dashboard fields (they can not be edited) so the dashboard also needs to be updated. Fixes: https://emqx.atlassian.net/browse/EMQX-12514 --- .../emqx_limiter/src/emqx_limiter_schema.erl | 1 + .../test/emqx_mgmt_api_listeners_SUITE.erl | 29 +++++++++++++++++++ 2 files changed, 30 insertions(+) diff --git a/apps/emqx/src/emqx_limiter/src/emqx_limiter_schema.erl b/apps/emqx/src/emqx_limiter/src/emqx_limiter_schema.erl index 8a10a7be2..b9bfda166 100644 --- a/apps/emqx/src/emqx_limiter/src/emqx_limiter_schema.erl +++ b/apps/emqx/src/emqx_limiter/src/emqx_limiter_schema.erl @@ -215,6 +215,7 @@ short_paths_fields(Importance) -> ?HOCON(rate_type(), #{ desc => ?DESC(Name), required => false, + default => infinity, importance => Importance, example => Example })} diff --git a/apps/emqx_management/test/emqx_mgmt_api_listeners_SUITE.erl b/apps/emqx_management/test/emqx_mgmt_api_listeners_SUITE.erl index 02a098f28..227ae0107 100644 --- a/apps/emqx_management/test/emqx_mgmt_api_listeners_SUITE.erl +++ b/apps/emqx_management/test/emqx_mgmt_api_listeners_SUITE.erl @@ -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(