test(retainer): fix flow control test case error

This commit is contained in:
firest 2022-05-24 11:11:22 +08:00
parent 74f715ca08
commit 89de8274a0
8 changed files with 25 additions and 15 deletions

View File

@ -2,5 +2,4 @@
## EMQX Rate Limiter ## EMQX Rate Limiter
##-------------------------------------------------------------------- ##--------------------------------------------------------------------
limiter { limiter {}
}

View File

@ -54,7 +54,8 @@ start(Type, Cfg) ->
stop(Type) -> stop(Type) ->
Id = emqx_limiter_server:name(Type), Id = emqx_limiter_server:name(Type),
supervisor:terminate_child(?MODULE, Id). _ = supervisor:terminate_child(?MODULE, Id),
supervisor:delete_child(?MODULE, Id).
%%-------------------------------------------------------------------- %%--------------------------------------------------------------------
%% Supervisor callbacks %% Supervisor callbacks

View File

@ -151,7 +151,7 @@ start_apps(Apps, Handler) when is_function(Handler) ->
%% Because, minirest, ekka etc.. application will scan these modules %% Because, minirest, ekka etc.. application will scan these modules
lists:foreach(fun load/1, [emqx | Apps]), lists:foreach(fun load/1, [emqx | Apps]),
ok = start_ekka(), ok = start_ekka(),
ok = emqx_ratelimiter_SUITE:base_conf(), ok = emqx_ratelimiter_SUITE:load_conf(),
lists:foreach(fun(App) -> start_app(App, Handler) end, [emqx | Apps]). lists:foreach(fun(App) -> start_app(App, Handler) end, [emqx | Apps]).
load(App) -> load(App) ->

View File

@ -29,6 +29,7 @@
"\n" "\n"
"limiter {\n" "limiter {\n"
" bytes_in {\n" " bytes_in {\n"
" enable = true\n"
" bucket.default {\n" " bucket.default {\n"
" rate = infinity\n" " rate = infinity\n"
" capacity = infinity\n" " capacity = infinity\n"
@ -36,6 +37,7 @@
" }\n" " }\n"
"\n" "\n"
" message_in {\n" " message_in {\n"
" enable = true\n"
" bucket.default {\n" " bucket.default {\n"
" rate = infinity\n" " rate = infinity\n"
" capacity = infinity\n" " capacity = infinity\n"
@ -43,6 +45,7 @@
" }\n" " }\n"
"\n" "\n"
" connection {\n" " connection {\n"
" enable = true\n"
" bucket.default {\n" " bucket.default {\n"
" rate = infinity\n" " rate = infinity\n"
" capacity = infinity\n" " capacity = infinity\n"
@ -50,6 +53,7 @@
" }\n" " }\n"
"\n" "\n"
" message_routing {\n" " message_routing {\n"
" enable = true\n"
" bucket.default {\n" " bucket.default {\n"
" rate = infinity\n" " rate = infinity\n"
" capacity = infinity\n" " capacity = infinity\n"
@ -57,6 +61,7 @@
" }\n" " }\n"
"\n" "\n"
" batch {\n" " batch {\n"
" enable = true\n"
" bucket.retainer {\n" " bucket.retainer {\n"
" rate = infinity\n" " rate = infinity\n"
" capacity = infinity\n" " capacity = infinity\n"
@ -79,7 +84,6 @@
-define(LOGT(Format, Args), ct:pal("TEST_SUITE: " ++ Format, Args)). -define(LOGT(Format, Args), ct:pal("TEST_SUITE: " ++ Format, Args)).
-define(RATE(Rate), to_rate(Rate)). -define(RATE(Rate), to_rate(Rate)).
-define(NOW, erlang:system_time(millisecond)). -define(NOW, erlang:system_time(millisecond)).
-define(CONST(X), fun(_) -> X end).
%%-------------------------------------------------------------------- %%--------------------------------------------------------------------
%% Setups %% Setups
@ -98,9 +102,12 @@ end_per_suite(_Config) ->
init_per_testcase(_TestCase, Config) -> init_per_testcase(_TestCase, Config) ->
Config. Config.
base_conf() -> load_conf() ->
emqx_common_test_helpers:load_config(emqx_limiter_schema, ?BASE_CONF). emqx_common_test_helpers:load_config(emqx_limiter_schema, ?BASE_CONF).
init_config() ->
emqx_config:init_load(emqx_limiter_schema, ?BASE_CONF).
%%-------------------------------------------------------------------- %%--------------------------------------------------------------------
%% Test Cases Bucket Level %% Test Cases Bucket Level
%%-------------------------------------------------------------------- %%--------------------------------------------------------------------

