Skip to content

Commit 1bbb03c

Browse files
committed
test(prop): add conn retry in prop stream tests
1 parent 1478cab commit 1bbb03c

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

test/prop_stateful_stream.erl

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ prop_stateful_client_stream_test() ->
4242
commands(?MODULE),
4343
begin
4444
flush_quic_msgs(),
45-
{ok, H} = quicer:connect("localhost", 14571, default_conn_opts(), 10000),
45+
{ok, H} = retry_connect("localhost", 14571, default_conn_opts(), 10000, 10),
4646
{History, State, Result} = run_commands(?MODULE, Cmds, [{conn_handle, H}]),
4747
quicer:async_shutdown_connection(H, ?QUIC_CONNECTION_SHUTDOWN_FLAG_SILENT, 0),
4848
?WHENFAIL(
@@ -267,6 +267,19 @@ remote_stream() ->
267267
stop_client_user(#{client_user := Pid}) ->
268268
Pid ! stop.
269269

270+
retry_connect(_Host, _Port, _Opts, _Timeout, 0) ->
271+
{error, max_retries_exceeded};
272+
retry_connect(Host, Port, Opts, Timeout, Retries) ->
273+
case quicer:connect(Host, Port, Opts, Timeout) of
274+
{ok, H} ->
275+
{ok, H};
276+
{error, _} when Retries > 1 ->
277+
timer:sleep(100),
278+
retry_connect(Host, Port, Opts, Timeout, Retries - 1);
279+
{error, Reason} ->
280+
{error, Reason}
281+
end.
282+
270283
flush_quic_msgs() ->
271284
receive
272285
{quic, _, _, _} ->

0 commit comments

Comments
 (0)