aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorjuhlig <[email protected]>2019-06-03 09:47:31 +0200
committerjuhlig <[email protected]>2019-06-03 09:47:31 +0200
commit8436e96544d79a5b5d32221925f60334cc33b205 (patch)
treeaa5a85fd8abcad711dd80d935afe38161b878e8c
parent30604262b5934b38e9f55f0d3ef44f8aed5310de (diff)
downloadranch-8436e96544d79a5b5d32221925f60334cc33b205.tar.gz
ranch-8436e96544d79a5b5d32221925f60334cc33b205.tar.bz2
ranch-8436e96544d79a5b5d32221925f60334cc33b205.zip
Fix many conns_sups tests for Windows
-rw-r--r--test/acceptor_SUITE.erl14
-rw-r--r--test/notify_and_wait_protocol.erl11
2 files changed, 13 insertions, 12 deletions
diff --git a/test/acceptor_SUITE.erl b/test/acceptor_SUITE.erl
index bc4f3f0..0267ff4 100644
--- a/test/acceptor_SUITE.erl
+++ b/test/acceptor_SUITE.erl
@@ -916,7 +916,7 @@ tcp_max_connections(_) ->
Name = name(),
{ok, _} = ranch:start_listener(Name,
ranch_tcp, #{max_connections => 10, num_acceptors => 1},
- notify_and_wait_protocol, [{msg, connected}, {pid, self()}]),
+ notify_and_wait_protocol, #{msg => connected, pid => self()}),
Port = ranch:get_port(Name),
ok = connect_loop(Port, 11, 150),
10 = ranch_server:count_connections(Name),
@@ -956,7 +956,7 @@ tcp_max_connections_infinity(_) ->
Name = name(),
{ok, _} = ranch:start_listener(Name,
ranch_tcp, #{max_connections => 10, num_acceptors => 1},
- notify_and_wait_protocol, [{msg, connected}, {pid, self()}]),
+ notify_and_wait_protocol, #{msg => connected, pid => self()}),
Port = ranch:get_port(Name),
ok = connect_loop(Port, 20, 0),
10 = ranch_server:count_connections(Name),
@@ -989,7 +989,7 @@ tcp_set_max_connections(_) ->
Name = name(),
{ok, _} = ranch:start_listener(Name,
ranch_tcp, #{max_connections => 10, num_acceptors => 1},
- notify_and_wait_protocol, [{msg, connected}, {pid, self()}]),
+ notify_and_wait_protocol, #{msg => connected, pid => self()}),
Port = ranch:get_port(Name),
ok = connect_loop(Port, 20, 0),
10 = ranch_server:count_connections(Name),
@@ -1011,7 +1011,7 @@ do_tcp_set_max_connections_clean(_) ->
Name = name(),
{ok, ListSupPid} = ranch:start_listener(Name,
ranch_tcp, #{max_connections => 4},
- notify_and_wait_protocol, [{msg, connected}, {pid, self()}]),
+ notify_and_wait_protocol, #{msg => connected, pid => self()}),
Children = supervisor:which_children(ListSupPid),
{_, AccSupPid, _, _} = lists:keyfind(ranch_acceptors_sup, 1, Children),
1 = erlang:trace(ListSupPid, true, [procs]),
@@ -1069,11 +1069,11 @@ tcp_upgrade(_) ->
Name = name(),
{ok, _} = ranch:start_listener(Name,
ranch_tcp, #{},
- notify_and_wait_protocol, [{msg, connected}, {pid, self()}]),
+ notify_and_wait_protocol, #{msg => connected, pid => self()}),
Port = ranch:get_port(Name),
ok = connect_loop(Port, 1, 0),
receive connected -> ok after 1000 -> error(timeout) end,
- ranch:set_protocol_options(Name, [{msg, upgraded}, {pid, self()}]),
+ ranch:set_protocol_options(Name, #{msg => upgraded, pid => self()}),
ok = connect_loop(Port, 1, 0),
receive upgraded -> ok after 1000 -> error(timeout) end,
ok = ranch:stop_listener(Name).
@@ -1162,7 +1162,7 @@ do_supervisor_n_acceptors_m_conns_sups(NumAcceptors, NumConnsSups) ->
Name = name(),
{ok, Pid} = ranch:start_listener(Name,
ranch_tcp, #{num_conns_sups => NumConnsSups, num_acceptors => NumAcceptors},
- notify_and_wait_protocol, [{msg, connected}, {pid, self()}]),
+ notify_and_wait_protocol, #{msg => connected, pid => self(), timeout => 10000}),
Port = ranch:get_port(Name),
ConnsSups = [ConnsSup || {_, ConnsSup} <- ranch_server:get_connections_sups(Name)],
NumConnsSups = length(ConnsSups),
diff --git a/test/notify_and_wait_protocol.erl b/test/notify_and_wait_protocol.erl
index e3e857b..37d0f42 100644
--- a/test/notify_and_wait_protocol.erl
+++ b/test/notify_and_wait_protocol.erl
@@ -2,12 +2,13 @@
-behaviour(ranch_protocol).
-export([start_link/3]).
--export([init/2]).
+-export([init/3]).
-start_link(_, _, [{msg, Msg}, {pid, TestPid}]) ->
- Pid = spawn_link(?MODULE, init, [Msg, TestPid]),
+start_link(_, _, Opts = #{msg := Msg, pid := TestPid}) ->
+ Timeout = maps:get(timeout, Opts, 2500),
+ Pid = spawn_link(?MODULE, init, [Msg, TestPid, Timeout]),
{ok, Pid}.
-init(Msg, Pid) ->
+init(Msg, Pid, Timeout) ->
Pid ! Msg,
- receive after 2500 -> ok end.
+ receive after Timeout -> ok end.