aboutsummaryrefslogtreecommitdiffstats
path: root/test/http_SUITE.erl
diff options
context:
space:
mode:
authorLoïc Hoguin <[email protected]>2018-08-13 11:09:24 +0200
committerLoïc Hoguin <[email protected]>2018-08-13 11:10:49 +0200
commitef426e0ff460b5d3f1b119f7b27ab1bdb5a24511 (patch)
tree01c1049f8dde9ee8bfdfb80ffdcfdcfea769e679 /test/http_SUITE.erl
parentb0774f7069874cb1df38f955ec00b553f9628b84 (diff)
downloadcowboy-ef426e0ff460b5d3f1b119f7b27ab1bdb5a24511.tar.gz
cowboy-ef426e0ff460b5d3f1b119f7b27ab1bdb5a24511.tar.bz2
cowboy-ef426e0ff460b5d3f1b119f7b27ab1bdb5a24511.zip
Fix the infinity timeout tests
Make sure the test fails when the code is incorrect.
Diffstat (limited to 'test/http_SUITE.erl')
-rw-r--r--test/http_SUITE.erl21
1 files changed, 14 insertions, 7 deletions
diff --git a/test/http_SUITE.erl b/test/http_SUITE.erl
index dbcfd2b..f4cf91c 100644
--- a/test/http_SUITE.erl
+++ b/test/http_SUITE.erl
@@ -18,6 +18,7 @@
-import(ct_helper, [config/2]).
-import(ct_helper, [doc/1]).
+-import(ct_helper, [get_remote_pid_tcp/1]).
-import(ct_helper, [name/0]).
-import(cowboy_test, [gun_open/1]).
@@ -34,16 +35,19 @@ init_routes(_) -> [
idle_timeout_infinity(Config) ->
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))},
request_timeout => infinity
}),
Port = ranch:get_port(name()),
- Ref = erlang:monitor(process, ListenerPid),
ConnPid = gun_open([{type, tcp}, {protocol, http}, {port, Port}|Config]),
_ = 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
- {'DOWN', Ref, process, ListenerPid, Reason} ->
+ {'DOWN', Ref, process, Pid, Reason} ->
error(Reason)
after 1000 ->
ok
@@ -51,15 +55,18 @@ idle_timeout_infinity(Config) ->
request_timeout_infinity(Config) ->
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))},
idle_timeout => infinity
}),
Port = ranch:get_port(name()),
- Ref = erlang:monitor(process, ListenerPid),
- _ = gun_open([{type, tcp}, {protocol, http}, {port, Port}|Config]),
+ ConnPid = 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
- {'DOWN', Ref, process, ListenerPid, Reason} ->
+ {'DOWN', Ref, process, Pid, Reason} ->
error(Reason)
after 1000 ->
ok