Skip to content

Split federation plugin #13921

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 9 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion .github/workflows/test-make-tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,8 @@ jobs:
- rabbitmq_cli
- rabbitmq_consistent_hash_exchange
- rabbitmq_event_exchange
- rabbitmq_federation
- rabbitmq_exchange_federation
- rabbitmq_federation_common
- rabbitmq_federation_management
- rabbitmq_federation_prometheus
- rabbitmq_jms_topic_exchange
Expand All @@ -98,6 +99,7 @@ jobs:
- rabbitmq_peer_discovery_k8s
- rabbitmq_prelaunch
- rabbitmq_prometheus
- rabbitmq_queue_federation
- rabbitmq_recent_history_exchange
- rabbitmq_sharding
- rabbitmq_shovel
Expand Down
4 changes: 3 additions & 1 deletion .github/workflows/test-make-type-check.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,8 @@ jobs:
- rabbitmq_aws
- rabbitmq_consistent_hash_exchange
- rabbitmq_event_exchange
- rabbitmq_federation
- rabbitmq_exchange_federation
- rabbitmq_federation_common
- rabbitmq_federation_management
- rabbitmq_federation_prometheus
- rabbitmq_jms_topic_exchange
Expand All @@ -50,6 +51,7 @@ jobs:
- rabbitmq_peer_discovery_k8s
- rabbitmq_prelaunch
- rabbitmq_prometheus
- rabbitmq_queue_federation
- rabbitmq_recent_history_exchange
- rabbitmq_sharding
- rabbitmq_shovel
Expand Down
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,9 @@ elvis
!/deps/rabbitmq_ct_helpers/
!/deps/rabbitmq_ct_client_helpers/
!/deps/rabbitmq_event_exchange/
!/deps/rabbitmq_exchange_federation/
!/deps/rabbitmq_federation/
!/deps/rabbitmq_federation_common/
!/deps/rabbitmq_federation_management/
!/deps/rabbitmq_federation_prometheus/
!/deps/rabbitmq_jms_topic_exchange/
Expand All @@ -62,6 +64,7 @@ elvis
!/deps/rabbitmq_peer_discovery_k8s/
!/deps/rabbitmq_prelaunch/
!/deps/rabbitmq_prometheus/
!/deps/rabbitmq_queue_federation/
!/deps/rabbitmq_random_exchange/
!/deps/rabbitmq_recent_history_exchange/
!/deps/rabbitmq_sharding/
Expand Down
2 changes: 1 addition & 1 deletion deps/rabbitmq_cli/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ $(LINKED_ESCRIPTS): $(ESCRIPT_FILE)
tests:: escript test-deps
$(verbose) $(MAKE) -C ../../ install-cli
$(verbose) $(MAKE) -C ../../ start-background-broker \
PLUGINS="rabbitmq_federation rabbitmq_stomp rabbitmq_stream_management amqp_client" \
PLUGINS="rabbitmq_federation_common rabbitmq_stomp rabbitmq_stream_management amqp_client" \
$(if $(filter khepri,$(RABBITMQ_METADATA_STORE)),,RABBITMQ_FEATURE_FLAGS="-khepri_db")
$(gen_verbose) $(MIX_TEST) \
$(if $(RABBITMQ_METADATA_STORE),--exclude $(filter-out $(RABBITMQ_METADATA_STORE),khepri mnesia),) \
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ defmodule ListParametersCommandTest do
rabbitmq_home: rabbitmq_home
}

set_enabled_plugins([:rabbitmq_stomp, :rabbitmq_federation], :online, node, opts)
set_enabled_plugins([:rabbitmq_stomp, :rabbitmq_federation_common], :online, node, opts)

add_vhost(@vhost)

Expand Down
42 changes: 21 additions & 21 deletions deps/rabbitmq_cli/test/plugins/disable_plugins_command_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ defmodule DisablePluginsCommandTest do

