test: fix flaky banned case
since this suite has changed its start method to the `emqx_common_test_helpers:start_apps/1`, the `emqx_banned` server will never stop (its restart type is permanent), thus there is no need to manually start or stops it.
This commit is contained in:
parent
8e87bd625d
commit
7b93b166dc
|
@ -97,22 +97,30 @@ t_check(_) ->
|
||||||
?assertEqual(0, emqx_banned:info(size)).
|
?assertEqual(0, emqx_banned:info(size)).
|
||||||
|
|
||||||
t_unused(_) ->
|
t_unused(_) ->
|
||||||
catch emqx_banned:stop(),
|
Who1 = {clientid, <<"BannedClient1">>},
|
||||||
{ok, Banned} = emqx_banned:start_link(),
|
Who2 = {clientid, <<"BannedClient2">>},
|
||||||
{ok, _} = emqx_banned:create(#banned{
|
|
||||||
who = {clientid, <<"BannedClient1">>},
|
?assertMatch(
|
||||||
|
{ok, _},
|
||||||
|
emqx_banned:create(#banned{
|
||||||
|
who = Who1,
|
||||||
until = erlang:system_time(second)
|
until = erlang:system_time(second)
|
||||||
}),
|
})
|
||||||
{ok, _} = emqx_banned:create(#banned{
|
),
|
||||||
who = {clientid, <<"BannedClient2">>},
|
?assertMatch(
|
||||||
|
{ok, _},
|
||||||
|
emqx_banned:create(#banned{
|
||||||
|
who = Who2,
|
||||||
until = erlang:system_time(second) - 1
|
until = erlang:system_time(second) - 1
|
||||||
}),
|
})
|
||||||
?assertEqual(ignored, gen_server:call(Banned, unexpected_req)),
|
),
|
||||||
?assertEqual(ok, gen_server:cast(Banned, unexpected_msg)),
|
?assertEqual(ignored, gen_server:call(emqx_banned, unexpected_req)),
|
||||||
?assertEqual(ok, Banned ! ok),
|
?assertEqual(ok, gen_server:cast(emqx_banned, unexpected_msg)),
|
||||||
%% expiry timer
|
%% expiry timer
|
||||||
timer:sleep(500),
|
timer:sleep(500),
|
||||||
ok = emqx_banned:stop().
|
|
||||||
|
ok = emqx_banned:delete(Who1),
|
||||||
|
ok = emqx_banned:delete(Who2).
|
||||||
|
|
||||||
t_kick(_) ->
|
t_kick(_) ->
|
||||||
ClientId = <<"client">>,
|
ClientId = <<"client">>,
|
||||||
|
|
Loading…
Reference in New Issue