Cosmetics, extract fn
This commit is contained in:
		
							parent
							
								
									31c3356c56
								
							
						
					
					
						commit
						830b1d1382
					
				| 
						 | 
					@ -43,7 +43,7 @@ defmodule DisablePluginsCommandTest do
 | 
				
			||||||
             online: true, offline: false}
 | 
					             online: true, offline: false}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    on_exit(fn ->
 | 
					    on_exit(fn ->
 | 
				
			||||||
      set_enabled_plugins(get_rabbit_hostname,enabled_plugins,opts)
 | 
					      set_enabled_plugins(get_rabbit_hostname, enabled_plugins, opts)
 | 
				
			||||||
    end)
 | 
					    end)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    :erlang.disconnect_node(node)
 | 
					    :erlang.disconnect_node(node)
 | 
				
			||||||
| 
						 | 
					@ -112,7 +112,7 @@ defmodule DisablePluginsCommandTest do
 | 
				
			||||||
      @command.validate(["a"], Map.delete(context[:opts], :rabbitmq_home))
 | 
					      @command.validate(["a"], Map.delete(context[:opts], :rabbitmq_home))
 | 
				
			||||||
  end
 | 
					  end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  test "will write enabled plugins file if node is unaccessible and report implicitly enabled list", context do
 | 
					  test "will write out enabled plugins file if node is unaccessible and report implicitly enabled list", context do
 | 
				
			||||||
    assert %{mode: :offline, enabled: [:amqp_client, :rabbitmq_federation]} =
 | 
					    assert %{mode: :offline, enabled: [:amqp_client, :rabbitmq_federation]} =
 | 
				
			||||||
           @command.run(["rabbitmq_metronome"], Map.merge(context[:opts], %{node: :nonode}))
 | 
					           @command.run(["rabbitmq_metronome"], Map.merge(context[:opts], %{node: :nonode}))
 | 
				
			||||||
    assert {:ok, [[:rabbitmq_federation]]} = :file.consult(context[:opts][:enabled_plugins_file])
 | 
					    assert {:ok, [[:rabbitmq_federation]]} = :file.consult(context[:opts][:enabled_plugins_file])
 | 
				
			||||||
| 
						 | 
					@ -120,7 +120,7 @@ defmodule DisablePluginsCommandTest do
 | 
				
			||||||
           Enum.sort(:rabbit_misc.rpc_call(context[:opts][:node], :rabbit_plugins, :active, []))
 | 
					           Enum.sort(:rabbit_misc.rpc_call(context[:opts][:node], :rabbit_plugins, :active, []))
 | 
				
			||||||
  end
 | 
					  end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  test "will write enabled plugins in offline mode and report implicitly enabled list", context do
 | 
					  test "will write out enabled plugins in offline mode and report implicitly enabled list", context do
 | 
				
			||||||
    assert %{mode: :offline, enabled: [:amqp_client, :rabbitmq_federation]} =
 | 
					    assert %{mode: :offline, enabled: [:amqp_client, :rabbitmq_federation]} =
 | 
				
			||||||
           @command.run(["rabbitmq_metronome"], Map.merge(context[:opts], %{offline: true, online: false}))
 | 
					           @command.run(["rabbitmq_metronome"], Map.merge(context[:opts], %{offline: true, online: false}))
 | 
				
			||||||
    assert {:ok, [[:rabbitmq_federation]]} = :file.consult(context[:opts][:enabled_plugins_file])
 | 
					    assert {:ok, [[:rabbitmq_federation]]} = :file.consult(context[:opts][:enabled_plugins_file])
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -25,9 +25,6 @@ defmodule EnablePluginsCommandTest do
 | 
				
			||||||
  @root   "/"
 | 
					  @root   "/"
 | 
				
			||||||
  @default_timeout :infinity
 | 
					  @default_timeout :infinity
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					 | 
				
			||||||
  #RABBITMQ_PLUGINS_DIR=~/dev/master/deps RABBITMQ_ENABLED_PLUGINS_FILE=/var/folders/cl/jnydxpf92rg76z05m12hlly80000gq/T/rabbitmq-test-instances/rabbit/enabled_plugins RABBITMQ_HOME=~/dev/master/deps/rabbit ./rabbitmq-plugins list_plugins
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
  setup_all do
 | 
					  setup_all do
 | 
				
			||||||
    RabbitMQ.CLI.Distribution.start()
 | 
					    RabbitMQ.CLI.Distribution.start()
 | 
				
			||||||
    node = get_rabbit_hostname
 | 
					    node = get_rabbit_hostname
 | 
				
			||||||
