aboutsummaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorLoïc Hoguin <[email protected]>2020-04-02 14:01:26 +0200
committerLoïc Hoguin <[email protected]>2020-04-02 14:01:26 +0200
commit789768e8d38812abbf3943cbea46a592f79a2972 (patch)
treeb3eab3937afa5ab98e314bbcbcbb1462bb795b31 /test
parent2b65b575c65ed097220d58116e246a16cee500b1 (diff)
downloadcowboy-789768e8d38812abbf3943cbea46a592f79a2972.tar.gz
cowboy-789768e8d38812abbf3943cbea46a592f79a2972.tar.bz2
cowboy-789768e8d38812abbf3943cbea46a592f79a2972.zip
Rework the req_SUITE:read_body_period test
To avoid intermittent test failures. We only want to make sure the function eventually returns so we don't need to use timeouts in the test itself, or check exactly what was read.
Diffstat (limited to 'test')
-rw-r--r--test/req_SUITE.erl10
1 files changed, 6 insertions, 4 deletions
diff --git a/test/req_SUITE.erl b/test/req_SUITE.erl
index b7ffbc9..d12a3bb 100644
--- a/test/req_SUITE.erl
+++ b/test/req_SUITE.erl
@@ -496,12 +496,14 @@ read_body_period(Config) ->
Ref = gun:headers(ConnPid, "POST", "/opts/read_body/period", [
{<<"content-length">>, integer_to_binary(byte_size(Body) * 2)}
]),
- %% The body is sent twice, first with nofin, then wait 3 seconds, then again with fin.
+ %% The body is sent without fin. The server will read what it can
+ %% for 2 seconds. The test succeeds if we get some of the data back
+ %% (meaning the function will have returned after the period ends).
gun:data(ConnPid, Ref, nofin, Body),
- timer:sleep(3000),
- gun:data(ConnPid, Ref, fin, Body),
{response, nofin, 200, _} = gun:await(ConnPid, Ref),
- {ok, Body} = gun:await_body(ConnPid, Ref),
+ {data, _, Data} = gun:await(ConnPid, Ref),
+ %% We expect to read at least some data.
+ true = Data =/= <<>>,
gun:close(ConnPid).
%% We expect a crash.