test: call ct helpers to load config

This commit is contained in:
Zaiming (Stone) Shi 2022-01-25 11:50:18 +01:00
parent 2a01c7a077
commit 2105d1f22b
26 changed files with 34 additions and 34 deletions

View File

@ -96,7 +96,7 @@ all() ->
emqx_common_test_helpers:all(?MODULE). emqx_common_test_helpers:all(?MODULE).
init_per_suite(Config) -> init_per_suite(Config) ->
ok = emqx_config:init_load(emqx_limiter_schema, ?BASE_CONF), ok = emqx_common_test_helpers:load_config(emqx_limiter_schema, ?BASE_CONF),
emqx_common_test_helpers:start_apps([?APP]), emqx_common_test_helpers:start_apps([?APP]),
Config. Config.
@ -107,7 +107,7 @@ init_per_testcase(_TestCase, Config) ->
Config. Config.
base_conf() -> base_conf() ->
emqx_config:init_load(emqx_limiter_schema, ?BASE_CONF). emqx_common_test_helpers:load_config(emqx_limiter_schema, ?BASE_CONF).
%%-------------------------------------------------------------------- %%--------------------------------------------------------------------
%% Test Cases Bucket Level %% Test Cases Bucket Level

View File

@ -58,7 +58,7 @@ init_per_suite(Config) ->
application:load(emqx_dashboard), application:load(emqx_dashboard),
application:load(?APP), application:load(?APP),
ok = emqx_config:init_load(emqx_auto_subscribe_schema, ok = emqx_common_test_helpers:load_config(emqx_auto_subscribe_schema,
<<"auto_subscribe { <<"auto_subscribe {
topics = [ topics = [
{ {

View File

@ -64,7 +64,7 @@ init_per_suite(Config) ->
_ = application:stop(emqx_resource), _ = application:stop(emqx_resource),
_ = application:stop(emqx_connector), _ = application:stop(emqx_connector),
ok = emqx_common_test_helpers:start_apps([emqx_bridge, emqx_dashboard]), ok = emqx_common_test_helpers:start_apps([emqx_bridge, emqx_dashboard]),
ok = emqx_config:init_load(emqx_bridge_schema, ?CONF_DEFAULT), ok = emqx_common_test_helpers:load_config(emqx_bridge_schema, ?CONF_DEFAULT),
Config. Config.
end_per_suite(_Config) -> end_per_suite(_Config) ->

View File

@ -97,9 +97,9 @@ init_per_suite(Config) ->
_ = application:stop(emqx_connector), _ = application:stop(emqx_connector),
ok = emqx_common_test_helpers:start_apps([emqx_rule_engine, emqx_connector, ok = emqx_common_test_helpers:start_apps([emqx_rule_engine, emqx_connector,
emqx_bridge, emqx_dashboard]), emqx_bridge, emqx_dashboard]),
ok = emqx_config:init_load(emqx_connector_schema, <<"connectors: {}">>), ok = emqx_common_test_helpers:load_config(emqx_connector_schema, <<"connectors: {}">>),
ok = emqx_config:init_load(emqx_rule_engine_schema, <<"rule_engine {rules {}}">>), ok = emqx_common_test_helpers:load_config(emqx_rule_engine_schema, <<"rule_engine {rules {}}">>),
ok = emqx_config:init_load(emqx_bridge_schema, ?BRIDGE_CONF_DEFAULT), ok = emqx_common_test_helpers:load_config(emqx_bridge_schema, ?BRIDGE_CONF_DEFAULT),
Config. Config.
end_per_suite(_Config) -> end_per_suite(_Config) ->

View File

@ -53,7 +53,7 @@ gateway.coap
all() -> emqx_common_test_helpers:all(?MODULE). all() -> emqx_common_test_helpers:all(?MODULE).
init_per_suite(Config) -> init_per_suite(Config) ->
ok = emqx_config:init_load(emqx_gateway_schema, ?CONF_DEFAULT), 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_gateway]),
Config. Config.

View File

@ -54,7 +54,7 @@ all() ->
emqx_common_test_helpers:all(?MODULE). emqx_common_test_helpers:all(?MODULE).
init_per_suite(Config) -> init_per_suite(Config) ->
ok = emqx_config:init_load(emqx_gateway_schema, ?CONF_DEFAULT), 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_gateway]),
Config. Config.

View File

@ -32,7 +32,7 @@ all() -> emqx_common_test_helpers:all(?MODULE).
init_per_suite(Conf) -> init_per_suite(Conf) ->
emqx_config:erase(gateway), emqx_config:erase(gateway),
emqx_config:init_load(emqx_gateway_schema, ?CONF_DEFAULT), emqx_common_test_helpers:load_config(emqx_gateway_schema, ?CONF_DEFAULT),
emqx_common_test_helpers:start_apps([emqx_gateway]), emqx_common_test_helpers:start_apps([emqx_gateway]),
Conf. Conf.

View File

@ -40,7 +40,7 @@ all() -> emqx_common_test_helpers:all(?MODULE).
init_per_suite(Conf) -> init_per_suite(Conf) ->
emqx_config:erase(gateway), emqx_config:erase(gateway),
emqx_config:init_load(emqx_gateway_schema, ?CONF_DEFAULT), emqx_common_test_helpers:load_config(emqx_gateway_schema, ?CONF_DEFAULT),
emqx_mgmt_api_test_util:init_suite([emqx_conf, emqx_authn, emqx_gateway]), emqx_mgmt_api_test_util:init_suite([emqx_conf, emqx_authn, emqx_gateway]),
Conf. Conf.

View File

@ -54,7 +54,7 @@ all() -> emqx_common_test_helpers:all(?MODULE).
init_per_suite(Conf) -> init_per_suite(Conf) ->
emqx_config:erase(gateway), emqx_config:erase(gateway),
emqx_config:init_load(emqx_gateway_schema, ?CONF_DEFAULT), emqx_common_test_helpers:load_config(emqx_gateway_schema, ?CONF_DEFAULT),
emqx_mgmt_api_test_util:init_suite([emqx_conf, emqx_authn, emqx_gateway]), emqx_mgmt_api_test_util:init_suite([emqx_conf, emqx_authn, emqx_gateway]),
Conf. Conf.

View File

@ -34,7 +34,7 @@ all() -> emqx_common_test_helpers:all(?MODULE).
init_per_suite(Conf) -> init_per_suite(Conf) ->
emqx_config:erase(gateway), emqx_config:erase(gateway),
emqx_config:init_load(emqx_gateway_schema, ?CONF_DEFAULT), emqx_common_test_helpers:load_config(emqx_gateway_schema, ?CONF_DEFAULT),
emqx_common_test_helpers:start_apps([]), emqx_common_test_helpers:start_apps([]),
ok = meck:new(emqx_gateway_metrics, [passthrough, no_history, no_link]), ok = meck:new(emqx_gateway_metrics, [passthrough, no_history, no_link]),

View File

@ -34,7 +34,7 @@ all() -> emqx_common_test_helpers:all(?MODULE).
init_per_suite(Conf) -> init_per_suite(Conf) ->
emqx_config:erase(gateway), emqx_config:erase(gateway),
emqx_config:init_load(emqx_gateway_schema, ?CONF_DEFAULT), emqx_common_test_helpers:load_config(emqx_gateway_schema, ?CONF_DEFAULT),
emqx_common_test_helpers:start_apps([]), emqx_common_test_helpers:start_apps([]),
Conf. Conf.

View File

@ -34,7 +34,7 @@ all() ->
emqx_common_test_helpers:all(?MODULE). emqx_common_test_helpers:all(?MODULE).
init_per_suite(Conf) -> init_per_suite(Conf) ->
emqx_config:init_load(emqx_gateway_schema, <<"gateway {}">>), emqx_common_test_helpers:load_config(emqx_gateway_schema, <<"gateway {}">>),
emqx_common_test_helpers:start_apps([emqx_conf, emqx_authn, emqx_gateway]), emqx_common_test_helpers:start_apps([emqx_conf, emqx_authn, emqx_gateway]),
Conf. Conf.

View File

@ -33,7 +33,7 @@ all() -> emqx_common_test_helpers:all(?MODULE).
init_per_suite(Conf) -> init_per_suite(Conf) ->
emqx_config:erase(gateway), emqx_config:erase(gateway),
emqx_config:init_load(emqx_gateway_schema, ?CONF_DEFAULT), emqx_common_test_helpers:load_config(emqx_gateway_schema, ?CONF_DEFAULT),
emqx_common_test_helpers:start_apps([]), emqx_common_test_helpers:start_apps([]),
Conf. Conf.

View File

@ -34,7 +34,7 @@ all() -> emqx_common_test_helpers:all(?MODULE).
%%-------------------------------------------------------------------- %%--------------------------------------------------------------------
init_per_suite(Cfg) -> init_per_suite(Cfg) ->
ok = emqx_config:init_load(emqx_gateway_schema, ?CONF_DEFAULT), ok = emqx_common_test_helpers:load_config(emqx_gateway_schema, ?CONF_DEFAULT),
emqx_common_test_helpers:start_apps([emqx_gateway]), emqx_common_test_helpers:start_apps([emqx_gateway]),
Cfg. Cfg.

View File

@ -173,7 +173,7 @@ end_per_suite(Config) ->
Config. Config.
init_per_testcase(_AllTestCase, Config) -> init_per_testcase(_AllTestCase, Config) ->
ok = emqx_config:init_load(emqx_gateway_schema, ?CONF_DEFAULT), ok = emqx_common_test_helpers:load_config(emqx_gateway_schema, ?CONF_DEFAULT),
{ok, _} = application:ensure_all_started(emqx_gateway), {ok, _} = application:ensure_all_started(emqx_gateway),
{ok, ClientUdpSock} = gen_udp:open(0, [binary, {active, false}]), {ok, ClientUdpSock} = gen_udp:open(0, [binary, {active, false}]),

View File

@ -69,7 +69,7 @@ all() ->
emqx_common_test_helpers:all(?MODULE). emqx_common_test_helpers:all(?MODULE).
init_per_suite(Config) -> init_per_suite(Config) ->
ok = emqx_config:init_load(emqx_gateway_schema, ?CONF_DEFAULT), ok = emqx_common_test_helpers:load_config(emqx_gateway_schema, ?CONF_DEFAULT),
application:load(emqx_gateway), application:load(emqx_gateway),
emqx_mgmt_api_test_util:init_suite([emqx_conf]), emqx_mgmt_api_test_util:init_suite([emqx_conf]),
Config. Config.
@ -81,7 +81,7 @@ end_per_suite(Config) ->
Config. Config.
init_per_testcase(_AllTestCase, Config) -> init_per_testcase(_AllTestCase, Config) ->
ok = emqx_config:init_load(emqx_gateway_schema, ?CONF_DEFAULT), ok = emqx_common_test_helpers:load_config(emqx_gateway_schema, ?CONF_DEFAULT),
{ok, _} = application:ensure_all_started(emqx_gateway), {ok, _} = application:ensure_all_started(emqx_gateway),
{ok, ClientUdpSock} = gen_udp:open(0, [binary, {active, false}]), {ok, ClientUdpSock} = gen_udp:open(0, [binary, {active, false}]),

View File

@ -88,7 +88,7 @@ all() ->
emqx_common_test_helpers:all(?MODULE). emqx_common_test_helpers:all(?MODULE).
init_per_suite(Config) -> init_per_suite(Config) ->
ok = emqx_config:init_load(emqx_gateway_schema, ?CONF_DEFAULT), 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_gateway]),
Config. Config.

View File

@ -49,7 +49,7 @@ all() -> emqx_common_test_helpers:all(?MODULE).
%%-------------------------------------------------------------------- %%--------------------------------------------------------------------
init_per_suite(Cfg) -> init_per_suite(Cfg) ->
ok = emqx_config:init_load(emqx_gateway_schema, ?CONF_DEFAULT), 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_gateway]),
Cfg. Cfg.

