test: stabilize flaky test

This commit is contained in:
Thales Macedo Garitezi 2024-05-14 17:11:05 -03:00
parent b0aa7f25aa
commit f062517ccb
1 changed files with 16 additions and 19 deletions

View File

@ -884,26 +884,23 @@ t_kick_session(Config) ->
{will_qos, 1} {will_qos, 1}
], ],
Commands = Commands =
lists:flatten([
%% GIVEN: client connect with willmsg payload <<"willpayload_kick">> %% GIVEN: client connect with willmsg payload <<"willpayload_kick">>
[{fun start_client/5, [ClientId, ClientId, ?QOS_1, WillOpts]}] ++ {fun start_client/5, [ClientId, ClientId, ?QOS_1, WillOpts]},
[
{fun start_client/5, [ {fun start_client/5, [
<<ClientId/binary, <<"_willsub">>/binary>>, WillTopic, ?QOS_1, [] <<ClientId/binary, <<"_willsub">>/binary>>, WillTopic, ?QOS_1, []
]} ]},
] ++
[
%% kick may fail (not found) without this delay %% kick may fail (not found) without this delay
{ {
fun(CTX) -> fun(CTX) ->
timer:sleep(100), timer:sleep(300),
CTX CTX
end, end,
[] []
} },
] ++
%% WHEN: client is kicked with kick_session %% WHEN: client is kicked with kick_session
[{fun kick_client/2, [ClientId]}], {fun kick_client/2, [ClientId]}
]),
FCtx = lists:foldl( FCtx = lists:foldl(
fun({Fun, Args}, Ctx) -> fun({Fun, Args}, Ctx) ->
ct:pal("COMMAND: ~p ~p", [element(2, erlang:fun_info(Fun, name)), Args]), ct:pal("COMMAND: ~p ~p", [element(2, erlang:fun_info(Fun, name)), Args]),