View File

@ -71,16 +71,17 @@ common_tests() ->
%%-------------------------------------------------------------------- %%--------------------------------------------------------------------
init_per_suite(Config) -> init_per_suite(Config) ->
load_base_conf(), emqx_common_test_helpers:start_apps([emqx_conf]),
emqx_ratelimiter_SUITE:base_conf(), load_conf(),
emqx_common_test_helpers:start_apps([emqx_conf, ?APP]), emqx_limiter_sup:start_link(),
timer:sleep(200),
ok = application:ensure_started(?APP),
Config. Config.
end_per_suite(_Config) -> end_per_suite(_Config) ->
ekka:stop(), ekka:stop(),
mria:stop(), mria:stop(),
mria_mnesia:delete_schema(), mria_mnesia:delete_schema(),
emqx_common_test_helpers:stop_apps([?APP, emqx_conf]). emqx_common_test_helpers:stop_apps([?APP, emqx_conf]).
init_per_group(mnesia_without_indices, Config) -> init_per_group(mnesia_without_indices, Config) ->
@ -111,8 +112,10 @@ init_per_testcase(t_get_basic_usage_info, Config) ->
init_per_testcase(_TestCase, Config) -> init_per_testcase(_TestCase, Config) ->
Config. Config.
load_base_conf() -> load_conf() ->
ok = emqx_common_test_helpers:load_config(emqx_retainer_schema, ?BASE_CONF). ok = emqx_config:delete_override_conf_files(),
emqx_ratelimiter_SUITE:init_config(),
ok = emqx_config:init_load(emqx_retainer_schema, ?BASE_CONF).
%%-------------------------------------------------------------------- %%--------------------------------------------------------------------
%% Test Cases %% Test Cases

View File

@ -34,7 +34,7 @@ init_per_suite(Config) ->
application:load(emqx_conf), application:load(emqx_conf),
ok = ekka:start(), ok = ekka:start(),
ok = mria_rlog:wait_for_shards([?CLUSTER_RPC_SHARD], infinity), ok = mria_rlog:wait_for_shards([?CLUSTER_RPC_SHARD], infinity),
emqx_retainer_SUITE:load_base_conf(), emqx_retainer_SUITE:load_conf(),
emqx_mgmt_api_test_util:init_suite([emqx_retainer, emqx_conf]), emqx_mgmt_api_test_util:init_suite([emqx_retainer, emqx_conf]),
%% make sure no "$SYS/#" topics %% make sure no "$SYS/#" topics
emqx_conf:update([sys_topics], raw_systopic_conf(), #{override_to => cluster}), emqx_conf:update([sys_topics], raw_systopic_conf(), #{override_to => cluster}),

View File

@ -27,7 +27,7 @@
all() -> emqx_common_test_helpers:all(?MODULE). all() -> emqx_common_test_helpers:all(?MODULE).
init_per_suite(Config) -> init_per_suite(Config) ->
emqx_retainer_SUITE:load_base_conf(), emqx_retainer_SUITE:load_conf(),
%% Start Apps %% Start Apps
emqx_common_test_helpers:start_apps([emqx_retainer]), emqx_common_test_helpers:start_apps([emqx_retainer]),
Config. Config.

View File

@ -24,7 +24,7 @@
all() -> emqx_common_test_helpers:all(?MODULE). all() -> emqx_common_test_helpers:all(?MODULE).
init_per_suite(Config) -> init_per_suite(Config) ->
emqx_retainer_SUITE:load_base_conf(), emqx_retainer_SUITE:load_conf(),
%% Start Apps %% Start Apps
emqx_common_test_helpers:start_apps([emqx_retainer]), emqx_common_test_helpers:start_apps([emqx_retainer]),
Config. Config.