View File

@ -38,7 +38,7 @@ all() -> emqx_common_test_helpers:all(?MODULE).
init_per_suite(Config) -> init_per_suite(Config) ->
emqx_common_test_helpers:boot_modules(all), emqx_common_test_helpers:boot_modules(all),
emqx_common_test_helpers:start_apps([emqx_modules]), emqx_common_test_helpers:start_apps([emqx_modules]),
ok = emqx_config:init_load(emqx_modules_schema, ?EVENT_MESSAGE), ok = emqx_common_test_helpers:load_config(emqx_modules_schema, ?EVENT_MESSAGE),
Config. Config.
end_per_suite(_Config) -> end_per_suite(_Config) ->

View File

@ -29,7 +29,7 @@ all() ->
emqx_common_test_helpers:all(?MODULE). emqx_common_test_helpers:all(?MODULE).
init_per_suite(Conf) -> init_per_suite(Conf) ->
emqx_config:init_load(emqx_modules_schema, <<"gateway {}">>), emqx_common_test_helpers:load_config(emqx_modules_schema, <<"gateway {}">>),
emqx_common_test_helpers:start_apps([emqx_conf, emqx_modules]), emqx_common_test_helpers:start_apps([emqx_conf, emqx_modules]),
Conf. Conf.

View File

