diff options
author | Loïc Hoguin <[email protected]> | 2020-04-16 19:48:43 +0200 |
---|---|---|
committer | Loïc Hoguin <[email protected]> | 2020-04-16 19:48:43 +0200 |
commit | c8dc7d2da7b40226a73584feed307467d74edbf8 (patch) | |
tree | 915e722de8a86636c246cd60639e434c2c19b029 /test | |
parent | ff64a5a66a3acf85b3f21b1bf7b29c9627e6b82a (diff) | |
download | gun-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.
Diffstat (limited to 'test')
-rw-r--r-- | test/gun_SUITE.erl | 9 |
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) |