Merge pull request #13544 from thalesmg/20240730-m-test-flaky-client-v2
test(clients v2 api): attempt to reduce flakiness
This commit is contained in:
commit
83041a8b83
|
@ -550,13 +550,10 @@ t_persistent_sessions5(Config) ->
|
||||||
lists:sort(lists:map(fun(#{<<"clientid">> := CId}) -> CId end, R3 ++ R4))
|
lists:sort(lists:map(fun(#{<<"clientid">> := CId}) -> CId end, R3 ++ R4))
|
||||||
),
|
),
|
||||||
|
|
||||||
lists:foreach(fun emqtt:stop/1, [C3, C4]),
|
lists:foreach(fun disconnect_and_destroy_session/1, [C3, C4]),
|
||||||
lists:foreach(
|
C1B = connect_client(#{port => Port1, clientid => ClientId1}),
|
||||||
fun(ClientId) ->
|
C2B = connect_client(#{port => Port2, clientid => ClientId2}),
|
||||||
ok = erpc:call(N1, emqx_persistent_session_ds, destroy_session, [ClientId])
|
lists:foreach(fun disconnect_and_destroy_session/1, [C1B, C2B]),
|
||||||
end,
|
|
||||||
ClientIds
|
|
||||||
),
|
|
||||||
|
|
||||||
ok
|
ok
|
||||||
end,
|
end,
|
||||||
|
@ -1623,8 +1620,7 @@ t_list_clients_v2(Config) ->
|
||||||
port => Port2, clientid => ClientId6, expiry => 0, clean_start => true
|
port => Port2, clientid => ClientId6, expiry => 0, clean_start => true
|
||||||
}),
|
}),
|
||||||
%% offline persistent clients
|
%% offline persistent clients
|
||||||
ok = emqtt:stop(C3),
|
lists:foreach(fun stop_and_commit/1, [C3, C4]),
|
||||||
ok = emqtt:stop(C4),
|
|
||||||
|
|
||||||
%% one by one
|
%% one by one
|
||||||
QueryParams1 = #{limit => "1"},
|
QueryParams1 = #{limit => "1"},
|
||||||
|
@ -2143,3 +2139,16 @@ do_traverse_in_reverse_v2(QueryParams0, Config, [Cursor | Rest], DirectOrderClie
|
||||||
|
|
||||||
disconnect_and_destroy_session(Client) ->
|
disconnect_and_destroy_session(Client) ->
|
||||||
ok = emqtt:disconnect(Client, ?RC_SUCCESS, #{'Session-Expiry-Interval' => 0}).
|
ok = emqtt:disconnect(Client, ?RC_SUCCESS, #{'Session-Expiry-Interval' => 0}).
|
||||||
|
|
||||||
|
%% To avoid a race condition where we try to delete the session while it's terminating and
|
||||||
|
%% committing. This shouldn't happen realistically, because we have a safe grace period
|
||||||
|
%% before attempting to GC a session.
|
||||||
|
%% Also, we need to wait until offline metadata is committed before checking the v2 client
|
||||||
|
%% list, to avoid flaky batch results.
|
||||||
|
stop_and_commit(Client) ->
|
||||||
|
{ok, {ok, _}} =
|
||||||
|
?wait_async_action(
|
||||||
|
emqtt:stop(Client),
|
||||||
|
#{?snk_kind := persistent_session_ds_terminate}
|
||||||
|
),
|
||||||
|
ok.
|
||||||
|
|
Loading…
Reference in New Issue