summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorArnaud Cogoluègnes <acogoluegnes@gmail.com>2016-12-22 17:09:20 +0100
committerArnaud Cogoluègnes <acogoluegnes@gmail.com>2016-12-22 17:09:20 +0100
commitdc89936ce4b74d322601972abc9b195ee7535a90 (patch)
tree10c1fcbe0e93fc66ea077cd0346c99696def66ca
parent0706cf06b09c5c55762ab67ee4c11b28fcf6ee85 (diff)
parentd616cc922dbd73eca7700c50f09e33e6b578b0d9 (diff)
downloadrabbitmq-server-git-dc89936ce4b74d322601972abc9b195ee7535a90.tar.gz
Merge branch 'master' into rabbitmq-server-505
-rw-r--r--Makefile4
-rw-r--r--src/rabbit_plugins.erl36
-rw-r--r--test/plugins_SUITE.erl80
-rw-r--r--test/plugins_SUITE_data/plugins1/mock_rabbitmq_plugins_01-0.1.0.ezbin0 -> 3280 bytes
4 files changed, 109 insertions, 11 deletions
diff --git a/Makefile b/Makefile
index 3c11b54020..f87a09ec7a 100644
--- a/Makefile
+++ b/Makefile
@@ -116,9 +116,7 @@ define PROJECT_ENV
]
endef
-# FIXME: Remove goldrush, once rabbit_plugins.erl knows how to ignore
-# indirect dependencies of rabbit.
-LOCAL_DEPS = sasl mnesia os_mon xmerl goldrush jsx
+LOCAL_DEPS = sasl mnesia os_mon
BUILD_DEPS = rabbitmq_cli
DEPS = ranch lager rabbit_common
TEST_DEPS = rabbitmq_ct_helpers rabbitmq_ct_client_helpers amqp_client meck proper
diff --git a/src/rabbit_plugins.erl b/src/rabbit_plugins.erl
index 40dbf91cfd..9da68b7640 100644
--- a/src/rabbit_plugins.erl
+++ b/src/rabbit_plugins.erl
@@ -140,9 +140,14 @@ active() ->
lists:member(App, LoadedPluginNames)].
loaded_plugin_names() ->
- {ok, PluginsDir} = application:get_env(rabbit, plugins_dir),
- PluginsDirComponents = filename:split(PluginsDir),
- loaded_plugin_names(code:get_path(), PluginsDirComponents, []).
+ {ok, PluginsPath} = application:get_env(rabbit, plugins_dir),
+ PluginsDirs = split_path(PluginsPath),
+ lists:flatmap(
+ fun(PluginsDir) ->
+ PluginsDirComponents = filename:split(PluginsDir),
+ loaded_plugin_names(code:get_path(), PluginsDirComponents, [])
+ end,
+ PluginsDirs).
loaded_plugin_names([Path | OtherPaths], PluginsDirComponents, PluginNames) ->
case lists:sublist(filename:split(Path), length(PluginsDirComponents)) of
@@ -608,11 +613,7 @@ remove_duplicate_plugins([Plugin|Rest], {Plugins0, Problems0}) ->
maybe_keep_required_deps(true, Plugins) ->
Plugins;
maybe_keep_required_deps(false, Plugins) ->
- %% We load the "rabbit" application to be sure we can get the
- %% "applications" key. This is required for rabbitmq-plugins for
- %% instance.
- application:load(rabbit),
- {ok, RabbitDeps} = application:get_key(rabbit, applications),
+ RabbitDeps = list_all_deps([rabbit]),
lists:filter(fun
(#plugin{name = Name}) ->
not lists:member(Name, RabbitDeps);
@@ -621,6 +622,25 @@ maybe_keep_required_deps(false, Plugins) ->
end,
Plugins).
+list_all_deps(Applications) ->
+ list_all_deps(Applications, []).
+
+list_all_deps([Application | Applications], Deps) ->
+ %% We load the application to be sure we can get the "applications" key.
+ %% This is required for rabbitmq-plugins for instance.
+ application:load(Application),
+ NewDeps = [Application | Deps],
+ case application:get_key(Application, applications) of
+ {ok, ApplicationDeps} ->
+ RemainingApplications0 = ApplicationDeps ++ Applications,
+ RemainingApplications = RemainingApplications0 -- NewDeps,
+ list_all_deps(RemainingApplications, NewDeps);
+ undefined ->
+ list_all_deps(Applications, NewDeps)
+ end;
+list_all_deps([], Deps) ->
+ Deps.
+
remove_otp_overrideable_plugins(Plugins) ->
lists:filter(fun(P) -> not plugin_provided_by_otp(P) end,
Plugins).
diff --git a/test/plugins_SUITE.erl b/test/plugins_SUITE.erl
new file mode 100644
index 0000000000..8896298df1
--- /dev/null
+++ b/test/plugins_SUITE.erl
@@ -0,0 +1,80 @@
+%% The contents of this file are subject to the Mozilla Public License
+%% Version 1.1 (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.mozilla.org/MPL/
+%%
+%% Software distributed under the License is distributed on an "AS IS"
+%% basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
+%% License for the specific language governing rights and limitations
+%% under the License.
+%%
+%% The Original Code is RabbitMQ.
+%%
+%% The Initial Developer of the Original Code is GoPivotal, Inc.
+%% Copyright (c) 2016 Pivotal Software, Inc. All rights reserved.
+%%
+
+-module(plugins_SUITE).
+
+-include_lib("common_test/include/ct.hrl").
+
+-compile(export_all).
+
+all() ->
+ [
+ active_with_single_plugin_dir,
+ active_with_multiple_plugin_dirs
+ ].
+
+%% -------------------------------------------------------------------
+%% Testsuite setup/teardown.
+%% -------------------------------------------------------------------
+
+init_per_suite(Config) ->
+ rabbit_ct_helpers:log_environment(),
+ application:load(rabbit),
+ rabbit_ct_helpers:run_setup_steps(Config).
+
+end_per_suite(Config) ->
+ rabbit_ct_helpers:run_teardown_steps(Config).
+
+init_per_group(_, Config) ->
+ Config.
+
+end_per_group(_, Config) ->
+ Config.
+
+init_per_testcase(Testcase, Config) ->
+ rabbit_ct_helpers:testcase_started(Config, Testcase).
+
+end_per_testcase(Testcase, Config) ->
+ rabbit_ct_helpers:testcase_finished(Config, Testcase).
+
+%% -------------------------------------------------------------------
+%% Testcases.
+%% -------------------------------------------------------------------
+
+active_with_single_plugin_dir(Config) ->
+ DataDir = rabbit_ct_helpers:get_config(Config, data_dir),
+ PluginsDir1 = filename:join(DataDir, "plugins1"),
+
+ true = code:add_path(filename:join([PluginsDir1,
+ "mock_rabbitmq_plugins_01-0.1.0.ez",
+ "mock_rabbitmq_plugins_01-0.1.0", "ebin"])),
+ {ok, _} = application:ensure_all_started(mock_rabbitmq_plugins_01),
+ application:set_env(rabbit, plugins_dir, PluginsDir1),
+
+ [mock_rabbitmq_plugins_01] = rabbit_plugins:active().
+
+active_with_multiple_plugin_dirs(Config) ->
+ DataDir = rabbit_ct_helpers:get_config(Config, data_dir),
+ PluginsDir1 = filename:join(DataDir, "plugins1"),
+ PluginsDir2 = filename:join(DataDir, "plugins2"),
+
+ true = code:add_path(filename:join([PluginsDir1,
+ "mock_rabbitmq_plugins_01-0.1.0.ez",
+ "mock_rabbitmq_plugins_01-0.1.0", "ebin"])),
+ {ok, _} = application:ensure_all_started(mock_rabbitmq_plugins_01),
+ application:set_env(rabbit, plugins_dir, PluginsDir1 ++ ":" ++ PluginsDir2),
+
+ [mock_rabbitmq_plugins_01] = rabbit_plugins:active().
diff --git a/test/plugins_SUITE_data/plugins1/mock_rabbitmq_plugins_01-0.1.0.ez b/test/plugins_SUITE_data/plugins1/mock_rabbitmq_plugins_01-0.1.0.ez
new file mode 100644
index 0000000000..40cba9f16b
--- /dev/null
+++ b/test/plugins_SUITE_data/plugins1/mock_rabbitmq_plugins_01-0.1.0.ez
Binary files differ