diff options
author | Loïc Hoguin <[email protected]> | 2015-08-20 14:28:16 +0200 |
---|---|---|
committer | Loïc Hoguin <[email protected]> | 2015-08-20 14:28:16 +0200 |
commit | c867ec582d445b251ff659ba23f522b5278d5119 (patch) | |
tree | 50efcb176bc97207ed06a536acd2f7c56db9db98 /test/acceptor_SUITE.erl | |
parent | 32e4ebef2ce16b2b1fce2a4af7bb2bd7ef17f235 (diff) | |
download | ranch-c867ec582d445b251ff659ba23f522b5278d5119.tar.gz ranch-c867ec582d445b251ff659ba23f522b5278d5119.tar.bz2 ranch-c867ec582d445b251ff659ba23f522b5278d5119.zip |
Add tests and more docs about separate supervisor/connection
Diffstat (limited to 'test/acceptor_SUITE.erl')
-rw-r--r-- | test/acceptor_SUITE.erl | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/test/acceptor_SUITE.erl b/test/acceptor_SUITE.erl index 07d4016..af1ea5e 100644 --- a/test/acceptor_SUITE.erl +++ b/test/acceptor_SUITE.erl @@ -42,6 +42,8 @@ groups() -> ]}, {misc, [ misc_bad_transport ]}, {supervisor, [ + connection_type_supervisor, + connection_type_supervisor_separate_from_connection, supervisor_clean_child_restart, supervisor_clean_conns_sup_restart, supervisor_clean_restart, @@ -298,6 +300,42 @@ tcp_upgrade(_) -> %% Supervisor tests +connection_type_supervisor(_) -> + doc("The supervisor connection type must be reflected in the specifications."), + Name = connection_type_supervisor, + {ok, _} = ranch:start_listener(Name, 1, + ranch_tcp, [{connection_type, supervisor}], + echo_protocol, []), + Port = ranch:get_port(Name), + {ok, Socket} = gen_tcp:connect("localhost", Port, [binary, {active, false}, {packet, raw}]), + ok = gen_tcp:send(Socket, <<"TCP Ranch is working!">>), + {ok, <<"TCP Ranch is working!">>} = gen_tcp:recv(Socket, 21, 1000), + ConnsSup = ranch_server:get_connections_sup(Name), + [{echo_protocol, _, supervisor, [echo_protocol]}] = supervisor:which_children(ConnsSup), + ok = ranch:stop_listener(Name), + {error, closed} = gen_tcp:recv(Socket, 0, 1000), + %% Make sure the listener stopped. + {'EXIT', _} = begin catch ranch:get_port(Name) end, + ok. + +connection_type_supervisor_separate_from_connection(_) -> + doc("The supervisor connection type allows separate supervised and connection processes."), + Name = connection_type_supervisor, + {ok, _} = ranch:start_listener(Name, 1, + ranch_tcp, [{connection_type, supervisor}], + supervisor_separate, []), + Port = ranch:get_port(Name), + {ok, Socket} = gen_tcp:connect("localhost", Port, [binary, {active, false}, {packet, raw}]), + ok = gen_tcp:send(Socket, <<"TCP Ranch is working!">>), + {ok, <<"TCP Ranch is working!">>} = gen_tcp:recv(Socket, 21, 1000), + ConnsSup = ranch_server:get_connections_sup(Name), + [{supervisor_separate, _, supervisor, [supervisor_separate]}] = supervisor:which_children(ConnsSup), + ok = ranch:stop_listener(Name), + {error, closed} = gen_tcp:recv(Socket, 0, 1000), + %% Make sure the listener stopped. + {'EXIT', _} = begin catch ranch:get_port(Name) end, + ok. + supervisor_clean_child_restart(_) -> %% Then we verify that only parts of the supervision tree %% restarted in the case of failure. |