aboutsummaryrefslogtreecommitdiffstats
path: root/test/loop_handler_SUITE.erl
diff options
context:
space:
mode:
Diffstat (limited to 'test/loop_handler_SUITE.erl')
-rw-r--r--test/loop_handler_SUITE.erl36
1 files changed, 32 insertions, 4 deletions
diff --git a/test/loop_handler_SUITE.erl b/test/loop_handler_SUITE.erl
index a7b5303..c5daaf8 100644
--- a/test/loop_handler_SUITE.erl
+++ b/test/loop_handler_SUITE.erl
@@ -1,4 +1,4 @@
-%% Copyright (c) 2011-2017, Loïc Hoguin <[email protected]>
+%% Copyright (c) 2011-2024, Loïc Hoguin <[email protected]>
%%
%% Permission to use, copy, modify, and/or distribute this software for any
%% purpose with or without fee is hereby granted, provided that the above
@@ -32,7 +32,7 @@ init_per_group(Name, Config) ->
cowboy_test:init_common_groups(Name, Config, ?MODULE).
end_per_group(Name, _) ->
- cowboy:stop_listener(Name).
+ cowboy_test:stop_group(Name).
%% Dispatch configuration.
@@ -40,7 +40,10 @@ init_dispatch(_) ->
cowboy_router:compile([{'_', [
{"/long_polling", long_polling_h, []},
{"/loop_body", loop_handler_body_h, []},
- {"/loop_timeout", loop_handler_timeout_h, []}
+ {"/loop_request_timeout", loop_handler_timeout_h, []},
+ {"/loop_timeout_init", loop_handler_timeout_init_h, []},
+ {"/loop_timeout_info", loop_handler_timeout_info_h, []},
+ {"/loop_timeout_hibernate", loop_handler_timeout_hibernate_h, []}
]}]).
%% Tests.
@@ -79,6 +82,31 @@ long_polling_pipeline(Config) ->
request_timeout(Config) ->
doc("Ensure that the request_timeout isn't applied when a request is ongoing."),
ConnPid = gun_open(Config),
- Ref = gun:get(ConnPid, "/loop_timeout", [{<<"accept-encoding">>, <<"gzip">>}]),
+ Ref = gun:get(ConnPid, "/loop_request_timeout", [{<<"accept-encoding">>, <<"gzip">>}]),
{response, nofin, 200, _} = gun:await(ConnPid, Ref, 10000),
ok.
+
+timeout_hibernate(Config) ->
+ doc("Ensure that loop handler idle timeouts don't trigger after hibernate is returned."),
+ ConnPid = gun_open(Config),
+ Ref = gun:get(ConnPid, "/loop_timeout_hibernate", [{<<"accept-encoding">>, <<"gzip">>}]),
+ {response, fin, 200, _} = gun:await(ConnPid, Ref),
+ ok.
+
+timeout_info(Config) ->
+ doc("Ensure that loop handler idle timeouts trigger on time when set in info/3."),
+ ConnPid = gun_open(Config),
+ Ref = gun:get(ConnPid, "/loop_timeout_info", [{<<"accept-encoding">>, <<"gzip">>}]),
+ {response, fin, 299, _} = gun:await(ConnPid, Ref),
+ ok.
+
+timeout_init(Config) ->
+ doc("Ensure that loop handler idle timeouts trigger on time when set in init/2."),
+ ConnPid = gun_open(Config),
+ Ref = gun:get(ConnPid, "/loop_timeout_init?timeout=1000",
+ [{<<"accept-encoding">>, <<"gzip">>}]),
+ {response, fin, 200, _} = gun:await(ConnPid, Ref),
+ Ref2 = gun:get(ConnPid, "/loop_timeout_init?timeout=100",
+ [{<<"accept-encoding">>, <<"gzip">>}]),
+ {response, fin, 299, _} = gun:await(ConnPid, Ref2),
+ ok.