2424% % ct.
2525
2626all () ->
27- [{group , ascii }, {group , mixed }, {group , japanese }].
27+ [{group , binary }, { group , ascii }, {group , mixed }, {group , japanese }].
2828
2929groups () ->
3030 CommonGroups = cowboy_test :common_groups (ct_helper :all (? MODULE ), no_parallel ),
3131 SubGroups = [G || G = {GN , _ , _ } <- CommonGroups ,
3232 GN =:= http orelse GN =:= h2c ],
3333 [
34+ {binary , [], SubGroups },
3435 {ascii , [], SubGroups },
3536 {mixed , [], SubGroups },
3637 {japanese , [], SubGroups }
@@ -46,18 +47,18 @@ end_per_suite(_Config) ->
4647
4748init_per_group (Name = http , Config ) ->
4849 ct :pal (" Websocket over cleartext HTTP/1.1 (~s )" ,
49- [config ( text_data_filename , Config )]),
50+ [init_data_info ( Config )]),
5051 cowboy_test :init_http (Name , #{
5152 env => #{dispatch => init_dispatch (Config )}
5253 }, [{flavor , vanilla }|Config ]);
5354init_per_group (Name = h2c , Config ) ->
5455 ct :pal (" Websocket over cleartext HTTP/2 (~s )" ,
55- [config ( text_data_filename , Config )]),
56+ [init_data_info ( Config )]),
5657 Config1 = cowboy_test :init_http (Name , #{
5758 connection_window_margin_size => 64 * 1024 ,
5859 enable_connect_protocol => true ,
5960 env => #{dispatch => init_dispatch (Config )},
60- max_frame_size_sent => 8 * 1024 ,
61+ max_frame_size_sent => 64 * 1024 ,
6162 max_frame_size_received => 16384 * 1024 - 1 ,
6263 stream_window_data_threshold => 1024 ,
6364 stream_window_margin_size => 64 * 1024
@@ -68,11 +69,23 @@ init_per_group(ascii, Config) ->
6869init_per_group (mixed , Config ) ->
6970 init_text_data (" grok_segond.txt" , Config );
7071init_per_group (japanese , Config ) ->
71- init_text_data (" japanese.txt" , Config ).
72+ init_text_data (" japanese.txt" , Config );
73+ init_per_group (binary , Config ) ->
74+ [{frame_type , binary }|Config ].
75+
76+ init_data_info (Config ) ->
77+ case config (frame_type , Config ) of
78+ text -> config (text_data_filename , Config );
79+ binary -> binary
80+ end .
7281
7382init_text_data (Filename , Config ) ->
7483 {ok , Text } = file :read_file (filename :join (config (data_dir , Config ), Filename )),
75- [{text_data , Text }, {text_data_filename , Filename }|Config ].
84+ [
85+ {frame_type , text },
86+ {text_data , Text },
87+ {text_data_filename , Filename }
88+ |Config ].
7689
7790end_per_group (Name , _Config ) ->
7891 cowboy_test :stop_group (Name ).
@@ -91,7 +104,7 @@ init_dispatch(_Config) ->
91104do_gun_open_ws (Config ) ->
92105 ConnPid = gun_open (Config , #{http2_opts => #{
93106 connection_window_margin_size => 64 * 1024 ,
94- max_frame_size_sent => 8 * 1024 ,
107+ max_frame_size_sent => 64 * 1024 ,
95108 max_frame_size_received => 16384 * 1024 - 1 ,
96109 notify_settings_changed => true ,
97110 stream_window_data_threshold => 1024 ,
@@ -125,94 +138,54 @@ receive_ws(ConnPid, StreamRef) ->
125138
126139% % Tests.
127140
128- one_binary_00064KiB (Config ) ->
129- doc (" Send and receive a 64KiB binary frame." ),
130- do_full (Config , one , 1 , binary , 64 * 1024 ).
141+ one_00064KiB (Config ) ->
142+ doc (" Send and receive a 64KiB frame." ),
143+ do_full (Config , one , 1 , 64 * 1024 ).
131144
132- one_binary_00256KiB (Config ) ->
133- doc (" Send and receive a 256KiB binary frame." ),
134- do_full (Config , one , 1 , binary , 256 * 1024 ).
145+ one_00256KiB (Config ) ->
146+ doc (" Send and receive a 256KiB frame." ),
147+ do_full (Config , one , 1 , 256 * 1024 ).
135148
136- one_binary_01024KiB (Config ) ->
137- doc (" Send and receive a 1024KiB binary frame." ),
138- do_full (Config , one , 1 , binary , 1024 * 1024 ).
149+ one_01024KiB (Config ) ->
150+ doc (" Send and receive a 1024KiB frame." ),
151+ do_full (Config , one , 1 , 1024 * 1024 ).
139152
140- one_binary_04096KiB (Config ) ->
141- doc (" Send and receive a 4096KiB binary frame." ),
142- do_full (Config , one , 1 , binary , 4096 * 1024 ).
153+ one_04096KiB (Config ) ->
154+ doc (" Send and receive a 4096KiB frame." ),
155+ do_full (Config , one , 1 , 4096 * 1024 ).
143156
144157% % Minus one because frames can only get so big.
145- one_binary_16384KiB (Config ) ->
146- doc (" Send and receive a 16384KiB - 1 binary frame." ),
147- do_full (Config , one , 1 , binary , 16384 * 1024 - 1 ).
148-
149- one_text_00064KiB (Config ) ->
150- doc (" Send and receive a 64KiB text frame." ),
151- do_full (Config , one , 1 , text , 64 * 1024 ).
152-
153- one_text_00256KiB (Config ) ->
154- doc (" Send and receive a 256KiB text frame." ),
155- do_full (Config , one , 1 , text , 256 * 1024 ).
156-
157- one_text_01024KiB (Config ) ->
158- doc (" Send and receive a 1024KiB text frame." ),
159- do_full (Config , one , 1 , text , 1024 * 1024 ).
160-
161- one_text_04096KiB (Config ) ->
162- doc (" Send and receive a 4096KiB text frame." ),
163- do_full (Config , one , 1 , text , 4096 * 1024 ).
164-
165- % % Minus one because frames can only get so big.
166- one_text_16384KiB (Config ) ->
167- doc (" Send and receive a 16384KiB - 1 text frame." ),
168- do_full (Config , one , 1 , text , 16384 * 1024 - 1 ).
169-
170- repeat_binary_00000B (Config ) ->
171- doc (" Send and receive a 0B binary frame 1000 times." ),
172- do_full (Config , repeat , 1000 , binary , 0 ).
173-
174- repeat_binary_00256B (Config ) ->
175- doc (" Send and receive a 256B binary frame 1000 times." ),
176- do_full (Config , repeat , 1000 , binary , 256 ).
177-
178- repeat_binary_01024B (Config ) ->
179- doc (" Send and receive a 1024B binary frame 1000 times." ),
180- do_full (Config , repeat , 1000 , binary , 1024 ).
181-
182- repeat_binary_04096B (Config ) ->
183- doc (" Send and receive a 4096B binary frame 1000 times." ),
184- do_full (Config , repeat , 1000 , binary , 4096 ).
185-
186- repeat_binary_16384B (Config ) ->
187- doc (" Send and receive a 16384B binary frame 1000 times." ),
188- do_full (Config , repeat , 1000 , binary , 16384 ).
158+ one_16384KiB (Config ) ->
159+ doc (" Send and receive a 16384KiB - 1 frame." ),
160+ do_full (Config , one , 1 , 16384 * 1024 - 1 ).
189161
190- repeat_text_00000B (Config ) ->
191- doc (" Send and receive a 0B text frame 1000 times." ),
192- do_full (Config , repeat , 1000 , text , 0 ).
162+ repeat_00000B (Config ) ->
163+ doc (" Send and receive a 0B frame 1000 times." ),
164+ do_full (Config , repeat , 1000 , 0 ).
193165
194- repeat_text_00256B (Config ) ->
195- doc (" Send and receive a 256B text frame 1000 times." ),
196- do_full (Config , repeat , 1000 , text , 256 ).
166+ repeat_00256B (Config ) ->
167+ doc (" Send and receive a 256B frame 1000 times." ),
168+ do_full (Config , repeat , 1000 , 256 ).
197169
198- repeat_text_01024B (Config ) ->
199- doc (" Send and receive a 1024B text frame 1000 times." ),
200- do_full (Config , repeat , 1000 , text , 1024 ).
170+ repeat_01024B (Config ) ->
171+ doc (" Send and receive a 1024B frame 1000 times." ),
172+ do_full (Config , repeat , 1000 , 1024 ).
201173
202- repeat_text_04096B (Config ) ->
203- doc (" Send and receive a 4096B text frame 1000 times." ),
204- do_full (Config , repeat , 1000 , text , 4096 ).
174+ repeat_04096B (Config ) ->
175+ doc (" Send and receive a 4096B frame 1000 times." ),
176+ do_full (Config , repeat , 1000 , 4096 ).
205177
206- repeat_text_16384B (Config ) ->
207- doc (" Send and receive a 16384B text frame 1000 times." ),
208- do_full (Config , repeat , 1000 , text , 16384 ).
178+ repeat_16384B (Config ) ->
179+ doc (" Send and receive a 16384B frame 1000 times." ),
180+ do_full (Config , repeat , 1000 , 16384 ).
209181
210- % repeat_text_16384B_10K (Config) ->
211- % doc("Send and receive a 16384B text frame 10000 times."),
212- % do_full(Config, repeat, 10000, text, 16384).
182+ % repeat_16384B_10K (Config) ->
183+ % doc("Send and receive a 16384B frame 10000 times."),
184+ % do_full(Config, repeat, 10000, 16384).
213185
214- do_full (Config , What , Num , FrameType , FrameSize ) ->
186+ do_full (Config , What , Num , FrameSize ) ->
215187 {ok , ConnPid , StreamRef } = do_gun_open_ws (Config ),
188+ FrameType = config (frame_type , Config ),
216189 FrameData = case FrameType of
217190 text -> do_text_data (Config , FrameSize );
218191 binary -> rand :bytes (FrameSize )
0 commit comments