| 
						 | 
					@ -48,7 +45,7 @@ defmodule EnablePluginsCommandTest do
 | 
				
			||||||
             online: true, offline: false}
 | 
					             online: true, offline: false}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    on_exit(fn ->
 | 
					    on_exit(fn ->
 | 
				
			||||||
      set_enabled_plugins(get_rabbit_hostname,enabled_plugins,opts)
 | 
					      set_enabled_plugins(get_rabbit_hostname, enabled_plugins, opts)
 | 
				
			||||||
    end)
 | 
					    end)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    :erlang.disconnect_node(node)
 | 
					    :erlang.disconnect_node(node)
 | 
				
			||||||
| 
						 | 
					@ -125,7 +122,7 @@ defmodule EnablePluginsCommandTest do
 | 
				
			||||||
           @command.run(["rabbitmq_metronome"], Map.merge(context[:opts], %{node: :nonode}))
 | 
					           @command.run(["rabbitmq_metronome"], Map.merge(context[:opts], %{node: :nonode}))
 | 
				
			||||||
    assert {:ok, [[:rabbitmq_metronome]]} = :file.consult(context[:opts][:enabled_plugins_file])
 | 
					    assert {:ok, [[:rabbitmq_metronome]]} = :file.consult(context[:opts][:enabled_plugins_file])
 | 
				
			||||||
    assert [:amqp_client, :rabbitmq_federation, :rabbitmq_metronome] =
 | 
					    assert [:amqp_client, :rabbitmq_federation, :rabbitmq_metronome] =
 | 
				
			||||||
           Enum.sort(:rabbit_misc.rpc_call(context[:opts][:node], :rabbit_plugins, :active, []))
 | 
					           currently_active_plugins(context)
 | 
				
			||||||
  end
 | 
					  end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  test "will write enabled plugins in offline mode and report implicitly enabled list", context do
 | 
					  test "will write enabled plugins in offline mode and report implicitly enabled list", context do
 | 
				
			||||||
| 
						 | 
					@ -136,7 +133,7 @@ defmodule EnablePluginsCommandTest do
 | 
				
			||||||
           @command.run(["rabbitmq_metronome"], Map.merge(context[:opts], %{offline: true, online: false}))
 | 
					           @command.run(["rabbitmq_metronome"], Map.merge(context[:opts], %{offline: true, online: false}))
 | 
				
			||||||
    assert {:ok, [[:rabbitmq_metronome]]} = :file.consult(context[:opts][:enabled_plugins_file])
 | 
					    assert {:ok, [[:rabbitmq_metronome]]} = :file.consult(context[:opts][:enabled_plugins_file])
 | 
				
			||||||
    assert [:amqp_client, :rabbitmq_federation, :rabbitmq_metronome] =
 | 
					    assert [:amqp_client, :rabbitmq_federation, :rabbitmq_metronome] =
 | 
				
			||||||
           Enum.sort(:rabbit_misc.rpc_call(context[:opts][:node], :rabbit_plugins, :active, []))
 | 
					           currently_active_plugins(context)
 | 
				
			||||||
  end
 | 
					  end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  test "will add additional plugin to already enabled", context do
 | 
					  test "will add additional plugin to already enabled", context do
 | 
				
			||||||
