summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorJean-Sébastien Pédron <jean-sebastien@rabbitmq.com>2020-04-06 12:58:49 +0200
committerJean-Sébastien Pédron <jean-sebastien@rabbitmq.com>2020-04-06 12:58:49 +0200
commit3b4a7ff2242c576867e63e55c9f73d6f97e9c43d (patch)
treeaca6c62bf894accbc5f17bce76352e26b3518d30 /test
parentee4b615fa84a5969aabcef1f7a2c7cc50a9f73ba (diff)
downloadrabbitmq-server-git-3b4a7ff2242c576867e63e55c9f73d6f97e9c43d.tar.gz
feature_flags_SUITE: Work around CLI/rabbitmq-server circular dependency
We need to copy `rabbit` in `my_plugins` plugins directory, not because `my_plugin` depends on it, but because the CLI erroneously depends on the broker. This can't be fixed easily because this is a circular dependency (i.e. the broker depends on the CLI). So until a proper solution is implemented, keep this second copy of the broker for the CLI to find it.
Diffstat (limited to 'test')
-rw-r--r--test/feature_flags_SUITE.erl43
1 files changed, 39 insertions, 4 deletions
diff --git a/test/feature_flags_SUITE.erl b/test/feature_flags_SUITE.erl
index e3dd3a64db..443be46d3d 100644
--- a/test/feature_flags_SUITE.erl
+++ b/test/feature_flags_SUITE.erl
@@ -125,7 +125,8 @@ init_per_group(clustering, Config) ->
{rmq_nodes_clustered, false},
{start_rmq_with_plugins_disabled, true}]),
rabbit_ct_helpers:run_setup_steps(Config1, [
- fun build_my_plugin/1
+ fun build_my_plugin/1,
+ fun work_around_cli_and_rabbit_circular_dep/1
]);
init_per_group(activating_plugin, Config) ->
Config1 = rabbit_ct_helpers:set_config(
@@ -134,7 +135,8 @@ init_per_group(activating_plugin, Config) ->
{rmq_nodes_clustered, true},
{start_rmq_with_plugins_disabled, true}]),
rabbit_ct_helpers:run_setup_steps(Config1, [
- fun build_my_plugin/1
+ fun build_my_plugin/1,
+ fun work_around_cli_and_rabbit_circular_dep/1
]);
init_per_group(_, Config) ->
Config.
@@ -958,10 +960,43 @@ list_my_plugin_plugins(PluginSrcDir) ->
end, Files).
remove_other_plugins(PluginSrcDir, OtherPlugins) ->
- [ok = file:delete(
- filename:join(PluginSrcDir, Filename))
+ [ok = file:delete(filename:join(PluginSrcDir, Filename))
|| Filename <- OtherPlugins].
+work_around_cli_and_rabbit_circular_dep(Config) ->
+ %% FIXME: We also need to copy `rabbit` in `my_plugins` plugins
+ %% directory, not because `my_plugin` depends on it, but because the
+ %% CLI erroneously depends on the broker.
+ %%
+ %% This can't be fixed easily because this is a circular dependency
+ %% (i.e. the broker depends on the CLI). So until a proper solution
+ %% is implemented, keep this second copy of the broker for the CLI
+ %% to find it.
+ InitialPluginsDir = filename:join(
+ ?config(current_srcdir, Config),
+ "plugins"),
+ PluginsDir = ?config(rmq_plugins_dir, Config),
+ lists:foreach(
+ fun(Path) ->
+ Filename = filename:basename(Path),
+ IsRabbit = re:run(
+ Filename,
+ "^rabbit-", [{capture, none}]) =:= match,
+ case IsRabbit of
+ true ->
+ Dest = filename:join(PluginsDir, Filename),
+ ct:pal(
+ ?LOW_IMPORTANCE,
+ "Copy `~s` to `~s` to fix CLI erroneous "
+ "dependency on `rabbit`", [Path, Dest]),
+ {ok, _} = file:copy(Path, Dest);
+ false ->
+ ok
+ end
+ end,
+ filelib:wildcard(filename:join(InitialPluginsDir, "*"))),
+ Config.
+
enable_feature_flag_on(Config, Node, FeatureName) ->
rabbit_ct_broker_helpers:rpc(
Config, Node, rabbit_feature_flags, enable, [FeatureName]).