setup context do
set_enabled_plugins(
[:rabbitmq_stomp, :rabbitmq_federation],
[:rabbitmq_stomp, :rabbitmq_federation_common],
:online,
get_rabbit_hostname(),
context[:opts]
Expand Down Expand Up @@ -105,14 +105,14 @@ defmodule DisablePluginsCommandTest do
@command.run(["rabbitmq_stomp"], Map.merge(context[:opts], %{node: :nonode}))

assert [
[:rabbitmq_federation],
%{mode: :offline, disabled: [:rabbitmq_stomp], set: [:rabbitmq_federation]}
[:rabbitmq_federation_common],
%{mode: :offline, disabled: [:rabbitmq_stomp], set: [:rabbitmq_federation_common]}
] ==
Enum.to_list(test_stream)

assert {:ok, [[:rabbitmq_federation]]} == :file.consult(context[:opts][:enabled_plugins_file])
assert {:ok, [[:rabbitmq_federation_common]]} == :file.consult(context[:opts][:enabled_plugins_file])

assert [:amqp_client, :rabbitmq_federation, :rabbitmq_stomp] ==
assert [:amqp_client, :rabbitmq_federation_common, :rabbitmq_stomp] ==
Enum.sort(:rabbit_misc.rpc_call(context[:opts][:node], :rabbit_plugins, :active, []))
end

Expand All @@ -125,27 +125,27 @@ defmodule DisablePluginsCommandTest do
)

assert [
[:rabbitmq_federation],
%{mode: :offline, disabled: [:rabbitmq_stomp], set: [:rabbitmq_federation]}
[:rabbitmq_federation_common],
%{mode: :offline, disabled: [:rabbitmq_stomp], set: [:rabbitmq_federation_common]}
] == Enum.to_list(test_stream)

assert {:ok, [[:rabbitmq_federation]]} == :file.consult(context[:opts][:enabled_plugins_file])
assert {:ok, [[:rabbitmq_federation_common]]} == :file.consult(context[:opts][:enabled_plugins_file])

assert [:amqp_client, :rabbitmq_federation, :rabbitmq_stomp] ==
assert [:amqp_client, :rabbitmq_federation_common, :rabbitmq_stomp] ==
Enum.sort(:rabbit_misc.rpc_call(context[:opts][:node], :rabbit_plugins, :active, []))
end

test "in offline mode, removes implicitly enabled plugins when the last explicitly enabled one is removed",
context do
assert {:stream, test_stream0} =
@command.run(
["rabbitmq_federation"],
["rabbitmq_federation_common"],
Map.merge(context[:opts], %{offline: true, online: false})
)

assert [
[:rabbitmq_stomp],
%{mode: :offline, disabled: [:rabbitmq_federation], set: [:rabbitmq_stomp]}
%{mode: :offline, disabled: [:rabbitmq_federation_common], set: [:rabbitmq_stomp]}
] == Enum.to_list(test_stream0)

assert {:ok, [[:rabbitmq_stomp]]} == :file.consult(context[:opts][:enabled_plugins_file])
Expand All @@ -166,31 +166,31 @@ defmodule DisablePluginsCommandTest do
assert {:stream, test_stream0} = @command.run(["rabbitmq_stomp"], context[:opts])

assert [
[:rabbitmq_federation],
[:rabbitmq_federation_common],
%{
mode: :online,
started: [],
stopped: [:rabbitmq_stomp],
disabled: [:rabbitmq_stomp],
set: [:rabbitmq_federation]
set: [:rabbitmq_federation_common]
}
] ==
Enum.to_list(test_stream0)

assert {:ok, [[:rabbitmq_federation]]} == :file.consult(context[:opts][:enabled_plugins_file])
assert {:ok, [[:rabbitmq_federation_common]]} == :file.consult(context[:opts][:enabled_plugins_file])

assert [:amqp_client, :rabbitmq_federation] ==
assert [:amqp_client, :rabbitmq_federation_common] ==
Enum.sort(:rabbit_misc.rpc_call(context[:opts][:node], :rabbit_plugins, :active, []))

assert {:stream, test_stream1} = @command.run(["rabbitmq_federation"], context[:opts])
assert {:stream, test_stream1} = @command.run(["rabbitmq_federation_common"], context[:opts])

