test(gw): fix test cases

This commit is contained in:
JianBo He 2022-06-16 22:01:49 +08:00
parent ae1346e3f0
commit ad698834df
7 changed files with 14 additions and 15 deletions

View File

@ -57,14 +57,14 @@ all() -> emqx_common_test_helpers:all(?MODULE).
init_per_suite(Config) ->
ok = emqx_common_test_helpers:load_config(emqx_gateway_schema, ?CONF_DEFAULT),
emqx_mgmt_api_test_util:init_suite([emqx_gateway]),
emqx_mgmt_api_test_util:init_suite([emqx_authn, emqx_gateway]),
ok = meck:new(emqx_access_control, [passthrough, no_history, no_link]),
Config.
end_per_suite(_) ->
meck:unload(emqx_access_control),
{ok, _} = emqx:remove_config([<<"gateway">>, <<"coap">>]),
emqx_mgmt_api_test_util:end_suite([emqx_gateway]).
emqx_mgmt_api_test_util:end_suite([emqx_gateway, emqx_authn]).
init_per_testcase(t_connection_with_authn_failed, Config) ->
ok = meck:expect(

View File

@ -57,12 +57,12 @@ all() ->
init_per_suite(Config) ->
ok = emqx_common_test_helpers:load_config(emqx_gateway_schema, ?CONF_DEFAULT),
emqx_mgmt_api_test_util:init_suite([emqx_gateway]),
emqx_mgmt_api_test_util:init_suite([emqx_authn, emqx_gateway]),
Config.
end_per_suite(Config) ->
{ok, _} = emqx:remove_config([<<"gateway">>, <<"coap">>]),
emqx_mgmt_api_test_util:end_suite([emqx_gateway]),
emqx_mgmt_api_test_util:end_suite([emqx_gateway, emqx_authn]),
Config.
%%--------------------------------------------------------------------

View File

@ -73,12 +73,12 @@ metrics() ->
init_per_group(GrpName, Cfg) ->
put(grpname, GrpName),
Svrs = emqx_exproto_echo_svr:start(),
emqx_common_test_helpers:start_apps([emqx_gateway], fun set_special_cfg/1),
emqx_common_test_helpers:start_apps([emqx_authn, emqx_gateway], fun set_special_cfg/1),
[{servers, Svrs}, {listener_type, GrpName} | Cfg].
end_per_group(_, Cfg) ->
emqx_config:erase(gateway),
emqx_common_test_helpers:stop_apps([emqx_gateway]),
emqx_common_test_helpers:stop_apps([emqx_gateway, emqx_authn]),
emqx_exproto_echo_svr:stop(proplists:get_value(servers, Cfg)).
set_special_cfg(emqx_gateway) ->

View File

@ -155,13 +155,13 @@ groups() ->
init_per_suite(Config) ->
%% load application first for minirest api searching
application:load(emqx_gateway),
emqx_mgmt_api_test_util:init_suite([emqx_conf]),
emqx_mgmt_api_test_util:init_suite([emqx_conf, emqx_authn]),
Config.
end_per_suite(Config) ->
timer:sleep(300),
{ok, _} = emqx_conf:remove([<<"gateway">>, <<"lwm2m">>], #{}),
emqx_mgmt_api_test_util:end_suite([emqx_conf]),
emqx_mgmt_api_test_util:end_suite([emqx_conf, emqx_authn]),
Config.
init_per_testcase(_AllTestCase, Config) ->

View File

@ -83,13 +83,13 @@ all() ->
init_per_suite(Config) ->
ok = emqx_common_test_helpers:load_config(emqx_gateway_schema, ?CONF_DEFAULT),
application:load(emqx_gateway),
emqx_mgmt_api_test_util:init_suite([emqx_conf]),
emqx_mgmt_api_test_util:init_suite([emqx_conf, emqx_authn]),
Config.
end_per_suite(Config) ->
timer:sleep(300),
{ok, _} = emqx_conf:remove([<<"gateway">>, <<"lwm2m">>], #{}),
emqx_mgmt_api_test_util:end_suite([emqx_conf]),
emqx_mgmt_api_test_util:end_suite([emqx_authn, emqx_conf]),
Config.
init_per_testcase(_AllTestCase, Config) ->
@ -107,7 +107,6 @@ end_per_testcase(_AllTestCase, Config) ->
gen_udp:close(?config(sock, Config)),
emqtt:disconnect(?config(emqx_c, Config)),
ok = application:stop(emqx_gateway),
ok = application:stop(emqx_authn),
timer:sleep(300).
%%--------------------------------------------------------------------

View File

@ -98,12 +98,12 @@ all() ->
init_per_suite(Config) ->
ok = emqx_common_test_helpers:load_config(emqx_gateway_schema, ?CONF_DEFAULT),
emqx_mgmt_api_test_util:init_suite([emqx_conf, emqx_gateway]),
emqx_mgmt_api_test_util:init_suite([emqx_conf, emqx_authn, emqx_gateway]),
Config.
end_per_suite(_) ->
{ok, _} = emqx:remove_config([gateway, mqttsn]),
emqx_mgmt_api_test_util:end_suite([emqx_gateway, emqx_conf]).
emqx_mgmt_api_test_util:end_suite([emqx_gateway, emqx_auhtn, emqx_conf]).
restart_mqttsn_with_subs_resume_on() ->
Conf = emqx:get_raw_config([gateway, mqttsn]),

View File

@ -54,11 +54,11 @@ all() -> emqx_common_test_helpers:all(?MODULE).
init_per_suite(Cfg) ->
ok = emqx_common_test_helpers:load_config(emqx_gateway_schema, ?CONF_DEFAULT),
emqx_mgmt_api_test_util:init_suite([emqx_gateway]),
emqx_mgmt_api_test_util:init_suite([emqx_authn, emqx_gateway]),
Cfg.
end_per_suite(_Cfg) ->
emqx_mgmt_api_test_util:end_suite([emqx_gateway]),
emqx_mgmt_api_test_util:end_suite([emqx_gateway, emqx_authn]),
ok.
default_config() ->