chore(gw): integrate emqx-conf

This commit is contained in:
JianBo He 2021-10-22 17:54:22 +08:00 committed by JianBo He
parent 0b36b73ee1
commit 287859fe36
5 changed files with 17 additions and 20 deletions

View File

@ -224,10 +224,10 @@ remove_authn(GwName, ListenerRef) ->
%% @private
update(Req) ->
res(emqx:update_config([gateway], Req)).
res(emqx_conf:update([gateway], Req, #{override_to => cluster})).
res({ok, _Result}) -> ok;
res({error, {pre_config_update,emqx_gateway_conf,Reason}}) -> {error, Reason};
res({error, {error, {pre_config_update,emqx_gateway_conf,Reason}}}) -> {error, Reason};
res({error, Reason}) -> {error, Reason}.
bin({LType, LName}) ->

View File

@ -28,6 +28,10 @@
-include_lib("eunit/include/eunit.hrl").
-define(CONF_DEFAULT, <<"
gateway {}
">>).
%%--------------------------------------------------------------------
%% Setup
%%--------------------------------------------------------------------
@ -35,18 +39,12 @@
all() -> emqx_common_test_helpers:all(?MODULE).
init_per_suite(Conf) ->
%% FIXME: Magic line. for saving gateway schema name for emqx_config
emqx_config:init_load(emqx_gateway_schema, <<"gateway {}">>),
emqx_mgmt_api_test_util:init_suite([emqx_gateway]),
%% Start emqx-authn separately, due to emqx_authn_schema
%% not implementing the roots/0 method, it cannot be started with
%% emqx-ct-helpers at the moment.
{ok, _} = application:ensure_all_started(emqx_authn),
emqx_config:init_load(emqx_gateway_schema, ?CONF_DEFAULT),
emqx_mgmt_api_test_util:init_suite([emqx_conf, emqx_authn, emqx_gateway]),
Conf.
end_per_suite(Conf) ->
application:stop(emqx_authn),
emqx_mgmt_api_test_util:end_suite([emqx_gateway]),
emqx_mgmt_api_test_util:end_suite([emqx_gateway, emqx_authn, emqx_conf]),
Conf.
%%--------------------------------------------------------------------

View File

@ -34,15 +34,12 @@ all() ->
emqx_common_test_helpers:all(?MODULE).
init_per_suite(Conf) ->
%% FIXME: Magic line. for saving gateway schema name for emqx_config
emqx_config:init_load(emqx_gateway_schema, <<"gateway {}">>),
emqx_common_test_helpers:start_apps([emqx_gateway]),
{ok, _} = application:ensure_all_started(emqx_authn),
emqx_common_test_helpers:start_apps([emqx_conf, emqx_authn, emqx_gateway]),
Conf.
end_per_suite(_Conf) ->
application:stop(emqx_authn),
emqx_common_test_helpers:stop_apps([emqx_gateway]).
emqx_common_test_helpers:stop_apps([emqx_gateway, emqx_authn, emqx_conf]).
init_per_testcase(_CaseName, Conf) ->
_ = emqx_gateway_conf:unload_gateway(stomp),

View File

@ -150,12 +150,13 @@ groups() ->
].
init_per_suite(Config) ->
emqx_common_test_helpers:start_apps([]),
emqx_common_test_helpers:start_apps([emqx_conf]),
Config.
end_per_suite(Config) ->
timer:sleep(300),
emqx_common_test_helpers:stop_apps([]),
{ok, _} = emqx_conf:remove([<<"gateway">>,<<"lwm2m">>], #{}),
emqx_common_test_helpers:stop_apps([emqx_conf]),
Config.
init_per_testcase(_AllTestCase, Config) ->

View File

@ -70,12 +70,13 @@ all() ->
init_per_suite(Config) ->
ok = emqx_config:init_load(emqx_gateway_schema, ?CONF_DEFAULT),
emqx_mgmt_api_test_util:init_suite([emqx_gateway]),
emqx_mgmt_api_test_util:init_suite([emqx_conf, emqx_gateway]),
Config.
end_per_suite(Config) ->
timer:sleep(300),
emqx_mgmt_api_test_util:end_suite([emqx_gateway]),
{ok, _} = emqx_conf:remove([<<"gateway">>,<<"lwm2m">>], #{}),
emqx_mgmt_api_test_util:end_suite([emqx_gateway, emqx_conf]),
Config.
init_per_testcase(_AllTestCase, Config) ->