aboutsummaryrefslogtreecommitdiffstats
path: root/test/http_SUITE.erl
diff options
context:
space:
mode:
authorLoïc Hoguin <[email protected]>2018-05-17 17:41:55 +0200
committerLoïc Hoguin <[email protected]>2018-05-17 17:41:55 +0200
commit0254c80c334b6fce03bb971d0323f97cdba20b13 (patch)
tree1d3ccd3ab3c504bc46974a368c416adf5ee9c78b /test/http_SUITE.erl
parentfd2643b01793bae4d361ba47039639f60f606a0b (diff)
downloadcowboy-0254c80c334b6fce03bb971d0323f97cdba20b13.tar.gz
cowboy-0254c80c334b6fce03bb971d0323f97cdba20b13.tar.bz2
cowboy-0254c80c334b6fce03bb971d0323f97cdba20b13.zip
Move timeout tests from old_http_SUITE to http_SUITE
Also fix the idle_timeout test which was producing an extra crash log.
Diffstat (limited to 'test/http_SUITE.erl')
-rw-r--r--test/http_SUITE.erl37
1 files changed, 36 insertions, 1 deletions
diff --git a/test/http_SUITE.erl b/test/http_SUITE.erl
index 16d7e76..dbcfd2b 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, [name/0]).
-import(cowboy_test, [gun_open/1]).
all() -> [{group, clear}].
@@ -26,10 +27,44 @@ groups() -> [{clear, [parallel], ct_helper:all(?MODULE)}].
init_routes(_) -> [
{"localhost", [
- {"/", hello_h, []}
+ {"/", hello_h, []},
+ {"/echo/:key", echo_h, []}
]}
].
+idle_timeout_infinity(Config) ->
+ doc("Ensure the idle_timeout option accepts the infinity value."),
+ {ok, ListenerPid} = 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">>),
+ receive
+ {'DOWN', Ref, process, ListenerPid, Reason} ->
+ error(Reason)
+ after 1000 ->
+ ok
+ end.
+
+request_timeout_infinity(Config) ->
+ doc("Ensure the request_timeout option accepts the infinity value."),
+ {ok, ListenerPid} = 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]),
+ receive
+ {'DOWN', Ref, process, ListenerPid, Reason} ->
+ error(Reason)
+ after 1000 ->
+ ok
+ end.
+
switch_protocol_flush(Config) ->
doc("Confirm that switch_protocol does not flush unrelated messages."),
ProtoOpts = #{