| 
						 | 
					@ -162,7 +159,7 @@ defmodule EnablePluginsCommandTest do
 | 
				
			||||||
           @command.run(["rabbitmq_metronome"], context[:opts])
 | 
					           @command.run(["rabbitmq_metronome"], context[:opts])
 | 
				
			||||||
    assert {:ok, [[:rabbitmq_metronome]]} = :file.consult(context[:opts][:enabled_plugins_file])
 | 
					    assert {:ok, [[:rabbitmq_metronome]]} = :file.consult(context[:opts][:enabled_plugins_file])
 | 
				
			||||||
    assert [:amqp_client, :rabbitmq_metronome] =
 | 
					    assert [:amqp_client, :rabbitmq_metronome] =
 | 
				
			||||||
           Enum.sort(:rabbit_misc.rpc_call(context[:opts][:node], :rabbit_plugins, :active, []))
 | 
					           currently_active_plugins(context)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    assert %{mode: :online,
 | 
					    assert %{mode: :online,
 | 
				
			||||||
             started: [:rabbitmq_federation], stopped: [],
 | 
					             started: [:rabbitmq_federation], stopped: [],
 | 
				
			||||||
| 
						 | 
					@ -170,7 +167,7 @@ defmodule EnablePluginsCommandTest do
 | 
				
			||||||
           @command.run(["rabbitmq_federation"], context[:opts])
 | 
					           @command.run(["rabbitmq_federation"], context[:opts])
 | 
				
			||||||
    assert {:ok, [[:rabbitmq_metronome, :rabbitmq_federation]]} = :file.consult(context[:opts][:enabled_plugins_file])
 | 
					    assert {:ok, [[:rabbitmq_metronome, :rabbitmq_federation]]} = :file.consult(context[:opts][:enabled_plugins_file])
 | 
				
			||||||
    assert [:amqp_client, :rabbitmq_federation, :rabbitmq_metronome] =
 | 
					    assert [:amqp_client, :rabbitmq_federation, :rabbitmq_metronome] =
 | 
				
			||||||
           Enum.sort(:rabbit_misc.rpc_call(context[:opts][:node], :rabbit_plugins, :active, []))
 | 
					           currently_active_plugins(context)
 | 
				
			||||||
  end
 | 
					  end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  test "can enable multiple plugins", context do
 | 
					  test "can enable multiple plugins", context do
 | 
				
			||||||
| 
						 | 
					@ -183,7 +180,7 @@ defmodule EnablePluginsCommandTest do
 | 
				
			||||||
           @command.run(["rabbitmq_metronome", "rabbitmq_federation"], context[:opts])
 | 
					           @command.run(["rabbitmq_metronome", "rabbitmq_federation"], context[:opts])
 | 
				
			||||||
    assert {:ok, [[:rabbitmq_metronome, :rabbitmq_federation]]} = :file.consult(context[:opts][:enabled_plugins_file])
 | 
					    assert {:ok, [[:rabbitmq_metronome, :rabbitmq_federation]]} = :file.consult(context[:opts][:enabled_plugins_file])
 | 
				
			||||||
    assert [:amqp_client, :rabbitmq_federation, :rabbitmq_metronome] =
 | 
					    assert [:amqp_client, :rabbitmq_federation, :rabbitmq_metronome] =
 | 
				
			||||||
           Enum.sort(:rabbit_misc.rpc_call(context[:opts][:node], :rabbit_plugins, :active, []))
 | 
					           currently_active_plugins(context)
 | 
				
			||||||
  end
 | 
					  end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  test "will not enable already enabled implicit plugin", context do
 | 
					  test "will not enable already enabled implicit plugin", context do
 | 
				
			||||||
| 
						 | 
					@ -196,8 +193,7 @@ defmodule EnablePluginsCommandTest do
 | 
				
			||||||
           @command.run(["amqp_client"], context[:opts])
 | 
					           @command.run(["amqp_client"], context[:opts])
 | 
				
			||||||
    assert {:ok, [[:rabbitmq_federation]]} = :file.consult(context[:opts][:enabled_plugins_file])
 | 
					    assert {:ok, [[:rabbitmq_federation]]} = :file.consult(context[:opts][:enabled_plugins_file])
 | 
				
			||||||
    assert [:amqp_client, :rabbitmq_federation] =
 | 
					    assert [:amqp_client, :rabbitmq_federation] =
 | 
				
			||||||
           Enum.sort(:rabbit_misc.rpc_call(context[:opts][:node], :rabbit_plugins, :active, []))
 | 
					           currently_active_plugins(context)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  end
 | 
					  end
 | 
				
			||||||
 | 
					 | 
				
			||||||
end
 | 
					end
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -270,4 +270,8 @@ defmodule TestHelper do
 | 
				
			||||||
  def set_enabled_plugins(node, plugins, opts) do
 | 
					  def set_enabled_plugins(node, plugins, opts) do
 | 
				
			||||||
    PluginHelpers.set_enabled_plugins(plugins, :online, node, opts)
 | 
					    PluginHelpers.set_enabled_plugins(plugins, :online, node, opts)
 | 
				
			||||||
  end
 | 
					  end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  def currently_active_plugins(context) do
 | 
				
			||||||
 | 
					    Enum.sort(:rabbit_misc.rpc_call(context[:opts][:node], :rabbit_plugins, :active, []))
 | 
				
			||||||
 | 
					  end
 | 
				
			||||||
end
 | 
					end
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in New Issue