Merge pull request #6126 from zmstone/test-fix-flaky-emqx-cm-test
Test fix flaky emqx cm test
This commit is contained in:
commit
edb2793180
|
@ -1,6 +1,6 @@
|
||||||
{application, emqx_dashboard,
|
{application, emqx_dashboard,
|
||||||
[{description, "EMQ X Web Dashboard"},
|
[{description, "EMQ X Web Dashboard"},
|
||||||
{vsn, "4.3.6"}, % strict semver, bump manually!
|
{vsn, "4.3.7"}, % strict semver, bump manually!
|
||||||
{modules, []},
|
{modules, []},
|
||||||
{registered, [emqx_dashboard_sup]},
|
{registered, [emqx_dashboard_sup]},
|
||||||
{applications, [kernel,stdlib,mnesia,minirest]},
|
{applications, [kernel,stdlib,mnesia,minirest]},
|
||||||
|
|
|
@ -183,7 +183,8 @@ t_open_session_race_condition(_) ->
|
||||||
|
|
||||||
exit(Winner, kill),
|
exit(Winner, kill),
|
||||||
receive {'DOWN', _, process, Winner, _} -> ok end,
|
receive {'DOWN', _, process, Winner, _} -> ok end,
|
||||||
ignored = gen_server:call(emqx_cm, ignore, infinity), %% sync
|
ignored = gen_server:call(?CM, ignore, infinity), %% sync
|
||||||
|
ok = flush_emqx_pool(),
|
||||||
?assertEqual([], emqx_cm:lookup_channels(ClientId)).
|
?assertEqual([], emqx_cm:lookup_channels(ClientId)).
|
||||||
|
|
||||||
t_kick_session_discard_normal(_) ->
|
t_kick_session_discard_normal(_) ->
|
||||||
|
@ -260,6 +261,7 @@ test_kick_session(Action, Reason) ->
|
||||||
?assertEqual(Reason, ?WAIT({'DOWN', _, process, Pid1, R}, 2_000, R)),
|
?assertEqual(Reason, ?WAIT({'DOWN', _, process, Pid1, R}, 2_000, R)),
|
||||||
?assertEqual(Reason, ?WAIT({'DOWN', _, process, Pid2, R}, 2_000, R))
|
?assertEqual(Reason, ?WAIT({'DOWN', _, process, Pid2, R}, 2_000, R))
|
||||||
end,
|
end,
|
||||||
|
ignored = gen_server:call(?CM, ignore, infinity), %% sync
|
||||||
ok = flush_emqx_pool(),
|
ok = flush_emqx_pool(),
|
||||||
?assertEqual([], emqx_cm:lookup_channels(ClientId)).
|
?assertEqual([], emqx_cm:lookup_channels(ClientId)).
|
||||||
|
|
||||||
|
@ -271,10 +273,11 @@ test_kick_session(Action, Reason) ->
|
||||||
%% The number of tasks should be large enough to ensure all workers have
|
%% The number of tasks should be large enough to ensure all workers have
|
||||||
%% the chance to work on at least one of the tasks.
|
%% the chance to work on at least one of the tasks.
|
||||||
flush_emqx_pool() ->
|
flush_emqx_pool() ->
|
||||||
|
Ref = make_ref(),
|
||||||
Self = self(),
|
Self = self(),
|
||||||
L = lists:seq(1, 1000),
|
L = lists:seq(1, 1000),
|
||||||
lists:foreach(fun(I) -> emqx_pool:async_submit(fun() -> Self ! {done, I} end, []) end, L),
|
lists:foreach(fun(I) -> emqx_pool:async_submit(fun() -> Self ! {done, I, Ref} end, []) end, L),
|
||||||
lists:foreach(fun(I) -> receive {done, I} -> ok end end, L).
|
lists:foreach(fun(I) -> receive {done, I, Ref} -> ok end end, L).
|
||||||
|
|
||||||
t_discard_session_race(_) ->
|
t_discard_session_race(_) ->
|
||||||
ClientId = rand_client_id(),
|
ClientId = rand_client_id(),
|
||||||
|
|
Loading…
Reference in New Issue