diff options
author | juhlig <[email protected]> | 2019-07-17 16:02:47 +0200 |
---|---|---|
committer | Loïc Hoguin <[email protected]> | 2019-07-18 09:35:56 +0200 |
commit | af739162fd43d46f2562af96c56147054457518e (patch) | |
tree | 51d5c937c3ee0af17c8cbe75d0f7bcd70aacfa91 /test | |
parent | d017c0f5860bc1a5c775c9a61db407e29c575f80 (diff) | |
download | ranch-2.0.0-rc.1.tar.gz ranch-2.0.0-rc.1.tar.bz2 ranch-2.0.0-rc.1.zip |
Return listener info as a map2.0.0-rc.1
Diffstat (limited to 'test')
-rw-r--r-- | test/acceptor_SUITE.erl | 163 |
1 files changed, 73 insertions, 90 deletions
diff --git a/test/acceptor_SUITE.erl b/test/acceptor_SUITE.erl index 1cccabc..8748201 100644 --- a/test/acceptor_SUITE.erl +++ b/test/acceptor_SUITE.erl @@ -137,47 +137,41 @@ misc_info(_) -> {ok, _} = gen_tcp:connect("localhost", Port1, [binary, {active, false}, {packet, raw}]), receive after 250 -> ok end, %% Confirm the info returned by Ranch is correct. - [ - {{misc_info, act}, [ - {pid, Pid2}, - {status, _}, - {ip, _}, - {port, Port2}, - {max_connections, infinity}, %% Option was modified. - {active_connections, 0}, - {all_connections, 0}, - {transport, ranch_tcp}, - {transport_options, #{num_acceptors := 2}}, - {protocol, active_echo_protocol}, - {protocol_options, {}} - ]}, - {{misc_info, ssl}, [ - {pid, Pid3}, - {status, _}, - {ip, _}, - {port, Port3}, - {max_connections, 1024}, - {active_connections, 0}, - {all_connections, 0}, - {transport, ranch_ssl}, - {transport_options, #{num_acceptors := 3, socket_opts := Opts}}, - {protocol, echo_protocol}, - {protocol_options, [{}]} - ]}, - {{misc_info, tcp}, [ - {pid, Pid1}, - {status, _}, - {ip, _}, - {port, Port1}, - {max_connections, 1024}, - {active_connections, 2}, - {all_connections, 5}, - {transport, ranch_tcp}, - {transport_options, #{num_acceptors := 1}}, - {protocol, remove_conn_and_wait_protocol}, - {protocol_options, [{remove, false, 2500}]} %% Option was modified. - ]} - ] = do_get_listener_info(misc_info), + #{ + {misc_info, act} := #{ + pid := Pid2, + port := Port2, + max_connections := infinity, %% Option was modified. + active_connections := 0, + all_connections := 0, + transport := ranch_tcp, + transport_options := #{num_acceptors := 2}, + protocol := active_echo_protocol, + protocol_options := {} + }, + {misc_info, ssl} := #{ + pid := Pid3, + port := Port3, + max_connections := 1024, + active_connections := 0, + all_connections := 0, + transport := ranch_ssl, + transport_options := #{num_acceptors := 3, socket_opts := Opts}, + protocol := echo_protocol, + protocol_options := [{}] + }, + {misc_info, tcp} := #{ + pid := Pid1, + port := Port1, + max_connections := 1024, + active_connections := 2, + all_connections := 5, + transport := ranch_tcp, + transport_options := #{num_acceptors := 1}, + protocol := remove_conn_and_wait_protocol, + protocol_options := [{remove, false, 2500}] %% Option was modified. + } + } = ranch:info(), %% Get acceptors. [_] = ranch:procs({misc_info, tcp}, acceptors), [_, _] = ranch:procs({misc_info, act}, acceptors), @@ -224,47 +218,41 @@ misc_info_embedded(_) -> {ok, _} = gen_tcp:connect("localhost", Port1, [binary, {active, false}, {packet, raw}]), receive after 250 -> ok end, %% Confirm the info returned by Ranch is correct. - [ - {{misc_info_embedded, act}, [ - {pid, Pid2}, - {status, _}, - {ip, _}, - {port, Port2}, - {max_connections, infinity}, %% Option was modified. - {active_connections, 0}, - {all_connections, 0}, - {transport, ranch_tcp}, - {transport_options, #{num_acceptors := 2}}, - {protocol, active_echo_protocol}, - {protocol_options, {}} - ]}, - {{misc_info_embedded, ssl}, [ - {pid, Pid3}, - {status, _}, - {ip, _}, - {port, Port3}, - {max_connections, 1024}, - {active_connections, 0}, - {all_connections, 0}, - {transport, ranch_ssl}, - {transport_options, #{num_acceptors := 3, socket_opts := Opts}}, - {protocol, echo_protocol}, - {protocol_options, [{}]} - ]}, - {{misc_info_embedded, tcp}, [ - {pid, Pid1}, - {status, _}, - {ip, _}, - {port, Port1}, - {max_connections, 1024}, - {active_connections, 2}, - {all_connections, 5}, - {transport, ranch_tcp}, - {transport_options, #{num_acceptors := 1}}, - {protocol, remove_conn_and_wait_protocol}, - {protocol_options, [{remove, false, 2500}]} %% Option was modified. - ]} - ] = do_get_listener_info(misc_info_embedded), + #{ + {misc_info_embedded, act} := #{ + pid := Pid2, + port := Port2, + max_connections := infinity, %% Option was modified. + active_connections := 0, + all_connections := 0, + transport := ranch_tcp, + transport_options := #{num_acceptors := 2}, + protocol := active_echo_protocol, + protocol_options := {} + }, + {misc_info_embedded, ssl} := #{ + pid := Pid3, + port := Port3, + max_connections := 1024, + active_connections := 0, + all_connections := 0, + transport := ranch_ssl, + transport_options := #{num_acceptors := 3, socket_opts := Opts}, + protocol := echo_protocol, + protocol_options := [{}] + }, + {misc_info_embedded, tcp} := #{ + pid := Pid1, + port := Port1, + max_connections := 1024, + active_connections := 2, + all_connections := 5, + transport := ranch_tcp, + transport_options := #{num_acceptors := 1}, + protocol := remove_conn_and_wait_protocol, + protocol_options := [{remove, false, 2500}] %% Option was modified. + } + } = ranch:info(), %% Get acceptors. [_] = ranch:procs({misc_info_embedded, tcp}, acceptors), [_, _] = ranch:procs({misc_info_embedded, act}, acceptors), @@ -276,24 +264,19 @@ misc_info_embedded(_) -> %% Stop embedded tcp listener and ensure it is gone. ok = embedded_sup:stop_listener(SupPid, {misc_info_embedded, tcp}), timer:sleep(500), - [{{misc_info_embedded, act}, _}, {{misc_info_embedded, ssl}, _}] = - do_get_listener_info(misc_info_embedded), + false = maps:is_key({misc_info_embedded, tcp}, ranch:info()), %% Stop embedded act listener and ensure it is gone. ok = embedded_sup:stop_listener(SupPid, {misc_info_embedded, act}), timer:sleep(500), - [{{misc_info_embedded, ssl}, _}] = - do_get_listener_info(misc_info_embedded), + false = maps:is_key({misc_info_embedded, act}, ranch:info()), %% Stop embedded ssl listener and ensure it is gone. ok = embedded_sup:stop_listener(SupPid, {misc_info_embedded, ssl}), timer:sleep(500), - [] = do_get_listener_info(misc_info_embedded), + false = maps:is_key({misc_info_embedded, ssl}, ranch:info()), %% Stop embedded supervisor. embedded_sup:stop(SupPid), ok. -do_get_listener_info(ListenerGroup) -> - lists:sort([L || L={{G, _}, _} <- ranch:info(), G=:=ListenerGroup]). - misc_opts_logger(_) -> doc("Confirm that messages are sent via the configured logger module."), register(misc_opts_logger, self()), |