mirror of
https://github.com/ninenines/cowboy.git
synced 2025-07-14 20:30:23 +00:00
Fix the infinity timeout tests
Make sure the test fails when the code is incorrect.
This commit is contained in:
parent
b0774f7069
commit
ef426e0ff4
2 changed files with 23 additions and 13 deletions
|
@ -18,6 +18,7 @@
|
||||||
|
|
||||||
-import(ct_helper, [config/2]).
|
-import(ct_helper, [config/2]).
|
||||||
-import(ct_helper, [doc/1]).
|
-import(ct_helper, [doc/1]).
|
||||||
|
-import(ct_helper, [get_remote_pid_tcp/1]).
|
||||||
-import(ct_helper, [name/0]).
|
-import(ct_helper, [name/0]).
|
||||||
-import(cowboy_test, [gun_open/1]).
|
-import(cowboy_test, [gun_open/1]).
|
||||||
|
|
||||||
|
@ -131,10 +132,11 @@ preface_timeout_infinity(Config) ->
|
||||||
env => #{dispatch => cowboy_router:compile(init_routes(Config))},
|
env => #{dispatch => cowboy_router:compile(init_routes(Config))},
|
||||||
preface_timeout => infinity
|
preface_timeout => infinity
|
||||||
},
|
},
|
||||||
{ok, Pid} = cowboy:start_clear(name(), [{port, 0}], ProtoOpts),
|
{ok, _} = cowboy:start_clear(name(), [{port, 0}], ProtoOpts),
|
||||||
Ref = erlang:monitor(process, Pid),
|
|
||||||
Port = ranch:get_port(name()),
|
Port = ranch:get_port(name()),
|
||||||
{ok, _} = do_handshake([{port, Port}|Config]),
|
{ok, Socket} = do_handshake([{port, Port}|Config]),
|
||||||
|
Pid = get_remote_pid_tcp(Socket),
|
||||||
|
Ref = erlang:monitor(process, Pid),
|
||||||
receive
|
receive
|
||||||
{'DOWN', Ref, process, Pid, Reason} ->
|
{'DOWN', Ref, process, Pid, Reason} ->
|
||||||
error(Reason)
|
error(Reason)
|
||||||
|
@ -166,10 +168,11 @@ settings_timeout_infinity(Config) ->
|
||||||
env => #{dispatch => cowboy_router:compile(init_routes(Config))},
|
env => #{dispatch => cowboy_router:compile(init_routes(Config))},
|
||||||
settings_timeout => infinity
|
settings_timeout => infinity
|
||||||
},
|
},
|
||||||
{ok, Pid} = cowboy:start_clear(name(), [{port, 0}], ProtoOpts),
|
{ok, _} = cowboy:start_clear(name(), [{port, 0}], ProtoOpts),
|
||||||
Ref = erlang:monitor(process, Pid),
|
|
||||||
Port = ranch:get_port(name()),
|
Port = ranch:get_port(name()),
|
||||||
{ok, _} = do_handshake([{port, Port}|Config]),
|
{ok, Socket} = do_handshake([{port, Port}|Config]),
|
||||||
|
Pid = get_remote_pid_tcp(Socket),
|
||||||
|
Ref = erlang:monitor(process, Pid),
|
||||||
receive
|
receive
|
||||||
{'DOWN', Ref, process, Pid, Reason} ->
|
{'DOWN', Ref, process, Pid, Reason} ->
|
||||||
error(Reason)
|
error(Reason)
|
||||||
|
|
|
@ -18,6 +18,7 @@
|
||||||
|
|
||||||
-import(ct_helper, [config/2]).
|
-import(ct_helper, [config/2]).
|
||||||
-import(ct_helper, [doc/1]).
|
-import(ct_helper, [doc/1]).
|
||||||
|
-import(ct_helper, [get_remote_pid_tcp/1]).
|
||||||
-import(ct_helper, [name/0]).
|
-import(ct_helper, [name/0]).
|
||||||
-import(cowboy_test, [gun_open/1]).
|
-import(cowboy_test, [gun_open/1]).
|
||||||
|
|
||||||
|
@ -34,16 +35,19 @@ init_routes(_) -> [
|
||||||
|
|
||||||
idle_timeout_infinity(Config) ->
|
idle_timeout_infinity(Config) ->
|
||||||
doc("Ensure the idle_timeout option accepts the infinity value."),
|
doc("Ensure the idle_timeout option accepts the infinity value."),
|
||||||
{ok, ListenerPid} = cowboy:start_clear(name(), [{port, 0}], #{
|
{ok, _} = cowboy:start_clear(name(), [{port, 0}], #{
|
||||||
env => #{dispatch => cowboy_router:compile(init_routes(Config))},
|
env => #{dispatch => cowboy_router:compile(init_routes(Config))},
|
||||||
request_timeout => infinity
|
request_timeout => infinity
|
||||||
}),
|
}),
|
||||||
Port = ranch:get_port(name()),
|
Port = ranch:get_port(name()),
|
||||||
Ref = erlang:monitor(process, ListenerPid),
|
|
||||||
ConnPid = gun_open([{type, tcp}, {protocol, http}, {port, Port}|Config]),
|
ConnPid = gun_open([{type, tcp}, {protocol, http}, {port, Port}|Config]),
|
||||||
_ = gun:post(ConnPid, "/echo/read_body", [], <<"TEST">>),
|
_ = gun:post(ConnPid, "/echo/read_body", [], <<"TEST">>),
|
||||||
|
%% @todo Gun should have a debug function to retrieve the socket.
|
||||||
|
Socket = element(9, element(2, sys:get_state(ConnPid))),
|
||||||
|
Pid = get_remote_pid_tcp(Socket),
|
||||||
|
Ref = erlang:monitor(process, Pid),
|
||||||
receive
|
receive
|
||||||
{'DOWN', Ref, process, ListenerPid, Reason} ->
|
{'DOWN', Ref, process, Pid, Reason} ->
|
||||||
error(Reason)
|
error(Reason)
|
||||||
after 1000 ->
|
after 1000 ->
|
||||||
ok
|
ok
|
||||||
|
@ -51,15 +55,18 @@ idle_timeout_infinity(Config) ->
|
||||||
|
|
||||||
request_timeout_infinity(Config) ->
|
request_timeout_infinity(Config) ->
|
||||||
doc("Ensure the request_timeout option accepts the infinity value."),
|
doc("Ensure the request_timeout option accepts the infinity value."),
|
||||||
{ok, ListenerPid} = cowboy:start_clear(name(), [{port, 0}], #{
|
{ok, _} = cowboy:start_clear(name(), [{port, 0}], #{
|
||||||
env => #{dispatch => cowboy_router:compile(init_routes(Config))},
|
env => #{dispatch => cowboy_router:compile(init_routes(Config))},
|
||||||
idle_timeout => infinity
|
idle_timeout => infinity
|
||||||
}),
|
}),
|
||||||
Port = ranch:get_port(name()),
|
Port = ranch:get_port(name()),
|
||||||
Ref = erlang:monitor(process, ListenerPid),
|
ConnPid = gun_open([{type, tcp}, {protocol, http}, {port, Port}|Config]),
|
||||||
_ = gun_open([{type, tcp}, {protocol, http}, {port, Port}|Config]),
|
%% @todo Gun should have a debug function to retrieve the socket.
|
||||||
|
Socket = element(9, element(2, sys:get_state(ConnPid))),
|
||||||
|
Pid = get_remote_pid_tcp(Socket),
|
||||||
|
Ref = erlang:monitor(process, Pid),
|
||||||
receive
|
receive
|
||||||
{'DOWN', Ref, process, ListenerPid, Reason} ->
|
{'DOWN', Ref, process, Pid, Reason} ->
|
||||||
error(Reason)
|
error(Reason)
|
||||||
after 1000 ->
|
after 1000 ->
|
||||||
ok
|
ok
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue