Skip to content

Commit

Permalink
test: send after stream shutdown
Browse files Browse the repository at this point in the history
try to trigger #277
  • Loading branch information
qzhuyan committed May 21, 2024
1 parent bd9ba0c commit e3537af
Showing 1 changed file with 31 additions and 0 deletions.
31 changes: 31 additions & 0 deletions test/quicer_SUITE.erl
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@
tc_stream_passive_receive_large_buffer_1/1,
tc_stream_passive_receive_large_buffer_2/1,
tc_stream_send_after_conn_close/1,
tc_stream_send_after_stream_shutdown/1,
tc_stream_send_after_async_conn_close/1,
tc_stream_sendrecv_large_data_passive/1,
%% @deprecated
Expand Down Expand Up @@ -737,6 +738,36 @@ tc_stream_send_after_conn_close(Config) ->
ct:fail("timeout")
end.

tc_stream_send_after_stream_shutdown(Config) ->
Port = select_port(),
Owner = self(),
{SPid, Ref} = spawn_monitor(fun() -> simple_stream_server(Owner, Config, Port) end),
receive
listener_ready -> ok
end,

{ok, Conn} = quicer:connect("localhost", Port, default_conn_opts(), 5000),
{ok, Stm} = quicer:start_stream(Conn, []),
{ok, 4} = quicer:send(Stm, <<"ping">>),
{ok, {_, _}} = quicer:sockname(Conn),
%% Next close_connection call has two scenarios:
%% a) Just close connection, stream is not created in QUIC
%% b) Close the connection after the stream is created in QUIC
ok = quicer:async_shutdown_stream(Stm),
case quicer:send(Stm, <<"ping2">>) of
{error, closed} ->
ok;
{error, stm_send_error, aborted} ->
ok;
{error, stm_send_error, invalid_state} ->
ok;
{error, cancelled} ->
ok
end,
ok = quicer:close_connection(Conn),
SPid ! done,
ok = ensure_server_exit_normal(Ref).

tc_stream_send_after_async_conn_close(Config) ->
Port = select_port(),
Owner = self(),
Expand Down

0 comments on commit e3537af

Please sign in to comment.