aboutsummaryrefslogtreecommitdiffstats
path: root/test/req_SUITE.erl
diff options
context:
space:
mode:
authorLoïc Hoguin <[email protected]>2024-01-18 11:13:51 +0100
committerLoïc Hoguin <[email protected]>2024-01-18 12:15:11 +0100
commit992ee6241d76b768d6091c27696afe3bc437a40f (patch)
tree225741dddf84e6ad77ab5c38574fc21920946a70 /test/req_SUITE.erl
parentecf3d43613ff69dd734411b35849dbfb0b33229b (diff)
downloadcowboy-992ee6241d76b768d6091c27696afe3bc437a40f.tar.gz
cowboy-992ee6241d76b768d6091c27696afe3bc437a40f.tar.bz2
cowboy-992ee6241d76b768d6091c27696afe3bc437a40f.zip
Retry the read_urlencoded_body_too_large if timeout triggers
This is caused by the timeout being 1s after the period. When the CI environment is overloaded, sometimes the timeout will trigger. We retry, knowing that the timetrap will catch us if we retry too much.
Diffstat (limited to 'test/req_SUITE.erl')
-rw-r--r--test/req_SUITE.erl16
1 files changed, 14 insertions, 2 deletions
diff --git a/test/req_SUITE.erl b/test/req_SUITE.erl
index 04da8fa..6e111bb 100644
--- a/test/req_SUITE.erl
+++ b/test/req_SUITE.erl
@@ -591,8 +591,20 @@ do_read_urlencoded_body_too_large(Path, Body, Config) ->
{<<"content-length">>, integer_to_binary(iolist_size(Body))}
]),
gun:data(ConnPid, Ref, fin, Body),
- {response, _, 413, _} = gun:await(ConnPid, Ref, infinity),
- gun:close(ConnPid).
+ Response = gun:await(ConnPid, Ref, infinity),
+ gun:close(ConnPid),
+ case Response of
+ {response, _, 413, _} ->
+ ok;
+ %% We got the wrong crash, likely because the environment
+ %% was overloaded and the timeout triggered. Try again.
+ {response, _, 408, _} ->
+ do_read_urlencoded_body_too_large(Path, Body, Config);
+ %% Timing issues make it possible for the connection to be
+ %% closed before the data went through. We retry.
+ {error, {stream_error, {closed, {error,closed}}}} ->
+ do_read_urlencoded_body_too_large(Path, Body, Config)
+ end.
read_urlencoded_body_too_long(Config) ->
doc("application/x-www-form-urlencoded request body sent too slow. "