diff options
author | Michael Klishin <mklishin@pivotal.io> | 2019-04-11 01:29:56 +0300 |
---|---|---|
committer | Michael Klishin <mklishin@pivotal.io> | 2019-04-11 01:38:20 +0300 |
commit | b7932ab6d49818106703ca4acc613d44a01f61cf (patch) | |
tree | a16ec07da865fa7d3ea687d8374a1140e99c4a95 | |
parent | 9cb776c98ef41534fec1c868dfbbd6c7c6808965 (diff) | |
download | rabbitmq-server-git-b7932ab6d49818106703ca4acc613d44a01f61cf.tar.gz |
Extract Core.Alarms and Core.Listeners from Diagnostics.Helpers
12 files changed, 252 insertions, 232 deletions
diff --git a/deps/rabbitmq_cli/lib/rabbitmq/cli/core/alarms.ex b/deps/rabbitmq_cli/lib/rabbitmq/cli/core/alarms.ex new file mode 100644 index 0000000000..e7675656a2 --- /dev/null +++ b/deps/rabbitmq_cli/lib/rabbitmq/cli/core/alarms.ex @@ -0,0 +1,52 @@ +## 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 https://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) 2007-2019 Pivotal Software, Inc. All rights reserved. + +defmodule RabbitMQ.CLI.Core.Alarms do + def alarm_lines(alarms, node_name) do + Enum.reduce(alarms, [], fn + :file_descriptor_limit, acc -> + ["File descriptor limit alarm on node #{node_name}" | acc] + + {{:resource_limit, :memory, alarmed_node_name}, _}, acc -> + ["Memory alarm on node #{alarmed_node_name}" | acc] + + {{:resource_limit, :disk, alarmed_node_name}, _}, acc -> + ["Free disk space alarm on node #{alarmed_node_name}" | acc] + end) + |> Enum.reverse() + end + + def local_alarms(alarms, node_name) do + Enum.filter( + alarms, + fn + # local by definition + :file_descriptor_limit -> + true + + {{:resource_limit, _, a_node}, _} -> + node_name == a_node + end + ) + end + + def clusterwide_alarms(alarms, node_name) do + alarms + |> Enum.reject(fn x -> x == :file_descriptor_limit end) + |> Enum.filter(fn {{:resource_limit, _, a_node}, _} -> + a_node != node_name + end) + end +end diff --git a/deps/rabbitmq_cli/lib/rabbitmq/cli/core/listeners.ex b/deps/rabbitmq_cli/lib/rabbitmq/cli/core/listeners.ex new file mode 100644 index 0000000000..9bfd0271d5 --- /dev/null +++ b/deps/rabbitmq_cli/lib/rabbitmq/cli/core/listeners.ex @@ -0,0 +1,175 @@ +## 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 https://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) 2007-2019 Pivotal Software, Inc. All rights reserved. + +defmodule RabbitMQ.CLI.Core.Listeners do + import Record, only: [defrecord: 2, extract: 2] + import RabbitCommon.Records + import Rabbitmq.Atom.Coerce + + # + # API + # + + defrecord :hostent, extract(:hostent, from_lib: "kernel/include/inet.hrl") + + def listeners_on(listeners, target_node) do + Enum.filter(listeners, fn listener(node: node) -> + node == target_node + end) + end + + def listener_lines(listeners) do + listeners + |> listener_maps + |> Enum.map(fn %{interface: interface, port: port, protocol: protocol} -> + "Interface: #{interface}, port: #{port}, protocol: #{protocol}, purpose: #{ + protocol_label(to_atom(protocol)) + }" + end) + end + + def listener_map(listener) do + # Listener options are left out intentionally: they can contain deeply nested values + # that are impossible to serialise to JSON. + # + # Management plugin/HTTP API had its fair share of bugs because of that + # and now filters out a lot of options. Raw listener data can be seen in + # rabbitmq-diagnostics status. + listener(node: node, protocol: protocol, ip_address: interface, port: port) = listener + + %{ + node: node, + protocol: protocol, + interface: :inet.ntoa(interface) |> to_string |> maybe_enquote_interface, + port: port, + purpose: protocol_label(to_atom(protocol)) + } + end + + def listener_maps(listeners) do + Enum.map(listeners, &listener_map/1) + end + + def listener_rows(listeners) do + for listener(node: node, protocol: protocol, ip_address: interface, port: port) <- listeners do + # Listener options are left out intentionally, see above + [ + node: node, + protocol: protocol, + interface: :inet.ntoa(interface) |> to_string |> maybe_enquote_interface, + port: port, + purpose: protocol_label(to_atom(protocol)) + ] + end + end + + def protocol_label(:amqp), do: "AMQP 0-9-1 and AMQP 1.0" + def protocol_label(:'amqp/ssl'), do: "AMQP 0-9-1 and AMQP 1.0 over TLS" + def protocol_label(:mqtt), do: "MQTT" + def protocol_label(:'mqtt/ssl'), do: "MQTT over TLS" + def protocol_label(:stomp), do: "STOMP" + def protocol_label(:'stomp/ssl'), do: "STOMP over TLS" + def protocol_label(:http), do: "HTTP API" + def protocol_label(:https), do: "HTTP API over TLS (HTTPS)" + def protocol_label(:"http/web-mqtt"), do: "MQTT over WebSockets" + def protocol_label(:"https/web-mqtt"), do: "MQTT over WebSockets and TLS (HTTPS)" + def protocol_label(:"http/web-stomp"), do: "STOMP over WebSockets" + def protocol_label(:"https/web-stomp"), do: "STOMP over WebSockets and TLS (HTTPS)" + def protocol_label(:clustering), do: "inter-node and CLI tool communication" + def protocol_label(other), do: to_string(other) + + def normalize_protocol(proto) do + val = proto |> to_string |> String.downcase() + + case val do + "amqp091" -> "amqp" + "amqp0.9.1" -> "amqp" + "amqp0-9-1" -> "amqp" + "amqp0_9_1" -> "amqp" + "amqp10" -> "amqp" + "amqp1.0" -> "amqp" + "amqp1-0" -> "amqp" + "amqp1_0" -> "amqp" + "amqps" -> "amqp/ssl" + "mqtt3.1" -> "mqtt" + "mqtt3.1.1" -> "mqtt" + "mqtt31" -> "mqtt" + "mqtt311" -> "mqtt" + "mqtt3_1" -> "mqtt" + "mqtt3_1_1" -> "mqtt" + "mqtts" -> "mqtt/ssl" + "mqtt+tls" -> "mqtt/ssl" + "mqtt+ssl" -> "mqtt/ssl" + "stomp1.0" -> "stomp" + "stomp1.1" -> "stomp" + "stomp1.2" -> "stomp" + "stomp10" -> "stomp" + "stomp11" -> "stomp" + "stomp12" -> "stomp" + "stomp1_0" -> "stomp" + "stomp1_1" -> "stomp" + "stomp1_2" -> "stomp" + "stomps" -> "stomp/ssl" + "stomp+tls" -> "stomp/ssl" + "stomp+ssl" -> "stomp/ssl" + "https" -> "https" + "http1" -> "http" + "http1.1" -> "http" + "http_api" -> "http" + "management" -> "http" + "management_ui" -> "http" + "ui" -> "http" + "cli" -> "clustering" + "distribution" -> "clustering" + "webmqtt" -> "http/web-mqtt" + "web-mqtt" -> "http/web-mqtt" + "web_mqtt" -> "http/web-mqtt" + "webmqtt/tls" -> "https/web-mqtt" + "web-mqtt/tls" -> "https/web-mqtt" + "webmqtt/ssl" -> "https/web-mqtt" + "web-mqtt/ssl" -> "https/web-mqtt" + "webmqtt+tls" -> "https/web-mqtt" + "web-mqtt+tls" -> "https/web-mqtt" + "webmqtt+ssl" -> "https/web-mqtt" + "web-mqtt+ssl" -> "https/web-mqtt" + "webstomp" -> "http/web-stomp" + "web-stomp" -> "http/web-stomp" + "web_stomp" -> "http/web-stomp" + "webstomp/tls" -> "https/web-stomp" + "web-stomp/tls" -> "https/web-stomp" + "webstomp/ssl" -> "https/web-stomp" + "web-stomp/ssl" -> "https/web-stomp" + "webstomp+tls" -> "https/web-stomp" + "web-stomp+tls" -> "https/web-stomp" + "webstomp+ssl" -> "https/web-stomp" + "web-stomp+ssl" -> "https/web-stomp" + _ -> val + end + end + + # + # Implementation + # + + defp maybe_enquote_interface(value) do + # This simplistic way of distinguishing IPv6 addresses, + # networks address ranges, etc actually works better + # for the kind of values we can get here than :inet functions. MK. + case value =~ ~r/:/ do + true -> "[#{value}]" + false -> value + end + end +end diff --git a/deps/rabbitmq_cli/lib/rabbitmq/cli/diagnostics/commands/alarms_command.ex b/deps/rabbitmq_cli/lib/rabbitmq/cli/diagnostics/commands/alarms_command.ex index f0ead11314..4b973732df 100644 --- a/deps/rabbitmq_cli/lib/rabbitmq/cli/diagnostics/commands/alarms_command.ex +++ b/deps/rabbitmq_cli/lib/rabbitmq/cli/diagnostics/commands/alarms_command.ex @@ -21,9 +21,7 @@ defmodule RabbitMQ.CLI.Diagnostics.Commands.AlarmsCommand do errors. This command is not meant to be used in health checks. """ import RabbitMQ.CLI.Core.Platform, only: [line_separator: 0] - - import RabbitMQ.CLI.Diagnostics.Helpers, - only: [alarm_lines: 2, local_alarms: 2, clusterwide_alarms: 2] + import RabbitMQ.CLI.Core.Alarms @behaviour RabbitMQ.CLI.CommandBehaviour diff --git a/deps/rabbitmq_cli/lib/rabbitmq/cli/diagnostics/commands/check_alarms_command.ex b/deps/rabbitmq_cli/lib/rabbitmq/cli/diagnostics/commands/check_alarms_command.ex index ce80ee8ca1..2b71ca7df7 100644 --- a/deps/rabbitmq_cli/lib/rabbitmq/cli/diagnostics/commands/check_alarms_command.ex +++ b/deps/rabbitmq_cli/lib/rabbitmq/cli/diagnostics/commands/check_alarms_command.ex @@ -22,8 +22,7 @@ defmodule RabbitMQ.CLI.Diagnostics.Commands.CheckAlarmsCommand do This command is meant to be used in health checks. """ - import RabbitMQ.CLI.Diagnostics.Helpers, - only: [alarm_lines: 2, local_alarms: 2, clusterwide_alarms: 2] + import RabbitMQ.CLI.Core.Alarms import RabbitMQ.CLI.Core.Platform, only: [line_separator: 0] @behaviour RabbitMQ.CLI.CommandBehaviour diff --git a/deps/rabbitmq_cli/lib/rabbitmq/cli/diagnostics/commands/check_local_alarms_command.ex b/deps/rabbitmq_cli/lib/rabbitmq/cli/diagnostics/commands/check_local_alarms_command.ex index 0f94a7fb9b..6bdfcd198d 100644 --- a/deps/rabbitmq_cli/lib/rabbitmq/cli/diagnostics/commands/check_local_alarms_command.ex +++ b/deps/rabbitmq_cli/lib/rabbitmq/cli/diagnostics/commands/check_local_alarms_command.ex @@ -20,7 +20,7 @@ defmodule RabbitMQ.CLI.Diagnostics.Commands.CheckLocalAlarmsCommand do This command is meant to be used in health checks. """ - import RabbitMQ.CLI.Diagnostics.Helpers, only: [alarm_lines: 2, local_alarms: 2] + import RabbitMQ.CLI.Core.Alarms import RabbitMQ.CLI.Core.Platform, only: [line_separator: 0] @behaviour RabbitMQ.CLI.CommandBehaviour diff --git a/deps/rabbitmq_cli/lib/rabbitmq/cli/diagnostics/commands/check_port_connectivity_command.ex b/deps/rabbitmq_cli/lib/rabbitmq/cli/diagnostics/commands/check_port_connectivity_command.ex index 7dd62bc6cb..90a429baa3 100644 --- a/deps/rabbitmq_cli/lib/rabbitmq/cli/diagnostics/commands/check_port_connectivity_command.ex +++ b/deps/rabbitmq_cli/lib/rabbitmq/cli/diagnostics/commands/check_port_connectivity_command.ex @@ -23,14 +23,9 @@ defmodule RabbitMQ.CLI.Diagnostics.Commands.CheckPortConnectivityCommand do """ import RabbitMQ.CLI.Diagnostics.Helpers, - only: [ - listeners_on: 2, - listener_lines: 1, - listener_map: 1, - listener_maps: 1, - check_listener_connectivity: 3 - ] + only: [check_listener_connectivity: 3] import RabbitMQ.CLI.Core.Platform, only: [line_separator: 0] + import RabbitMQ.CLI.Core.Listeners @behaviour RabbitMQ.CLI.CommandBehaviour diff --git a/deps/rabbitmq_cli/lib/rabbitmq/cli/diagnostics/commands/check_port_listener_command.ex b/deps/rabbitmq_cli/lib/rabbitmq/cli/diagnostics/commands/check_port_listener_command.ex index 04316271d9..6dd15b91e2 100644 --- a/deps/rabbitmq_cli/lib/rabbitmq/cli/diagnostics/commands/check_port_listener_command.ex +++ b/deps/rabbitmq_cli/lib/rabbitmq/cli/diagnostics/commands/check_port_listener_command.ex @@ -21,7 +21,7 @@ defmodule RabbitMQ.CLI.Diagnostics.Commands.CheckPortListenerCommand do This command is meant to be used in health checks. """ - import RabbitMQ.CLI.Diagnostics.Helpers, only: [listeners_on: 2, listener_maps: 1] + import RabbitMQ.CLI.Core.Listeners, only: [listeners_on: 2, listener_maps: 1] @behaviour RabbitMQ.CLI.CommandBehaviour diff --git a/deps/rabbitmq_cli/lib/rabbitmq/cli/diagnostics/commands/check_protocol_listener_command.ex b/deps/rabbitmq_cli/lib/rabbitmq/cli/diagnostics/commands/check_protocol_listener_command.ex index 5fd7a4a034..70dc4d2d2a 100644 --- a/deps/rabbitmq_cli/lib/rabbitmq/cli/diagnostics/commands/check_protocol_listener_command.ex +++ b/deps/rabbitmq_cli/lib/rabbitmq/cli/diagnostics/commands/check_protocol_listener_command.ex @@ -21,7 +21,7 @@ defmodule RabbitMQ.CLI.Diagnostics.Commands.CheckProtocolListenerCommand do This command is meant to be used in health checks. """ - import RabbitMQ.CLI.Diagnostics.Helpers, + import RabbitMQ.CLI.Core.Listeners, only: [listeners_on: 2, listener_maps: 1, normalize_protocol: 1] @behaviour RabbitMQ.CLI.CommandBehaviour diff --git a/deps/rabbitmq_cli/lib/rabbitmq/cli/diagnostics/commands/listeners_command.ex b/deps/rabbitmq_cli/lib/rabbitmq/cli/diagnostics/commands/listeners_command.ex index 5661ece910..a3ae42c3c1 100644 --- a/deps/rabbitmq_cli/lib/rabbitmq/cli/diagnostics/commands/listeners_command.ex +++ b/deps/rabbitmq_cli/lib/rabbitmq/cli/diagnostics/commands/listeners_command.ex @@ -21,7 +21,7 @@ defmodule RabbitMQ.CLI.Diagnostics.Commands.ListenersCommand do errors. This command is not meant to be used in health checks. """ - import RabbitMQ.CLI.Diagnostics.Helpers, + import RabbitMQ.CLI.Core.Listeners, only: [listeners_on: 2, listener_lines: 1, listener_maps: 1, listener_rows: 1] import RabbitMQ.CLI.Core.Platform, only: [line_separator: 0] diff --git a/deps/rabbitmq_cli/lib/rabbitmq/cli/diagnostics/diagnostics_helpers.ex b/deps/rabbitmq_cli/lib/rabbitmq/cli/diagnostics/diagnostics_helpers.ex index 6023f32b00..168d5a272c 100644 --- a/deps/rabbitmq_cli/lib/rabbitmq/cli/diagnostics/diagnostics_helpers.ex +++ b/deps/rabbitmq_cli/lib/rabbitmq/cli/diagnostics/diagnostics_helpers.ex @@ -14,67 +14,6 @@ ## Copyright (c) 2007-2019 Pivotal Software, Inc. All rights reserved. defmodule RabbitMQ.CLI.Diagnostics.Helpers do - import Record, only: [defrecord: 2, extract: 2] - import RabbitCommon.Records - import Rabbitmq.Atom.Coerce - - # - # Listeners - # - - defrecord :hostent, extract(:hostent, from_lib: "kernel/include/inet.hrl") - - def listeners_on(listeners, target_node) do - Enum.filter(listeners, fn listener(node: node) -> - node == target_node - end) - end - - def listener_lines(listeners) do - listeners - |> listener_maps - |> Enum.map(fn %{interface: interface, port: port, protocol: protocol} -> - "Interface: #{interface}, port: #{port}, protocol: #{protocol}, purpose: #{ - protocol_label(to_atom(protocol)) - }" - end) - end - - def listener_map(listener) do - # Listener options are left out intentionally: they can contain deeply nested values - # that are impossible to serialise to JSON. - # - # Management plugin/HTTP API had its fair share of bugs because of that - # and now filters out a lot of options. Raw listener data can be seen in - # rabbitmq-diagnostics status. - listener(node: node, protocol: protocol, ip_address: interface, port: port) = listener - - %{ - node: node, - protocol: protocol, - interface: :inet.ntoa(interface) |> to_string |> maybe_enquote_interface, - port: port, - purpose: protocol_label(to_atom(protocol)) - } - end - - def listener_maps(listeners) do - Enum.map(listeners, &listener_map/1) - end - - def listener_rows(listeners) do - for listener(node: node, protocol: protocol, ip_address: interface, port: port) <- listeners do - # Listener options are left out intentionally, see above - [ - node: node, - protocol: protocol, - interface: :inet.ntoa(interface) |> to_string |> maybe_enquote_interface, - port: port, - purpose: protocol_label(to_atom(protocol)) - ] - end - end - def check_port_connectivity(port, node_name, timeout) do hostname = Regex.replace(~r/^(.+)@/, to_string(node_name), "") |> to_charlist @@ -98,142 +37,4 @@ defmodule RabbitMQ.CLI.Diagnostics.Helpers do def check_listener_connectivity(%{port: port}, node_name, timeout) do check_port_connectivity(port, node_name, timeout) end - - def protocol_label(:amqp), do: "AMQP 0-9-1 and AMQP 1.0" - def protocol_label(:'amqp/ssl'), do: "AMQP 0-9-1 and AMQP 1.0 over TLS" - def protocol_label(:mqtt), do: "MQTT" - def protocol_label(:'mqtt/ssl'), do: "MQTT over TLS" - def protocol_label(:stomp), do: "STOMP" - def protocol_label(:'stomp/ssl'), do: "STOMP over TLS" - def protocol_label(:http), do: "HTTP API" - def protocol_label(:https), do: "HTTP API over TLS (HTTPS)" - def protocol_label(:"http/web-mqtt"), do: "MQTT over WebSockets" - def protocol_label(:"https/web-mqtt"), do: "MQTT over WebSockets and TLS (HTTPS)" - def protocol_label(:"http/web-stomp"), do: "STOMP over WebSockets" - def protocol_label(:"https/web-stomp"), do: "STOMP over WebSockets and TLS (HTTPS)" - def protocol_label(:clustering), do: "inter-node and CLI tool communication" - def protocol_label(other), do: to_string(other) - - def normalize_protocol(proto) do - val = proto |> to_string |> String.downcase() - - case val do - "amqp091" -> "amqp" - "amqp0.9.1" -> "amqp" - "amqp0-9-1" -> "amqp" - "amqp0_9_1" -> "amqp" - "amqp10" -> "amqp" - "amqp1.0" -> "amqp" - "amqp1-0" -> "amqp" - "amqp1_0" -> "amqp" - "amqps" -> "amqp/ssl" - "mqtt3.1" -> "mqtt" - "mqtt3.1.1" -> "mqtt" - "mqtt31" -> "mqtt" - "mqtt311" -> "mqtt" - "mqtt3_1" -> "mqtt" - "mqtt3_1_1" -> "mqtt" - "mqtts" -> "mqtt/ssl" - "mqtt+tls" -> "mqtt/ssl" - "mqtt+ssl" -> "mqtt/ssl" - "stomp1.0" -> "stomp" - "stomp1.1" -> "stomp" - "stomp1.2" -> "stomp" - "stomp10" -> "stomp" - "stomp11" -> "stomp" - "stomp12" -> "stomp" - "stomp1_0" -> "stomp" - "stomp1_1" -> "stomp" - "stomp1_2" -> "stomp" - "stomps" -> "stomp/ssl" - "stomp+tls" -> "stomp/ssl" - "stomp+ssl" -> "stomp/ssl" - "https" -> "https" - "http1" -> "http" - "http1.1" -> "http" - "http_api" -> "http" - "management" -> "http" - "management_ui" -> "http" - "ui" -> "http" - "cli" -> "clustering" - "distribution" -> "clustering" - "webmqtt" -> "http/web-mqtt" - "web-mqtt" -> "http/web-mqtt" - "web_mqtt" -> "http/web-mqtt" - "webmqtt/tls" -> "https/web-mqtt" - "web-mqtt/tls" -> "https/web-mqtt" - "webmqtt/ssl" -> "https/web-mqtt" - "web-mqtt/ssl" -> "https/web-mqtt" - "webmqtt+tls" -> "https/web-mqtt" - "web-mqtt+tls" -> "https/web-mqtt" - "webmqtt+ssl" -> "https/web-mqtt" - "web-mqtt+ssl" -> "https/web-mqtt" - "webstomp" -> "http/web-stomp" - "web-stomp" -> "http/web-stomp" - "web_stomp" -> "http/web-stomp" - "webstomp/tls" -> "https/web-stomp" - "web-stomp/tls" -> "https/web-stomp" - "webstomp/ssl" -> "https/web-stomp" - "web-stomp/ssl" -> "https/web-stomp" - "webstomp+tls" -> "https/web-stomp" - "web-stomp+tls" -> "https/web-stomp" - "webstomp+ssl" -> "https/web-stomp" - "web-stomp+ssl" -> "https/web-stomp" - _ -> val - end - end - - # - # Alarms - # - - def alarm_lines(alarms, node_name) do - Enum.reduce(alarms, [], fn - :file_descriptor_limit, acc -> - ["File descriptor limit alarm on node #{node_name}" | acc] - - {{:resource_limit, :memory, alarmed_node_name}, _}, acc -> - ["Memory alarm on node #{alarmed_node_name}" | acc] - - {{:resource_limit, :disk, alarmed_node_name}, _}, acc -> - ["Free disk space alarm on node #{alarmed_node_name}" | acc] - end) - |> Enum.reverse() - end - - def local_alarms(alarms, node_name) do - Enum.filter( - alarms, - fn - # local by definition - :file_descriptor_limit -> - true - - {{:resource_limit, _, a_node}, _} -> - node_name == a_node - end - ) - end - - def clusterwide_alarms(alarms, node_name) do - alarms - |> Enum.reject(fn x -> x == :file_descriptor_limit end) - |> Enum.filter(fn {{:resource_limit, _, a_node}, _} -> - a_node != node_name - end) - end - - # - # Implementation - # - - defp maybe_enquote_interface(value) do - # This simplistic way of distinguishing IPv6 addresses, - # networks address ranges, etc actually works better - # for the kind of values we can get here than :inet functions. MK. - case value =~ ~r/:/ do - true -> "[#{value}]" - false -> value - end - end end diff --git a/deps/rabbitmq_cli/test/diagnostics/diagnostics_helpers_test.exs b/deps/rabbitmq_cli/test/core/listeners_test.exs index 729a35c88b..af48b94e32 100644 --- a/deps/rabbitmq_cli/test/diagnostics/diagnostics_helpers_test.exs +++ b/deps/rabbitmq_cli/test/core/listeners_test.exs @@ -13,17 +13,17 @@ ## The Initial Developer of the Original Code is GoPivotal, Inc. ## Copyright (c) 2007-2019 Pivotal Software, Inc. All rights reserved. -defmodule DiagnosticsHelpersTest do +defmodule CoreListenersTest do use ExUnit.Case, async: true - alias RabbitMQ.CLI.Diagnostics.Helpers, as: DH + import RabbitMQ.CLI.Core.Listeners import RabbitCommon.Records test "listener record translation to a map" do - assert DH.listener_map(listener(node: :rabbit@mercurio, - protocol: :stomp, - ip_address: {0,0,0,0,0,0,0,0}, - port: 61613)) == + assert listener_map(listener(node: :rabbit@mercurio, + protocol: :stomp, + ip_address: {0,0,0,0,0,0,0,0}, + port: 61613)) == %{ interface: "[::]", node: :rabbit@mercurio, @@ -34,15 +34,15 @@ defmodule DiagnosticsHelpersTest do end test "[human-readable] protocol labels" do - assert DH.protocol_label(:amqp) == "AMQP 0-9-1 and AMQP 1.0" - assert DH.protocol_label(:'amqp/ssl') == "AMQP 0-9-1 and AMQP 1.0 over TLS" - assert DH.protocol_label(:mqtt) == "MQTT" - assert DH.protocol_label(:'mqtt/ssl') == "MQTT over TLS" - assert DH.protocol_label(:stomp) == "STOMP" - assert DH.protocol_label(:'stomp/ssl') == "STOMP over TLS" - assert DH.protocol_label(:http) == "HTTP API" - assert DH.protocol_label(:https) == "HTTP API over TLS (HTTPS)" - assert DH.protocol_label(:'https/web-stomp') == "STOMP over WebSockets and TLS (HTTPS)" - assert DH.protocol_label(:'https/web-mqtt') == "MQTT over WebSockets and TLS (HTTPS)" + assert protocol_label(:amqp) == "AMQP 0-9-1 and AMQP 1.0" + assert protocol_label(:'amqp/ssl') == "AMQP 0-9-1 and AMQP 1.0 over TLS" + assert protocol_label(:mqtt) == "MQTT" + assert protocol_label(:'mqtt/ssl') == "MQTT over TLS" + assert protocol_label(:stomp) == "STOMP" + assert protocol_label(:'stomp/ssl') == "STOMP over TLS" + assert protocol_label(:http) == "HTTP API" + assert protocol_label(:https) == "HTTP API over TLS (HTTPS)" + assert protocol_label(:'https/web-stomp') == "STOMP over WebSockets and TLS (HTTPS)" + assert protocol_label(:'https/web-mqtt') == "MQTT over WebSockets and TLS (HTTPS)" end end diff --git a/deps/rabbitmq_cli/test/diagnostics/listeners_command_test.exs b/deps/rabbitmq_cli/test/diagnostics/listeners_command_test.exs index 2b228f7898..96ebabfdad 100644 --- a/deps/rabbitmq_cli/test/diagnostics/listeners_command_test.exs +++ b/deps/rabbitmq_cli/test/diagnostics/listeners_command_test.exs @@ -16,7 +16,7 @@ defmodule ListenersCommandTest do use ExUnit.Case import TestHelper - import RabbitMQ.CLI.Diagnostics.Helpers, only: [listener_maps: 1] + import RabbitMQ.CLI.Core.Listeners, only: [listener_maps: 1] @command RabbitMQ.CLI.Diagnostics.Commands.ListenersCommand |