assert [
[],
%{
mode: :online,
started: [],
stopped: [:rabbitmq_federation],
disabled: [:rabbitmq_federation],
stopped: [:rabbitmq_federation_common],
disabled: [:rabbitmq_federation_common],
set: []
}
] ==
Expand All @@ -205,7 +205,7 @@ defmodule DisablePluginsCommandTest do

test "can disable multiple plugins at once", context do
assert {:stream, test_stream} =
@command.run(["rabbitmq_stomp", "rabbitmq_federation"], context[:opts])
@command.run(["rabbitmq_stomp", "rabbitmq_federation_common"], context[:opts])

[[], m0] = Enum.to_list(test_stream)

Expand All @@ -214,7 +214,7 @@ defmodule DisablePluginsCommandTest do
|> Map.update!(:stopped, &Enum.sort/1)
|> Map.update!(:disabled, &Enum.sort/1)

expected_list = Enum.sort([:rabbitmq_federation, :rabbitmq_stomp])
expected_list = Enum.sort([:rabbitmq_federation_common, :rabbitmq_stomp])

assert [
[],
Expand Down Expand Up @@ -243,7 +243,7 @@ defmodule DisablePluginsCommandTest do
|> Map.update!(:stopped, &Enum.sort/1)
|> Map.update!(:disabled, &Enum.sort/1)

expected_list = Enum.sort([:rabbitmq_federation, :rabbitmq_stomp])
expected_list = Enum.sort([:rabbitmq_federation_common, :rabbitmq_stomp])

assert [
[],
Expand Down
54 changes: 27 additions & 27 deletions deps/rabbitmq_cli/test/plugins/enable_plugins_command_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ defmodule EnablePluginsCommandTest do

def reset_enabled_plugins_to_preconfigured_defaults(context) do
set_enabled_plugins(
[:rabbitmq_stomp, :rabbitmq_federation],
[:rabbitmq_stomp, :rabbitmq_federation_common],
:online,
get_rabbit_hostname(),
context[:opts]
Expand Down Expand Up @@ -120,7 +120,7 @@ defmodule EnablePluginsCommandTest do

check_plugins_enabled([:rabbitmq_stomp], context)

assert [:amqp_client, :rabbitmq_federation, :rabbitmq_stomp] ==
assert [:amqp_client, :rabbitmq_federation_common, :rabbitmq_stomp] ==
currently_active_plugins(context)
end

Expand All @@ -144,7 +144,7 @@ defmodule EnablePluginsCommandTest do
check_plugins_enabled([:rabbitmq_stomp], context)

assert_equal_sets(
[:amqp_client, :rabbitmq_federation, :rabbitmq_stomp],
[:amqp_client, :rabbitmq_federation_common, :rabbitmq_stomp],
currently_active_plugins(context)
)
end
Expand All @@ -169,21 +169,21 @@ defmodule EnablePluginsCommandTest do

assert {:stream, test_stream1} =
@command.run(
["rabbitmq_federation"],
["rabbitmq_federation_common"],
Map.merge(context[:opts], %{offline: true, online: false})
)

assert [
[:rabbitmq_federation, :rabbitmq_stomp],
[:rabbitmq_federation_common, :rabbitmq_stomp],
%{
mode: :offline,
enabled: [:rabbitmq_federation],
set: [:rabbitmq_federation, :rabbitmq_stomp]
enabled: [:rabbitmq_federation_common],
set: [:rabbitmq_federation_common, :rabbitmq_stomp]
}
] ==
Enum.to_list(test_stream1)

check_plugins_enabled([:rabbitmq_stomp, :rabbitmq_federation], context)
check_plugins_enabled([:rabbitmq_stomp, :rabbitmq_federation_common], context)
end

test "run: updates plugin list and starts newly enabled plugins", context do
Expand All @@ -207,24 +207,24 @@ defmodule EnablePluginsCommandTest do
check_plugins_enabled([:rabbitmq_stomp], context)
assert_equal_sets([:amqp_client, :rabbitmq_stomp], currently_active_plugins(context))

{:stream, test_stream1} = @command.run(["rabbitmq_federation"], context[:opts])
{:stream, test_stream1} = @command.run(["rabbitmq_federation_common"], context[:opts])

assert [
[:rabbitmq_federation, :rabbitmq_stomp],
[:rabbitmq_federation_common, :rabbitmq_stomp],
%{
mode: :online,
started: [:rabbitmq_federation],
started: [:rabbitmq_federation_common],
stopped: [],
enabled: [:rabbitmq_federation],
set: [:rabbitmq_federation, :rabbitmq_stomp]
enabled: [:rabbitmq_federation_common],
set: [:rabbitmq_federation_common, :rabbitmq_stomp]
}
] ==
Enum.to_list(test_stream1)

check_plugins_enabled([:rabbitmq_stomp, :rabbitmq_federation], context)
check_plugins_enabled([:rabbitmq_stomp, :rabbitmq_federation_common], context)

assert_equal_sets(
[:amqp_client, :rabbitmq_federation, :rabbitmq_stomp],
[:amqp_client, :rabbitmq_federation_common, :rabbitmq_stomp],
currently_active_plugins(context)
)

Expand All @@ -236,24 +236,24 @@ defmodule EnablePluginsCommandTest do
set_enabled_plugins([], :online, context[:opts][:node], context[:opts])

assert {:stream, test_stream} =
@command.run(["rabbitmq_stomp", "rabbitmq_federation"], context[:opts])
@command.run(["rabbitmq_stomp", "rabbitmq_federation_common"], context[:opts])

assert [
[:rabbitmq_federation, :rabbitmq_stomp],
[:rabbitmq_federation_common, :rabbitmq_stomp],
%{
mode: :online,
started: [:rabbitmq_federation, :rabbitmq_stomp],
started: [:rabbitmq_federation_common, :rabbitmq_stomp],
stopped: [],
enabled: [:rabbitmq_federation, :rabbitmq_stomp],
set: [:rabbitmq_federation, :rabbitmq_stomp]
enabled: [:rabbitmq_federation_common, :rabbitmq_stomp],
set: [:rabbitmq_federation_common, :rabbitmq_stomp]
}
] ==
Enum.to_list(test_stream)

check_plugins_enabled([:rabbitmq_stomp, :rabbitmq_federation], context)
check_plugins_enabled([:rabbitmq_stomp, :rabbitmq_federation_common], context)

assert_equal_sets(
[:amqp_client, :rabbitmq_federation, :rabbitmq_stomp],
[:amqp_client, :rabbitmq_federation_common, :rabbitmq_stomp],
currently_active_plugins(context)
)

Expand All @@ -262,18 +262,18 @@ defmodule EnablePluginsCommandTest do

test "run: does not enable an already implicitly enabled plugin", context do
# Clears enabled plugins file and stop all plugins
set_enabled_plugins([:rabbitmq_federation], :online, context[:opts][:node], context[:opts])
set_enabled_plugins([:rabbitmq_federation_common], :online, context[:opts][:node], context[:opts])
assert {:stream, test_stream} = @command.run(["amqp_client"], context[:opts])

assert [
[:rabbitmq_federation],
%{mode: :online, started: [], stopped: [], enabled: [], set: [:rabbitmq_federation]}
[:rabbitmq_federation_common],
%{mode: :online, started: [], stopped: [], enabled: [], set: [:rabbitmq_federation_common]}
] ==
Enum.to_list(test_stream)

check_plugins_enabled([:rabbitmq_federation], context)
check_plugins_enabled([:rabbitmq_federation_common], context)

assert [:amqp_client, :rabbitmq_federation] ==
assert [:amqp_client, :rabbitmq_federation_common] ==
currently_active_plugins(context)

reset_enabled_plugins_to_preconfigured_defaults(context)
Expand Down
2 changes: 1 addition & 1 deletion deps/rabbitmq_cli/test/plugins/is_enabled_command_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ defmodule PluginIsEnabledCommandTest do

assert match?(
{:ok, _},
assert(@command.run(["rabbitmq_stomp", "rabbitmq_federation"], opts))
assert(@command.run(["rabbitmq_stomp", "rabbitmq_federation_common"], opts))
)
end

Expand Down
Loading
Loading