aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLoïc Hoguin <[email protected]>2018-04-28 00:53:12 +0200
committerLoïc Hoguin <[email protected]>2018-04-28 00:53:12 +0200
commitadd71bfb7e1191cb1af0fea19f5df0fde786a494 (patch)
treeb90bb756cb49d4ced59e83a394d434164c25482d
parent3d6bb01d5fee9497d995e63c12271fc4bf268911 (diff)
downloadcowboy-add71bfb7e1191cb1af0fea19f5df0fde786a494.tar.gz
cowboy-add71bfb7e1191cb1af0fea19f5df0fde786a494.tar.bz2
cowboy-add71bfb7e1191cb1af0fea19f5df0fde786a494.zip
Fix intermittent test failures for rfc7540
-rw-r--r--test/rfc7540_SUITE.erl32
1 files changed, 27 insertions, 5 deletions
diff --git a/test/rfc7540_SUITE.erl b/test/rfc7540_SUITE.erl
index 9200270..5b16294 100644
--- a/test/rfc7540_SUITE.erl
+++ b/test/rfc7540_SUITE.erl
@@ -385,9 +385,24 @@ http_upgrade_accept_client_preface_empty_settings(Config) ->
%% Receive the server preface.
{ok, << Len:24 >>} = gen_tcp:recv(Socket, 3, 1000),
{ok, << 4:8, 0:40, _:Len/binary >>} = gen_tcp:recv(Socket, 6 + Len, 1000),
- %% Receive the SETTINGS ack.
- {ok, << 0:24, 4:8, 1:8, 0:32 >>} = gen_tcp:recv(Socket, 9, 1000),
- ok.
+ %% Receive the SETTINGS ack. The response might arrive beforehand.
+ Received = lists:reverse(lists:foldl(fun(_, Acc) ->
+ case gen_tcp:recv(Socket, 9, 1000) of
+ {ok, << SkipLen:24, 1:8, _:8, 1:32 >>} ->
+ {ok, _} = gen_tcp:recv(Socket, SkipLen, 1000),
+ [headers|Acc];
+ {ok, << SkipLen:24, 0:8, _:8, 1:32 >>} ->
+ {ok, _} = gen_tcp:recv(Socket, SkipLen, 1000),
+ [data|Acc];
+ {ok, << 0:24, 4:8, 1:8, 0:32 >>} ->
+ [settings_ack|Acc]
+ end
+ end, [], [1, 2, 3])),
+ case Received of
+ [settings_ack|_] -> ok;
+ [headers, settings_ack|_] -> ok;
+ [headers, data, settings_ack] -> ok
+ end.
http_upgrade_client_preface_settings_ack_timeout(Config) ->
doc("The SETTINGS frames sent by the client must be acknowledged. (RFC7540 3.5, RFC7540 6.5.3)"),
@@ -510,7 +525,10 @@ http_upgrade_response_half_closed(Config) ->
%% Receive the server preface.
{ok, << Len:24 >>} = gen_tcp:recv(Socket, 3, 1000),
{ok, << 4:8, 0:40, _:Len/binary >>} = gen_tcp:recv(Socket, 6 + Len, 1000),
- %% Skip the SETTINGS ack, receive the response HEADERS, DATA and RST_STREAM (streamid 1).
+ %% Skip the SETTINGS ack. Receive an RST_STREAM possibly following by
+ %% a HEADERS frame, or a GOAWAY following HEADERS and DATA. This
+ %% corresponds to the stream being in half-closed and closed states.
+ %% The reason must be STREAM_CLOSED.
Received = lists:reverse(lists:foldl(fun(_, Acc) ->
case gen_tcp:recv(Socket, 9, 1000) of
{ok, << 0:24, 4:8, 1:8, 0:32 >>} ->
@@ -525,6 +543,10 @@ http_upgrade_response_half_closed(Config) ->
%% We expect a STREAM_CLOSED reason.
{ok, << 5:32 >>} = gen_tcp:recv(Socket, 4, 1000),
[rst_stream|Acc];
+ {ok, << 8:24, 7:8, 0:40 >>} ->
+ %% We expect a STREAM_CLOSED reason.
+ {ok, << 1:32, 5:32 >>} = gen_tcp:recv(Socket, 8, 1000),
+ [goaway|Acc];
{error, _} ->
%% Can be timeouts, ignore them.
Acc
@@ -533,7 +555,7 @@ http_upgrade_response_half_closed(Config) ->
case Received of
[rst_stream] -> ok;
[headers, rst_stream] -> ok;
- [headers, data, rst_stream] -> ok
+ [headers, data, goaway] -> ok
end.
%% Starting HTTP/2 for "https" URIs.