diff options
Diffstat (limited to 'test')
-rw-r--r-- | test/acceptor_SUITE.erl | 25 | ||||
-rw-r--r-- | test/active_echo_protocol.erl | 8 | ||||
-rw-r--r-- | test/echo_protocol.erl | 8 | ||||
-rw-r--r-- | test/remove_conn_and_wait_protocol.erl | 10 |
4 files changed, 25 insertions, 26 deletions
diff --git a/test/acceptor_SUITE.erl b/test/acceptor_SUITE.erl index d6084fd..db9d4ff 100644 --- a/test/acceptor_SUITE.erl +++ b/test/acceptor_SUITE.erl @@ -266,9 +266,9 @@ tcp_max_connections_and_beyond(_) -> receive after 250 -> ok end, 0 = ranch_server:count_connections(Name), 10 = length(supervisor:which_children( - ranch_server:lookup_connections_sup(Name))), + ranch_server:get_connections_sup(Name))), Counts = supervisor:count_children( - ranch_server:lookup_connections_sup(Name)), + ranch_server:get_connections_sup(Name)), {_, 1} = lists:keyfind(specs, 1, Counts), {_, 0} = lists:keyfind(supervisors, 1, Counts), {_, 10} = lists:keyfind(active, 1, Counts), @@ -279,9 +279,9 @@ tcp_max_connections_and_beyond(_) -> receive after 250 -> ok end, 10 = ranch_server:count_connections(Name), 20 = length(supervisor:which_children( - ranch_server:lookup_connections_sup(Name))), + ranch_server:get_connections_sup(Name))), Counts2 = supervisor:count_children( - ranch_server:lookup_connections_sup(Name)), + ranch_server:get_connections_sup(Name)), {_, 20} = lists:keyfind(active, 1, Counts2), {_, 20} = lists:keyfind(workers, 1, Counts2), ranch:stop_listener(Name). @@ -346,16 +346,15 @@ supervisor_clean_restart(_) -> NbAcc, ranch_tcp, [{port, 0}], echo_protocol, []), %% Trace supervisor spawns. 1 = erlang:trace(Pid, true, [procs, set_on_spawn]), - ListenerPid0 = ranch_server:lookup_listener(Name), - erlang:exit(ListenerPid0, kill), + ConnsSup0 = ranch_server:get_connections_sup(Name), + erlang:exit(ConnsSup0, kill), receive after 1000 -> ok end, %% Verify that supervisor is alive true = is_process_alive(Pid), %% ...but children are dead. - false = is_process_alive(ListenerPid0), + false = is_process_alive(ConnsSup0), %% Receive traces from newly started children - ListenerPid = receive {trace, Pid, spawn, Pid1, _} -> Pid1 end, - _ConnSupPid = receive {trace, Pid, spawn, Pid2, _} -> Pid2 end, + ConnsSup = receive {trace, Pid, spawn, Pid2, _} -> Pid2 end, AccSupPid = receive {trace, Pid, spawn, Pid3, _} -> Pid3 end, %% ...and its acceptors. [receive {trace, AccSupPid, spawn, _Pid, _} -> ok end || @@ -366,7 +365,7 @@ supervisor_clean_restart(_) -> error(invalid_restart) after 1000 -> ok end, %% Verify that new children registered themselves properly. - ListenerPid = ranch_server:lookup_listener(Name), + ConnsSup = ranch_server:get_connections_sup(Name), _ = erlang:trace(all, false, [all]), ok = clean_traces(), ranch:stop_listener(Name). @@ -383,7 +382,7 @@ supervisor_clean_child_restart(_) -> 1, ranch_tcp, [{port, 0}], echo_protocol, []), %% Trace supervisor spawns. 1 = erlang:trace(Pid, true, [procs, set_on_spawn]), - ListenerPid = ranch_server:lookup_listener(Name), + ConnsSup = ranch_server:get_connections_sup(Name), %% Manually shut the listening socket down. LSocket = receive {trace, _, return_from, {ranch_tcp, listen, 1}, {ok, Socket}} -> @@ -395,7 +394,7 @@ supervisor_clean_child_restart(_) -> receive after 1000 -> ok end, %% Verify that supervisor and its first two children are alive. true = is_process_alive(Pid), - true = is_process_alive(ListenerPid), + true = is_process_alive(ConnsSup), %% Check that acceptors_sup is restarted properly. AccSupPid = receive {trace, Pid, spawn, Pid1, _} -> Pid1 end, receive {trace, AccSupPid, spawn, _, _} -> ok end, @@ -404,7 +403,7 @@ supervisor_clean_child_restart(_) -> {trace, _, spawn, _, _} -> error(invalid_restart) after 1000 -> ok end, %% Verify that children still registered right. - ListenerPid = ranch_server:lookup_listener(Name), + ConnsSup = ranch_server:get_connections_sup(Name), _ = erlang:trace_pattern({ranch_tcp, listen, 1}, false, []), _ = erlang:trace(all, false, [all]), ok = clean_traces(), diff --git a/test/active_echo_protocol.erl b/test/active_echo_protocol.erl index 875bdd2..6767141 100644 --- a/test/active_echo_protocol.erl +++ b/test/active_echo_protocol.erl @@ -4,12 +4,12 @@ -export([start_link/4]). -export([init/4]). -start_link(ListenerPid, Socket, Transport, Opts) -> - Pid = spawn_link(?MODULE, init, [ListenerPid, Socket, Transport, Opts]), +start_link(Ref, Socket, Transport, Opts) -> + Pid = spawn_link(?MODULE, init, [Ref, Socket, Transport, Opts]), {ok, Pid}. -init(ListenerPid, Socket, Transport, _Opts = []) -> - ok = ranch:accept_ack(ListenerPid), +init(Ref, Socket, Transport, _Opts = []) -> + ok = ranch:accept_ack(Ref), loop(Socket, Transport). loop(Socket, Transport) -> diff --git a/test/echo_protocol.erl b/test/echo_protocol.erl index 54507d2..8c454bc 100644 --- a/test/echo_protocol.erl +++ b/test/echo_protocol.erl @@ -4,12 +4,12 @@ -export([start_link/4]). -export([init/4]). -start_link(ListenerPid, Socket, Transport, Opts) -> - Pid = spawn_link(?MODULE, init, [ListenerPid, Socket, Transport, Opts]), +start_link(Ref, Socket, Transport, Opts) -> + Pid = spawn_link(?MODULE, init, [Ref, Socket, Transport, Opts]), {ok, Pid}. -init(ListenerPid, Socket, Transport, _Opts = []) -> - ok = ranch:accept_ack(ListenerPid), +init(Ref, Socket, Transport, _Opts = []) -> + ok = ranch:accept_ack(Ref), loop(Socket, Transport). loop(Socket, Transport) -> diff --git a/test/remove_conn_and_wait_protocol.erl b/test/remove_conn_and_wait_protocol.erl index 6a5b52a..6c8206c 100644 --- a/test/remove_conn_and_wait_protocol.erl +++ b/test/remove_conn_and_wait_protocol.erl @@ -4,15 +4,15 @@ -export([start_link/4]). -export([init/2]). -start_link(ListenerPid, _, _, [{remove, MaybeRemove}]) -> - Pid = spawn_link(?MODULE, init, [ListenerPid, MaybeRemove]), +start_link(Ref, _, _, [{remove, MaybeRemove}]) -> + Pid = spawn_link(?MODULE, init, [Ref, MaybeRemove]), {ok, Pid}. -init(ListenerPid, MaybeRemove) -> - ranch:accept_ack(ListenerPid), +init(Ref, MaybeRemove) -> + ranch:accept_ack(Ref), case MaybeRemove of true -> - ranch_listener:remove_connection(ListenerPid); + ranch:remove_connection(Ref); false -> ok end, |