Merge pull request #8694 from zhongwencool/fix-bad-default-plugins
fix: bad default plugins
This commit is contained in:
commit
b88d4a61b1
|
@ -31,11 +31,12 @@ all() -> emqx_ct:all(?MODULE).
|
||||||
%%--------------------------------------------------------------------
|
%%--------------------------------------------------------------------
|
||||||
|
|
||||||
init_per_suite(Config) ->
|
init_per_suite(Config) ->
|
||||||
emqx_ct_helpers:start_apps([emqx_retainer]),
|
emqx_retainer_ct_helper:ensure_start(),
|
||||||
Config.
|
Config.
|
||||||
|
|
||||||
end_per_suite(_Config) ->
|
end_per_suite(_Config) ->
|
||||||
emqx_ct_helpers:stop_apps([emqx_retainer]).
|
emqx_retainer_ct_helper:ensure_stop(),
|
||||||
|
ok.
|
||||||
|
|
||||||
init_per_testcase(TestCase, Config) ->
|
init_per_testcase(TestCase, Config) ->
|
||||||
emqx_retainer:clean(<<"#">>),
|
emqx_retainer:clean(<<"#">>),
|
||||||
|
@ -207,4 +208,3 @@ receive_messages(Count, Msgs) ->
|
||||||
after 2000 ->
|
after 2000 ->
|
||||||
Msgs
|
Msgs
|
||||||
end.
|
end.
|
||||||
|
|
||||||
|
|
|
@ -24,11 +24,12 @@
|
||||||
all() -> emqx_ct:all(?MODULE).
|
all() -> emqx_ct:all(?MODULE).
|
||||||
|
|
||||||
init_per_suite(Config) ->
|
init_per_suite(Config) ->
|
||||||
emqx_ct_helpers:start_apps([emqx_retainer]),
|
emqx_retainer_ct_helper:ensure_start(),
|
||||||
Config.
|
Config.
|
||||||
|
|
||||||
end_per_suite(_Config) ->
|
end_per_suite(_Config) ->
|
||||||
emqx_ct_helpers:stop_apps([emqx_retainer]).
|
emqx_retainer_ct_helper:ensure_stop(),
|
||||||
|
ok.
|
||||||
|
|
||||||
init_per_testcase(_TestCase, Config) ->
|
init_per_testcase(_TestCase, Config) ->
|
||||||
Config.
|
Config.
|
||||||
|
|
|
@ -0,0 +1,46 @@
|
||||||
|
%%--------------------------------------------------------------------
|
||||||
|
%% Copyright (c) 2020-2022 EMQ Technologies Co., Ltd. All Rights Reserved.
|
||||||
|
%%
|
||||||
|
%% Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
%% you may not use this file except in compliance with the License.
|
||||||
|
%% You may obtain a copy of the License at
|
||||||
|
%%
|
||||||
|
%% http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
%%
|
||||||
|
%% Unless required by applicable law or agreed to in writing, software
|
||||||
|
%% distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
%% WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
%% See the License for the specific language governing permissions and
|
||||||
|
%% limitations under the License.
|
||||||
|
%%--------------------------------------------------------------------
|
||||||
|
-module(emqx_retainer_ct_helper).
|
||||||
|
|
||||||
|
|
||||||
|
%% API
|
||||||
|
-export([ensure_start/0, ensure_stop/0]).
|
||||||
|
-ifdef(EMQX_ENTERPRISE).
|
||||||
|
ensure_start() ->
|
||||||
|
application:stop(emqx_modules),
|
||||||
|
init_conf(),
|
||||||
|
emqx_ct_helpers:start_apps([emqx_retainer]),
|
||||||
|
ok.
|
||||||
|
|
||||||
|
-else.
|
||||||
|
|
||||||
|
ensure_start() ->
|
||||||
|
init_conf(),
|
||||||
|
emqx_ct_helpers:start_apps([emqx_retainer]),
|
||||||
|
ok.
|
||||||
|
|
||||||
|
-endif.
|
||||||
|
|
||||||
|
ensure_stop() ->
|
||||||
|
emqx_ct_helpers:stop_apps([emqx_retainer]).
|
||||||
|
|
||||||
|
|
||||||
|
init_conf() ->
|
||||||
|
application:set_env(emqx_retainer, expiry_interval, 0),
|
||||||
|
application:set_env(emqx_retainer, max_payload_size, 1024000),
|
||||||
|
application:set_env(emqx_retainer, max_retained_messages, 0),
|
||||||
|
application:set_env(emqx_retainer, storage_type, ram),
|
||||||
|
ok.
|
|
@ -27,12 +27,13 @@ init_per_suite(Config) ->
|
||||||
%% Meck emqtt
|
%% Meck emqtt
|
||||||
ok = meck:new(emqtt, [non_strict, passthrough, no_history, no_link]),
|
ok = meck:new(emqtt, [non_strict, passthrough, no_history, no_link]),
|
||||||
%% Start Apps
|
%% Start Apps
|
||||||
emqx_ct_helpers:start_apps([emqx_retainer]),
|
emqx_retainer_ct_helper:ensure_start(),
|
||||||
Config.
|
Config.
|
||||||
|
|
||||||
end_per_suite(_Config) ->
|
end_per_suite(_Config) ->
|
||||||
ok = meck:unload(emqtt),
|
ok = meck:unload(emqtt),
|
||||||
emqx_ct_helpers:stop_apps([emqx_retainer]).
|
emqx_retainer_ct_helper:ensure_stop().
|
||||||
|
|
||||||
|
|
||||||
%%--------------------------------------------------------------------
|
%%--------------------------------------------------------------------
|
||||||
%% Helpers
|
%% Helpers
|
||||||
|
|
|
@ -217,22 +217,50 @@ load_plugin_conf(AppName, PluginDir) ->
|
||||||
ensure_file(File) ->
|
ensure_file(File) ->
|
||||||
case filelib:is_file(File) of
|
case filelib:is_file(File) of
|
||||||
false ->
|
false ->
|
||||||
DefaultPlugins = [ {emqx_management, true}
|
DefaultPlugins = default_plugins(),
|
||||||
, {emqx_dashboard, true}
|
|
||||||
, {emqx_modules, true}
|
|
||||||
, {emqx_recon, true}
|
|
||||||
, {emqx_retainer, true}
|
|
||||||
, {emqx_telemetry, true}
|
|
||||||
, {emqx_rule_engine, true}
|
|
||||||
, {emqx_bridge_mqtt, false}
|
|
||||||
, {emqx_eviction_agent, true}
|
|
||||||
, {emqx_node_rebalance, true}
|
|
||||||
],
|
|
||||||
write_loaded(DefaultPlugins);
|
write_loaded(DefaultPlugins);
|
||||||
true ->
|
true ->
|
||||||
ok
|
ok
|
||||||
end.
|
end.
|
||||||
|
|
||||||
|
-ifndef(EMQX_ENTERPRISE).
|
||||||
|
%% default plugins see rebar.config.erl
|
||||||
|
default_plugins() ->
|
||||||
|
[
|
||||||
|
{emqx_management, true},
|
||||||
|
{emqx_dashboard, true},
|
||||||
|
%% emqx_modules is not a plugin, but a normal application starting when boots.
|
||||||
|
{emqx_modules, false},
|
||||||
|
{emqx_retainer, true},
|
||||||
|
{emqx_recon, true},
|
||||||
|
{emqx_telemetry, true},
|
||||||
|
{emqx_rule_engine, true},
|
||||||
|
{emqx_bridge_mqtt, false},
|
||||||
|
{emqx_eviction_agent, true},
|
||||||
|
{emqx_node_rebalance, true}
|
||||||
|
].
|
||||||
|
|
||||||
|
-else.
|
||||||
|
|
||||||
|
default_plugins() ->
|
||||||
|
[
|
||||||
|
{emqx_management, true},
|
||||||
|
{emqx_dashboard, true},
|
||||||
|
%% enterprise version of emqx_modules is a plugin
|
||||||
|
{emqx_modules, true},
|
||||||
|
%% retainer is managed by emqx_modules.
|
||||||
|
%% default is true in data/load_modules. **NOT HERE**
|
||||||
|
{emqx_retainer, false},
|
||||||
|
{emqx_recon, true},
|
||||||
|
{emqx_telemetry, true},
|
||||||
|
{emqx_rule_engine, true},
|
||||||
|
{emqx_bridge_mqtt, false},
|
||||||
|
{emqx_eviction_agent, true},
|
||||||
|
{emqx_node_rebalance, true}
|
||||||
|
].
|
||||||
|
|
||||||
|
-endif.
|
||||||
|
|
||||||
with_loaded_file(File, SuccFun) ->
|
with_loaded_file(File, SuccFun) ->
|
||||||
case read_loaded(File) of
|
case read_loaded(File) of
|
||||||
{ok, Names0} ->
|
{ok, Names0} ->
|
||||||
|
|
|
@ -89,6 +89,38 @@ t_load(_) ->
|
||||||
?assertEqual(ignore, emqx_plugins:load()),
|
?assertEqual(ignore, emqx_plugins:load()),
|
||||||
?assertEqual(ignore, emqx_plugins:unload()).
|
?assertEqual(ignore, emqx_plugins:unload()).
|
||||||
|
|
||||||
|
-ifndef(EMQX_ENTERPRISE).
|
||||||
|
default_plugins() ->
|
||||||
|
[
|
||||||
|
{emqx_bridge_mqtt, false},
|
||||||
|
{emqx_dashboard, true},
|
||||||
|
{emqx_eviction_agent, true},
|
||||||
|
{emqx_management, true},
|
||||||
|
{emqx_modules, false},
|
||||||
|
{emqx_node_rebalance, true},
|
||||||
|
{emqx_recon, true},
|
||||||
|
{emqx_retainer, true},
|
||||||
|
{emqx_rule_engine, true},
|
||||||
|
{emqx_telemetry, true}
|
||||||
|
].
|
||||||
|
|
||||||
|
-else.
|
||||||
|
|
||||||
|
default_plugins() ->
|
||||||
|
[
|
||||||
|
{emqx_bridge_mqtt, false},
|
||||||
|
{emqx_dashboard, true},
|
||||||
|
{emqx_eviction_agent, true},
|
||||||
|
{emqx_management, true},
|
||||||
|
{emqx_modules, true},
|
||||||
|
{emqx_node_rebalance, true},
|
||||||
|
{emqx_recon, true},
|
||||||
|
{emqx_retainer, false},
|
||||||
|
{emqx_rule_engine, true},
|
||||||
|
{emqx_telemetry, true}
|
||||||
|
].
|
||||||
|
|
||||||
|
-endif.
|
||||||
t_ensure_default_loaded_plugins_file(Config) ->
|
t_ensure_default_loaded_plugins_file(Config) ->
|
||||||
%% this will trigger it to write the default plugins to the
|
%% this will trigger it to write the default plugins to the
|
||||||
%% inexistent file; but it won't truly load them in this test
|
%% inexistent file; but it won't truly load them in this test
|
||||||
|
@ -96,19 +128,8 @@ t_ensure_default_loaded_plugins_file(Config) ->
|
||||||
TmpFilepath = ?config(tmp_filepath, Config),
|
TmpFilepath = ?config(tmp_filepath, Config),
|
||||||
ok = emqx_plugins:load(),
|
ok = emqx_plugins:load(),
|
||||||
{ok, Contents} = file:consult(TmpFilepath),
|
{ok, Contents} = file:consult(TmpFilepath),
|
||||||
?assertEqual(
|
DefaultPlugins = default_plugins(),
|
||||||
[ {emqx_bridge_mqtt, false}
|
?assertEqual(DefaultPlugins, lists:sort(Contents)),
|
||||||
, {emqx_dashboard, true}
|
|
||||||
, {emqx_eviction_agent, true}
|
|
||||||
, {emqx_management, true}
|
|
||||||
, {emqx_modules, true}
|
|
||||||
, {emqx_node_rebalance, true}
|
|
||||||
, {emqx_recon, true}
|
|
||||||
, {emqx_retainer, true}
|
|
||||||
, {emqx_rule_engine, true}
|
|
||||||
, {emqx_telemetry, true}
|
|
||||||
],
|
|
||||||
lists:sort(Contents)),
|
|
||||||
ok.
|
ok.
|
||||||
|
|
||||||
t_init_config(_) ->
|
t_init_config(_) ->
|
||||||
|
|
Loading…
Reference in New Issue