Merge pull request #7948 from zmstone/0513-fix-flaky-test

0513 fix flaky test
This commit is contained in:
Zaiming (Stone) Shi 2022-05-13 12:06:03 +01:00 committed by GitHub
commit 44b14fc019
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 5 additions and 2 deletions

View File

@ -25,6 +25,8 @@
all() -> emqx_common_test_helpers:all(?MODULE). all() -> emqx_common_test_helpers:all(?MODULE).
init_per_suite(Config) -> init_per_suite(Config) ->
%% ensure stopped, this suite tests emqx_ctl process independently
application:stop(emqx),
ok = emqx_logger:set_log_level(emergency), ok = emqx_logger:set_log_level(emergency),
Config. Config.

View File

@ -105,6 +105,7 @@ t_monitor_reset(_) ->
?assert(maps:is_key(atom_to_binary(Key, utf8), Rate)) ?assert(maps:is_key(atom_to_binary(Key, utf8), Rate))
|| Key <- maps:values(?DELTA_SAMPLER_RATE_MAP) ++ ?GAUGE_SAMPLER_LIST || Key <- maps:values(?DELTA_SAMPLER_RATE_MAP) ++ ?GAUGE_SAMPLER_LIST
], ],
timer:sleep(?DEFAULT_SAMPLE_INTERVAL * 2 * 1000 + 20),
{ok, Samplers} = request(["monitor"], "latest=1"), {ok, Samplers} = request(["monitor"], "latest=1"),
?assertEqual(1, erlang:length(Samplers)), ?assertEqual(1, erlang:length(Samplers)),
ok. ok.
@ -158,7 +159,7 @@ auth_header_() ->
restart_monitor() -> restart_monitor() ->
OldMonitor = erlang:whereis(emqx_dashboard_monitor), OldMonitor = erlang:whereis(emqx_dashboard_monitor),
erlang:exit(OldMonitor, killed), erlang:exit(OldMonitor, kill),
?assertEqual(ok, wait_new_monitor(OldMonitor, 10)). ?assertEqual(ok, wait_new_monitor(OldMonitor, 10)).
wait_new_monitor(_OldMonitor, Count) when Count =< 0 -> timeout; wait_new_monitor(_OldMonitor, Count) when Count =< 0 -> timeout;

View File

@ -40,7 +40,7 @@
] ]
). ).
-include("emqx_authn.hrl"). -include_lib("emqx_authn/include/emqx_authn.hrl").
-include_lib("eunit/include/eunit.hrl"). -include_lib("eunit/include/eunit.hrl").
-include_lib("common_test/include/ct.hrl"). -include_lib("common_test/include/ct.hrl").
-include_lib("emqx/include/emqx_placeholder.hrl"). -include_lib("emqx/include/emqx_placeholder.hrl").