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),
|
-define(assertReceive(PATTERN, TIMEOUT),
|
||||||
|
?assertReceive(PATTERN, TIMEOUT, #{})
|
||||||
|
).
|
||||||
|
|
||||||
|
-define(assertReceive(PATTERN, TIMEOUT, EXTRA),
|
||||||
(fun() ->
|
(fun() ->
|
||||||
receive
|
receive
|
||||||
X__V = PATTERN -> X__V
|
X__V = PATTERN -> X__V
|
||||||
|
@ -54,7 +58,8 @@
|
||||||
{module, ?MODULE},
|
{module, ?MODULE},
|
||||||
{line, ?LINE},
|
{line, ?LINE},
|
||||||
{expression, (??PATTERN)},
|
{expression, (??PATTERN)},
|
||||||
{mailbox, ?drainMailbox()}
|
{mailbox, ?drainMailbox()},
|
||||||
|
{extra_info, EXTRA}
|
||||||
]}
|
]}
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
|
|
|
@ -884,26 +884,23 @@ t_kick_session(Config) ->
|
||||||
{will_qos, 1}
|
{will_qos, 1}
|
||||||
],
|
],
|
||||||
Commands =
|
Commands =
|
||||||
%% GIVEN: client connect with willmsg payload <<"willpayload_kick">>
|
lists:flatten([
|
||||||
[{fun start_client/5, [ClientId, ClientId, ?QOS_1, WillOpts]}] ++
|
%% GIVEN: client connect with willmsg payload <<"willpayload_kick">>
|
||||||
[
|
{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) ->
|
||||||
{
|
timer:sleep(300),
|
||||||
fun(CTX) ->
|
CTX
|
||||||
timer:sleep(100),
|
end,
|
||||||
CTX
|
[]
|
||||||
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]),
|
||||||
|
@ -1045,9 +1042,15 @@ assert_client_exit(Pid, v5, takenover) ->
|
||||||
%% @ref: MQTT 5.0 spec [MQTT-3.1.4-3]
|
%% @ref: MQTT 5.0 spec [MQTT-3.1.4-3]
|
||||||
?assertReceive({'EXIT', Pid, {disconnected, ?RC_SESSION_TAKEN_OVER, _}});
|
?assertReceive({'EXIT', Pid, {disconnected, ?RC_SESSION_TAKEN_OVER, _}});
|
||||||
assert_client_exit(Pid, v3, takenover) ->
|
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) ->
|
assert_client_exit(Pid, v3, kicked) ->
|
||||||
?assertReceive({'EXIT', Pid, _});
|
?assertReceive({'EXIT', Pid, _}, 1_000, #{pid => Pid});
|
||||||
assert_client_exit(Pid, v5, kicked) ->
|
assert_client_exit(Pid, v5, kicked) ->
|
||||||
?assertReceive({'EXIT', Pid, {disconnected, ?RC_ADMINISTRATIVE_ACTION, _}});
|
?assertReceive({'EXIT', Pid, {disconnected, ?RC_ADMINISTRATIVE_ACTION, _}});
|
||||||
assert_client_exit(Pid, _, killed) ->
|
assert_client_exit(Pid, _, killed) ->
|
||||||
|
|
Loading…
Reference in New Issue