Skip to content

Commit

Permalink
Fix test suite for HTTP/2 and use Gun branch with fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
essen committed Jan 2, 2025
1 parent bb6faa1 commit ffdab5b
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 10 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ DOC_DEPS = asciideck

TEST_DEPS = $(if $(CI_ERLANG_MK),ci.erlang.mk) ct_helper gun
dep_ct_helper = git https://github.com/extend/ct_helper master
dep_gun = git https://github.com/ninenines/gun master
dep_gun = git https://github.com/ninenines/gun optimise-websocket-bug-fixes

# CI configuration.

Expand Down
28 changes: 19 additions & 9 deletions test/ws_perf_SUITE.erl
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,13 @@ init_per_group(Name=http, Config) ->
init_per_group(Name=h2c, Config) ->
ct:pal("Websocket over cleartext HTTP/2"),
Config1 = cowboy_test:init_http(Name, #{
connection_window_margin_size => 64*1024,
enable_connect_protocol => true,
env => #{dispatch => init_dispatch(Config)},
max_frame_size_received => 1048576
max_frame_size_sent => 8*1024,
max_frame_size_received => 16384 * 1024 - 1,
stream_window_data_threshold => 1024,
stream_window_margin_size => 64*1024
}, [{flavor, vanilla}|Config]),
lists:keyreplace(protocol, 1, Config1, {protocol, http2}).

Expand All @@ -66,8 +70,12 @@ init_dispatch(_Config) ->

do_gun_open_ws(Config) ->
ConnPid = gun_open(Config, #{http2_opts => #{
max_frame_size_received => 1048576,
notify_settings_changed => true
connection_window_margin_size => 64*1024,
max_frame_size_sent => 8*1024,
max_frame_size_received => 16384 * 1024 - 1,
notify_settings_changed => true,
stream_window_data_threshold => 1024,
stream_window_margin_size => 64*1024
}}),
case config(protocol, Config) of
http -> ok;
Expand All @@ -91,7 +99,7 @@ receive_ws(ConnPid, StreamRef) ->
receive
{gun_ws, ConnPid, StreamRef, Frame} ->
{ok, Frame}
after 5000 ->
after 15000 ->
{error, timeout}
end.

Expand All @@ -113,9 +121,10 @@ one_binary_04096KiB(Config) ->
doc("Send and receive a 4096KiB binary frame."),
do_full(Config, one, 1, binary, 4096 * 1024).

%% Minus one because frames can only get so big.
one_binary_16384KiB(Config) ->
doc("Send and receive a 16384KiB binary frame."),
do_full(Config, one, 1, binary, 16384 * 1024).
doc("Send and receive a 16384KiB - 1 binary frame."),
do_full(Config, one, 1, binary, 16384 * 1024 - 1).

one_text_00064KiB(Config) ->
doc("Send and receive a 64KiB text frame."),
Expand All @@ -133,9 +142,10 @@ one_text_04096KiB(Config) ->
doc("Send and receive a 4096KiB text frame."),
do_full(Config, one, 1, text, 4096 * 1024).

%% Minus one because frames can only get so big.
one_text_16384KiB(Config) ->
doc("Send and receive a 16384KiB text frame."),
do_full(Config, one, 1, text, 16384 * 1024).
doc("Send and receive a 16384KiB - 1 text frame."),
do_full(Config, one, 1, text, 16384 * 1024 - 1).

repeat_binary_00000B(Config) ->
doc("Send and receive a 0B binary frame 1000 times."),
Expand Down Expand Up @@ -184,7 +194,7 @@ do_full(Config, What, Num, FrameType, FrameSize) ->
binary -> rand:bytes(FrameSize)
end,
{Time, _} = timer:tc(?MODULE, do_full1, [ConnPid, StreamRef, Num, FrameType, FrameData]),
do_log("~-6s ~-6s ~6s: ~7bµs", [What, FrameType, do_format_size(FrameSize), Time]),
do_log("~-6s ~-6s ~6s: ~8bµs", [What, FrameType, do_format_size(FrameSize), Time]),
gun:ws_send(ConnPid, StreamRef, close),
{ok, close} = receive_ws(ConnPid, StreamRef),
gun_down(ConnPid).
Expand Down

0 comments on commit ffdab5b

Please sign in to comment.