@ -112,7 +112,7 @@ t_rewrite_re_error(_Config) ->
ok. ok.
t_list(_Config) -> t_list(_Config) ->
ok = emqx_config:init_load(emqx_modules_schema, ?REWRITE), ok = emqx_common_test_helpers:load_config(emqx_modules_schema, ?REWRITE),
Expect = [ Expect = [
#{<<"action">> => <<"publish">>, #{<<"action">> => <<"publish">>,
<<"dest_topic">> => <<"z/y/$1">>, <<"dest_topic">> => <<"z/y/$1">>,
@ -130,7 +130,7 @@ t_list(_Config) ->
ok. ok.
t_update(_Config) -> t_update(_Config) ->
ok = emqx_config:init_load(emqx_modules_schema, ?REWRITE), ok = emqx_common_test_helpers:load_config(emqx_modules_schema, ?REWRITE),
Init = emqx_rewrite:list(), Init = emqx_rewrite:list(),
Rules = [#{ Rules = [#{
<<"source_topic">> => <<"test/#">>, <<"source_topic">> => <<"test/#">>,
@ -144,7 +144,7 @@ t_update(_Config) ->
ok. ok.
t_update_disable(_Config) -> t_update_disable(_Config) ->
ok = emqx_config:init_load(emqx_modules_schema, ?REWRITE), ok = emqx_common_test_helpers:load_config(emqx_modules_schema, ?REWRITE),
?assertEqual(ok, emqx_rewrite:update([])), ?assertEqual(ok, emqx_rewrite:update([])),
timer:sleep(150), timer:sleep(150),
@ -159,7 +159,7 @@ t_update_disable(_Config) ->
ok. ok.
t_update_re_failed(_Config) -> t_update_re_failed(_Config) ->
ok = emqx_config:init_load(emqx_modules_schema, ?REWRITE), ok = emqx_common_test_helpers:load_config(emqx_modules_schema, ?REWRITE),
Rules = [#{ Rules = [#{
<<"source_topic">> => <<"test/#">>, <<"source_topic">> => <<"test/#">>,
<<"re">> => <<"*^test/*">>, <<"re">> => <<"*^test/*">>,
@ -188,7 +188,7 @@ receive_publish(Timeout) ->
end. end.
init() -> init() ->
ok = emqx_config:init_load(emqx_modules_schema, ?REWRITE), ok = emqx_common_test_helpers:load_config(emqx_modules_schema, ?REWRITE),
ok = emqx_rewrite:enable(), ok = emqx_rewrite:enable(),
{ok, C} = emqtt:start_link([{clientid, <<"rewrite_client">>}]), {ok, C} = emqtt:start_link([{clientid, <<"rewrite_client">>}]),
{ok, _} = emqtt:connect(C), {ok, _} = emqtt:connect(C),

View File

@ -30,7 +30,7 @@ all() -> emqx_common_test_helpers:all(?MODULE).
init_per_suite(Config) -> init_per_suite(Config) ->
emqx_common_test_helpers:boot_modules(all), emqx_common_test_helpers:boot_modules(all),
emqx_common_test_helpers:start_apps([emqx_modules]), emqx_common_test_helpers:start_apps([emqx_modules]),
ok = emqx_config:init_load(emqx_modules_schema, ?TOPIC), ok = emqx_common_test_helpers:load_config(emqx_modules_schema, ?TOPIC),
Config. Config.
end_per_suite(_Config) -> end_per_suite(_Config) ->

View File

@ -57,7 +57,7 @@ init_per_suite(Config) ->
meck:expect(emqx_alarm, activate, 3, ok), meck:expect(emqx_alarm, activate, 3, ok),
meck:expect(emqx_alarm, deactivate, 3, ok), meck:expect(emqx_alarm, deactivate, 3, ok),
ok = emqx_config:init_load(emqx_retainer_schema, ?BASE_CONF), ok = emqx_common_test_helpers:load_config(emqx_retainer_schema, ?BASE_CONF),
emqx_common_test_helpers:start_apps([emqx_retainer]), emqx_common_test_helpers:start_apps([emqx_retainer]),
Config. Config.

View File

@ -13,7 +13,7 @@ all() ->
init_per_suite(Config) -> init_per_suite(Config) ->
application:load(emqx_conf), application:load(emqx_conf),
ok = emqx_config:init_load(emqx_rule_engine_schema, ?CONF_DEFAULT), ok = emqx_common_test_helpers:load_config(emqx_rule_engine_schema, ?CONF_DEFAULT),
ok = emqx_common_test_helpers:start_apps([emqx_conf, emqx_rule_engine]), ok = emqx_common_test_helpers:start_apps([emqx_conf, emqx_rule_engine]),
Config. Config.

View File

@ -40,7 +40,7 @@ all() ->
emqx_common_test_helpers:all(?MODULE). emqx_common_test_helpers:all(?MODULE).
init_per_suite(Config) -> init_per_suite(Config) ->
ok = emqx_config:init_load(emqx_slow_subs_schema, ?BASE_CONF), ok = emqx_common_test_helpers:load_config(emqx_slow_subs_schema, ?BASE_CONF),
emqx_common_test_helpers:start_apps([emqx_slow_subs]), emqx_common_test_helpers:start_apps([emqx_slow_subs]),
Config. Config.

View File

@ -57,7 +57,7 @@ init_per_suite(Config) ->
meck:expect(emqx_alarm, activate, 3, ok), meck:expect(emqx_alarm, activate, 3, ok),
meck:expect(emqx_alarm, deactivate, 3, ok), meck:expect(emqx_alarm, deactivate, 3, ok),
ok = emqx_config:init_load(emqx_slow_subs_schema, ?CONF_DEFAULT), ok = emqx_common_test_helpers:load_config(emqx_slow_subs_schema, ?CONF_DEFAULT),
emqx_mgmt_api_test_util:init_suite([emqx_slow_subs]), emqx_mgmt_api_test_util:init_suite([emqx_slow_subs]),
{ok, _} = application:ensure_all_started(emqx_authn), {ok, _} = application:ensure_all_started(emqx_authn),
Config. Config.