aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLoïc Hoguin <[email protected]>2020-03-23 16:41:02 +0100
committerLoïc Hoguin <[email protected]>2020-03-23 16:41:02 +0100
commitc1c9341255bdd6664e4c69093cc2e84d7dc43bb9 (patch)
tree8c456c0b363004d2769c683407a1c67b26add738
parent5f73982cf9edc258e955e3b115cba1a4c4af263f (diff)
downloadgun-c1c9341255bdd6664e4c69093cc2e84d7dc43bb9.tar.gz
gun-c1c9341255bdd6664e4c69093cc2e84d7dc43bb9.tar.bz2
gun-c1c9341255bdd6664e4c69093cc2e84d7dc43bb9.zip
Tweak connection timeouts tests for Windows
It seems that the retry behavior changed recently. It would be better to retrieve the exact values and calculate how much time we want to wait but that will do for now.
-rw-r--r--test/gun_SUITE.erl32
-rw-r--r--test/shutdown_SUITE.erl4
2 files changed, 18 insertions, 18 deletions
diff --git a/test/gun_SUITE.erl b/test/gun_SUITE.erl
index 2fbbb05..0667cac 100644
--- a/test/gun_SUITE.erl
+++ b/test/gun_SUITE.erl
@@ -28,9 +28,9 @@ all() ->
groups() ->
%% On Windows we sometimes have timeout related failures due to
- %% some operations taking longer on Windows. Best retry a few times.
+ %% some operations taking longer. Best retry a few times.
Props = case os:type() of
- {win32, _} -> [{repeat_until_all_ok, 100}];
+ {win32, _} -> [{repeat_until_all_ok, 10}];
_ -> []
end,
[{gun, [parallel|Props], ct_helper:all(?MODULE)}].
@@ -296,11 +296,11 @@ retry_0(_) ->
{ok, Pid} = gun:open("localhost", 12345, #{retry => 0, retry_timeout => 500}),
Ref = monitor(process, Pid),
%% On Windows when the connection is refused the OS will retry
- %% 3 times before giving up, with a 500ms delay between tries.
- %% This adds approximately 1 second to connection failures.
+ %% a few times before giving up, with a delay between tries.
+ %% This adds time to connection failures.
After = case os:type() of
- {win32, _} -> 1200;
- _ -> 200
+ {win32, _} -> 2300;
+ _ -> 300
end,
receive
{'DOWN', Ref, process, Pid, {shutdown, _}} ->
@@ -316,11 +316,11 @@ retry_0_disconnect(_) ->
{ok, Pid} = gun:open("localhost", Port, #{retry => 0, retry_timeout => 500}),
Ref = monitor(process, Pid),
%% On Windows when the connection is refused the OS will retry
- %% 3 times before giving up, with a 500ms delay between tries.
- %% This adds approximately 1 second to connection failures.
+ %% a few times before giving up, with a delay between tries.
+ %% This adds time to connection failures.
After = case os:type() of
- {win32, _} -> 1200;
- _ -> 200
+ {win32, _} -> 2300;
+ _ -> 300
end,
%% We accept the connection and then close it to trigger a disconnect.
{ok, ClientSocket} = gen_tcp:accept(ListenSocket, 5000),
@@ -337,8 +337,8 @@ retry_1(_) ->
{ok, Pid} = gun:open("localhost", 12345, #{retry => 1, retry_timeout => 500}),
Ref = monitor(process, Pid),
After = case os:type() of
- {win32, _} -> 2700;
- _ -> 700
+ {win32, _} -> 4800;
+ _ -> 800
end,
receive
{'DOWN', Ref, process, Pid, {shutdown, _}} ->
@@ -368,7 +368,7 @@ retry_fun(_) ->
}),
Ref = monitor(process, Pid),
After = case os:type() of
- {win32, _} -> 2800;
+ {win32, _} -> 4800;
_ -> 800
end,
receive
@@ -384,7 +384,7 @@ retry_timeout(_) ->
{ok, Pid} = gun:open("localhost", 12345, #{retry => 2, retry_timeout => 1000}),
Ref = monitor(process, Pid),
After = case os:type() of
- {win32, _} -> 2800;
+ {win32, _} -> 4800;
_ -> 800
end,
receive
@@ -419,8 +419,8 @@ shutdown_reason(_) ->
{ok, Pid} = gun:open("localhost", 12345, #{retry => 0}),
Ref = monitor(process, Pid),
After = case os:type() of
- {win32, _} -> 1200;
- _ -> 200
+ {win32, _} -> 2300;
+ _ -> 300
end,
receive
{'DOWN', Ref, process, Pid, {shutdown, econnrefused}} ->
diff --git a/test/shutdown_SUITE.erl b/test/shutdown_SUITE.erl
index 4cc2566..b7a4c7e 100644
--- a/test/shutdown_SUITE.erl
+++ b/test/shutdown_SUITE.erl
@@ -61,7 +61,7 @@ not_connected_gun_shutdown(_) ->
ConnRef = monitor(process, ConnPid),
gun:shutdown(ConnPid),
Timeout = case os:type() of
- {win32, _} -> 2000;
+ {win32, _} -> 5000;
_ -> 1000
end,
gun_is_down(ConnPid, ConnRef, shutdown, Timeout).
@@ -87,7 +87,7 @@ do_not_connected_owner_down(ExitReason, DownReason) ->
ConnPid = receive {conn, C} -> C after 1000 -> error(timeout) end,
ConnRef = monitor(process, ConnPid),
Timeout = case os:type() of
- {win32, _} -> 2000;
+ {win32, _} -> 5000;
_ -> 1000
end,
gun_is_down(ConnPid, ConnRef, DownReason, Timeout).