aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLoïc Hoguin <[email protected]>2020-04-16 19:48:43 +0200
committerLoïc Hoguin <[email protected]>2020-04-16 19:48:43 +0200
commitc8dc7d2da7b40226a73584feed307467d74edbf8 (patch)
tree915e722de8a86636c246cd60639e434c2c19b029
parentff64a5a66a3acf85b3f21b1bf7b29c9627e6b82a (diff)
downloadgun-c8dc7d2da7b40226a73584feed307467d74edbf8.tar.gz
gun-c8dc7d2da7b40226a73584feed307467d74edbf8.tar.bz2
gun-c8dc7d2da7b40226a73584feed307467d74edbf8.zip
Fix the gun_SUITE:shutdown_reason intermittent errors
Depending on timing the monitor may be applied after the Gun process has started and stopped. In that case we run the test again until timetrap_timeout.
-rw-r--r--test/gun_SUITE.erl9
1 files changed, 9 insertions, 0 deletions
diff --git a/test/gun_SUITE.erl b/test/gun_SUITE.erl
index 2febe2b..2b41d3a 100644
--- a/test/gun_SUITE.erl
+++ b/test/gun_SUITE.erl
@@ -433,6 +433,9 @@ set_owner(_) ->
shutdown_reason(_) ->
doc("The last connection failure must be propagated."),
+ do_shutdown_reason().
+
+do_shutdown_reason() ->
%% We set retry=1 so that we can monitor before the process terminates.
{ok, ConnPid} = gun:open("localhost", 12345, #{
retry => 1,
@@ -440,6 +443,12 @@ shutdown_reason(_) ->
}),
Ref = monitor(process, ConnPid),
receive
+ %% Depending on timings we may monitor AFTER the process already
+ %% failed to connect and exited. In that case we just try again.
+ %% We rely on timetrap_timeout to stop the test if it takes too long.
+ {'DOWN', Ref, process, ConnPid, noproc} ->
+ ct:log("Monitor got noproc, trying again..."),
+ do_shutdown_reason();
{'DOWN', Ref, process, ConnPid, Reason} ->
{shutdown, econnrefused} = Reason,
gun:close(ConnPid)