From c1c9341255bdd6664e4c69093cc2e84d7dc43bb9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lo=C3=AFc=20Hoguin?= Date: Mon, 23 Mar 2020 16:41:02 +0100 Subject: 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. --- test/gun_SUITE.erl | 32 ++++++++++++++++---------------- test/shutdown_SUITE.erl | 4 ++-- 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). -- cgit v1.2.3