aboutsummaryrefslogtreecommitdiffstats
path: root/test/gun_SUITE.erl
diff options
context:
space:
mode:
authorLoïc Hoguin <[email protected]>2019-01-05 11:53:31 +0100
committerLoïc Hoguin <[email protected]>2019-01-05 11:53:31 +0100
commit4bd87ba7d1699fc1b2901cd61b703429f1deff63 (patch)
treea24fe6638cbabc1a675f8f4df0ccd70ab5c0cbff /test/gun_SUITE.erl
parentc2ba3ff0999f523b665dc0dbf100ed634bd1d6af (diff)
downloadgun-4bd87ba7d1699fc1b2901cd61b703429f1deff63.tar.gz
gun-4bd87ba7d1699fc1b2901cd61b703429f1deff63.tar.bz2
gun-4bd87ba7d1699fc1b2901cd61b703429f1deff63.zip
Ensure Gun retries connecting immediately
Diffstat (limited to 'test/gun_SUITE.erl')
-rw-r--r--test/gun_SUITE.erl17
1 files changed, 17 insertions, 0 deletions
diff --git a/test/gun_SUITE.erl b/test/gun_SUITE.erl
index cb2c262..a7bb0f1 100644
--- a/test/gun_SUITE.erl
+++ b/test/gun_SUITE.erl
@@ -18,6 +18,7 @@
-import(ct_helper, [doc/1]).
-import(ct_helper, [name/0]).
+-import(gun_test, [init_origin/3]).
all() ->
ct_helper:all(?MODULE).
@@ -227,6 +228,22 @@ retry_1(_) ->
error(timeout)
end.
+retry_immediately(_) ->
+ doc("Ensure Gun retries immediately."),
+ %% We have to make a first successful connection in order to test this.
+ {ok, _, OriginPort} = init_origin(tcp, http,
+ fun(_, ClientSocket, ClientTransport) ->
+ ClientTransport:close(ClientSocket)
+ end),
+ {ok, Pid} = gun:open("localhost", OriginPort, #{retry => 1, retry_timeout => 500}),
+ Ref = monitor(process, Pid),
+ receive
+ {'DOWN', Ref, process, Pid, {shutdown, _}} ->
+ ok
+ after 200 ->
+ error(timeout)
+ end.
+
retry_timeout(_) ->
doc("Ensure the retry_timeout value is enforced."),
{ok, Pid} = gun:open("localhost", 12345, #{retry => 1, retry_timeout => 1000}),