diff --git a/apps/emqx/src/emqx_listeners.erl b/apps/emqx/src/emqx_listeners.erl index 2af2673d1..55c7d2715 100644 --- a/apps/emqx/src/emqx_listeners.erl +++ b/apps/emqx/src/emqx_listeners.erl @@ -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. diff --git a/apps/emqx/test/emqx_common_test_helpers.erl b/apps/emqx/test/emqx_common_test_helpers.erl index a5d80bab5..c4336b855 100644 --- a/apps/emqx/test/emqx_common_test_helpers.erl +++ b/apps/emqx/test/emqx_common_test_helpers.erl @@ -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) -> diff --git a/apps/emqx/test/emqx_listeners_SUITE.erl b/apps/emqx/test/emqx_listeners_SUITE.erl index a9ee0d7d9..7411ca1fd 100644 --- a/apps/emqx/test/emqx_listeners_SUITE.erl +++ b/apps/emqx/test/emqx_listeners_SUITE.erl @@ -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). diff --git a/apps/emqx/test/emqx_persistent_session_SUITE.erl b/apps/emqx/test/emqx_persistent_session_SUITE.erl index 0fa73ebe2..cf7579ba4 100644 --- a/apps/emqx/test/emqx_persistent_session_SUITE.erl +++ b/apps/emqx/test/emqx_persistent_session_SUITE.erl @@ -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. diff --git a/apps/emqx_plugins/etc/emqx_plugins.conf b/apps/emqx_plugins/etc/emqx_plugins.conf index 35f02a9f8..0a1dfb72d 100644 --- a/apps/emqx_plugins/etc/emqx_plugins.conf +++ b/apps/emqx_plugins/etc/emqx_plugins.conf @@ -3,5 +3,5 @@ plugins { } external { } - install_dir = "plugins" + install_dir = "{{ platform_plugins_dir }}" } diff --git a/apps/emqx_plugins/test/emqx_plugins_SUITE.erl b/apps/emqx_plugins/test/emqx_plugins_SUITE.erl index 2281f09dc..013544e32 100644 --- a/apps/emqx_plugins/test/emqx_plugins_SUITE.erl +++ b/apps/emqx_plugins/test/emqx_plugins_SUITE.erl @@ -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, _}, diff --git a/apps/emqx_retainer/test/emqx_retainer_SUITE.erl b/apps/emqx_retainer/test/emqx_retainer_SUITE.erl index 5596e9539..7191bacc0 100644 --- a/apps/emqx_retainer/test/emqx_retainer_SUITE.erl +++ b/apps/emqx_retainer/test/emqx_retainer_SUITE.erl @@ -55,6 +55,7 @@ init_per_suite(Config) -> end_per_suite(_Config) -> emqx_common_test_helpers:stop_apps([emqx_retainer]). + %%-------------------------------------------------------------------- %% Test Cases %%-------------------------------------------------------------------- diff --git a/rebar.config.erl b/rebar.config.erl index f63fedd84..5187379b1 100644 --- a/rebar.config.erl +++ b/rebar.config.erl @@ -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"}