fix: allow listener not_found before restart

This commit is contained in:
Zaiming (Stone) Shi 2021-12-12 19:54:13 +01:00
parent 38ac10d3e2
commit d3d8b3a01f
8 changed files with 13 additions and 17 deletions

View File

@ -175,9 +175,10 @@ restart_listener(Type, ListenerName, Conf) ->
restart_listener(Type, ListenerName, Conf, Conf).
restart_listener(Type, ListenerName, OldConf, NewConf) ->
case stop_listener(Type, ListenerName, OldConf) of
case do_stop_listener(Type, ListenerName, OldConf) of
ok -> start_listener(Type, ListenerName, NewConf);
Error -> Error
{error, not_found} -> start_listener(Type, ListenerName, NewConf);
{error, Reason} -> {error, Reason}
end.
%% @doc Stop all listeners.

View File

@ -120,6 +120,7 @@ all(Suite) ->
string:substr(atom_to_list(F), 1, 2) == "t_"
]).
%% set emqx app boot modules
-spec(boot_modules(all|list(atom())) -> ok).
boot_modules(Mods) ->
application:set_env(emqx, boot_modules, Mods).
@ -162,8 +163,7 @@ app_schema(App) ->
mustache_vars(App) ->
[{platform_data_dir, app_path(App, "data")},
{platform_etc_dir, app_path(App, "etc")},
{platform_log_dir, app_path(App, "log")},
{platform_plugins_dir, app_path(App, "plugins")}
{platform_log_dir, app_path(App, "log")}
].
start_app(App, Schema, ConfigFile, SpecAppConfig) ->

View File

@ -132,8 +132,7 @@ render_config_file() ->
mustache_vars() ->
[{platform_data_dir, local_path(["data"])},
{platform_etc_dir, local_path(["etc"])},
{platform_log_dir, local_path(["log"])},
{platform_plugins_dir, local_path(["plugins"])}
{platform_log_dir, local_path(["log"])}
].
generate_config() ->
@ -144,10 +143,6 @@ generate_config() ->
set_app_env({App, Lists}) ->
lists:foreach(fun({authz_file, _Var}) ->
application:set_env(App, authz_file, local_path(["etc", "authz.conf"]));
({plugins_loaded_file, _Var}) ->
application:set_env(App,
plugins_loaded_file,
local_path(["test", "emqx_SUITE_data","loaded_plugins"]));
({Par, Var}) ->
application:set_env(App, Par, Var)
end, Lists).

View File

@ -160,9 +160,6 @@ init_per_group(gc_tests, Config) ->
init_per_suite(Config) ->
Config.
set_special_confs(emqx) ->
Path = emqx_common_test_helpers:deps_path(emqx, "test/emqx_SUITE_data/loaded_plugins"),
application:set_env(emqx, plugins_loaded_file, Path);
set_special_confs(_) ->
ok.

View File

@ -3,5 +3,5 @@ plugins {
}
external {
}
install_dir = "plugins"
install_dir = "{{ platform_plugins_dir }}"
}

View File

@ -47,7 +47,9 @@ init_per_suite(Config) ->
Config.
end_per_suite(_Config) ->
emqx_common_test_helpers:stop_apps([]).
emqx_common_test_helpers:boot_modules(all),
emqx_common_test_helpers:stop_apps([]),
emqx_config:erase(plugins).
t_load(_) ->
?assertEqual(ok, emqx_plugins:load()),
@ -57,7 +59,7 @@ t_load(_) ->
?assertEqual({error, not_started}, emqx_plugins:unload(emqx_mini_plugin)),
?assertEqual({error, not_started}, emqx_plugins:unload(emqx_hocon_plugin)),
emqx_config:put([plugins, install_dir], undefined).
emqx_config:erase(plugins).
t_load_ext_plugin(_) ->
?assertError({plugin_app_file_not_found, _},

View File

@ -55,6 +55,7 @@ init_per_suite(Config) ->
end_per_suite(_Config) ->
emqx_common_test_helpers:stop_apps([emqx_retainer]).
%%--------------------------------------------------------------------
%% Test Cases
%%--------------------------------------------------------------------

View File

@ -257,7 +257,7 @@ overlay_vars_pkg(pkg) ->
, {platform_etc_dir, "/etc/emqx"}
, {platform_lib_dir, ""}
, {platform_log_dir, "/var/log/emqx"}
, {platform_plugins_dir, "/var/lib/enqx/plugins"}
, {platform_plugins_dir, "/var/lib/emqx/plugins"}
, {runner_root_dir, "/usr/lib/emqx"}
, {runner_bin_dir, "/usr/bin"}
, {runner_etc_dir, "/etc/emqx"}