Merge pull request #13051 from thalesmg/test-add-more-context-debug-m-20240514
test: attempt to stabilize a couple flaky tests
This commit is contained in:
commit
bde17158e9
|
@ -45,6 +45,10 @@
|
|||
).
|
||||
|
||||
-define(assertReceive(PATTERN, TIMEOUT),
|
||||
?assertReceive(PATTERN, TIMEOUT, #{})
|
||||
).
|
||||
|
||||
-define(assertReceive(PATTERN, TIMEOUT, EXTRA),
|
||||
(fun() ->
|
||||
receive
|
||||
X__V = PATTERN -> X__V
|
||||
|
@ -54,7 +58,8 @@
|
|||
{module, ?MODULE},
|
||||
{line, ?LINE},
|
||||
{expression, (??PATTERN)},
|
||||
{mailbox, ?drainMailbox()}
|
||||
{mailbox, ?drainMailbox()},
|
||||
{extra_info, EXTRA}
|
||||
]}
|
||||
)
|
||||
end
|
||||
|
|
|
@ -884,26 +884,23 @@ t_kick_session(Config) ->
|
|||
{will_qos, 1}
|
||||
],
|
||||
Commands =
|
||||
lists:flatten([
|
||||
%% 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, [
|
||||
<<ClientId/binary, <<"_willsub">>/binary>>, WillTopic, ?QOS_1, []
|
||||
]}
|
||||
] ++
|
||||
[
|
||||
]},
|
||||
%% kick may fail (not found) without this delay
|
||||
{
|
||||
fun(CTX) ->
|
||||
timer:sleep(100),
|
||||
timer:sleep(300),
|
||||
CTX
|
||||
end,
|
||||
[]
|
||||
}
|
||||
] ++
|
||||
},
|
||||
%% WHEN: client is kicked with kick_session
|
||||
[{fun kick_client/2, [ClientId]}],
|
||||
|
||||
{fun kick_client/2, [ClientId]}
|
||||
]),
|
||||
FCtx = lists:foldl(
|
||||
fun({Fun, Args}, Ctx) ->
|
||||
ct:pal("COMMAND: ~p ~p", [element(2, erlang:fun_info(Fun, name)), Args]),
|
||||
|
@ -1045,9 +1042,15 @@ assert_client_exit(Pid, v5, takenover) ->
|
|||
%% @ref: MQTT 5.0 spec [MQTT-3.1.4-3]
|
||||
?assertReceive({'EXIT', Pid, {disconnected, ?RC_SESSION_TAKEN_OVER, _}});
|
||||
assert_client_exit(Pid, v3, takenover) ->
|
||||
?assertReceive({'EXIT', Pid, {shutdown, tcp_closed}});
|
||||
?assertReceive(
|
||||
{'EXIT', Pid, {shutdown, Reason}} when
|
||||
Reason =:= tcp_closed orelse
|
||||
Reason =:= closed,
|
||||
1_000,
|
||||
#{pid => Pid}
|
||||
);
|
||||
assert_client_exit(Pid, v3, kicked) ->
|
||||
?assertReceive({'EXIT', Pid, _});
|
||||
?assertReceive({'EXIT', Pid, _}, 1_000, #{pid => Pid});
|
||||
assert_client_exit(Pid, v5, kicked) ->
|
||||
?assertReceive({'EXIT', Pid, {disconnected, ?RC_ADMINISTRATIVE_ACTION, _}});
|
||||
assert_client_exit(Pid, _, killed) ->
|
||||
|
|
Loading…
Reference in New Issue