aboutsummaryrefslogtreecommitdiffstats
path: root/test/gun_SUITE.erl
diff options
context:
space:
mode:
authorLoïc Hoguin <[email protected]>2019-07-27 16:42:00 +0200
committerLoïc Hoguin <[email protected]>2019-07-27 16:42:00 +0200
commit50ff97bf82cd146cb289e5b9fbd864bbcc9c30d9 (patch)
tree5c2afd3d9a1c96868dbfc3cc0456422607d68f94 /test/gun_SUITE.erl
parent02fed8a1422c9ca6f33127509eebd244f0a74d3f (diff)
downloadgun-50ff97bf82cd146cb289e5b9fbd864bbcc9c30d9.tar.gz
gun-50ff97bf82cd146cb289e5b9fbd864bbcc9c30d9.tar.bz2
gun-50ff97bf82cd146cb289e5b9fbd864bbcc9c30d9.zip
Add the retry_fun option for different backoff strategies
Diffstat (limited to 'test/gun_SUITE.erl')
-rw-r--r--test/gun_SUITE.erl21
1 files changed, 20 insertions, 1 deletions
diff --git a/test/gun_SUITE.erl b/test/gun_SUITE.erl
index 4f99594..4526a15 100644
--- a/test/gun_SUITE.erl
+++ b/test/gun_SUITE.erl
@@ -289,7 +289,7 @@ postpone_request_while_not_connected(_) ->
end,
timer:sleep(Timeout),
%% Start the server so that next retry will result in the client connecting successfully.
- {ok, ListenSocket} = gen_tcp:listen(23456, [binary, {active, false}]),
+ {ok, ListenSocket} = gen_tcp:listen(23456, [binary, {active, false}, {reuseaddr, true}]),
{ok, ClientSocket} = gen_tcp:accept(ListenSocket, 5000),
%% The client should now be up.
{ok, http} = gun:await_up(Pid),
@@ -395,6 +395,25 @@ retry_1(_) ->
error(timeout)
end.
+retry_fun(_) ->
+ doc("Ensure the retry_fun is used when provided."),
+ {ok, Pid} = gun:open("localhost", 12345, #{
+ retry => 5,
+ retry_fun => fun(_, _) -> #{retries => 0, timeout => 500} end,
+ retry_timeout => 5000
+ }),
+ Ref = monitor(process, Pid),
+ After = case os:type() of
+ {win32, _} -> 2800;
+ _ -> 800
+ end,
+ receive
+ {'DOWN', Ref, process, Pid, {shutdown, _}} ->
+ ok
+ after After ->
+ error(shutdown_too_late)
+ end.
+
retry_immediately(_) ->
doc("Ensure Gun retries immediately."),
%% We have to make a first successful connection in order to test this.