Merge pull request #8107 from zmstone/0531-test-fix-flaky-test-case
test: wait for listener to be ready before running test case
This commit is contained in:
commit
a272951415
|
@ -21,6 +21,7 @@
|
|||
|
||||
-include("emqx_mqtt.hrl").
|
||||
-include("logger.hrl").
|
||||
-include_lib("snabbkaffe/include/snabbkaffe.hrl").
|
||||
|
||||
%% APIs
|
||||
-export([
|
||||
|
@ -193,6 +194,7 @@ start_listener(Type, ListenerName, #{bind := Bind} = Conf) ->
|
|||
),
|
||||
ok;
|
||||
{ok, _} ->
|
||||
?tp(listener_started, #{type => Type, bind => Bind}),
|
||||
console_print(
|
||||
"Listener ~ts on ~ts started.~n",
|
||||
[listener_id(Type, ListenerName), format_addr(Bind)]
|
||||
|
|
|
@ -22,6 +22,7 @@
|
|||
-include_lib("emqx/include/emqx.hrl").
|
||||
-include_lib("eunit/include/eunit.hrl").
|
||||
-include_lib("common_test/include/ct.hrl").
|
||||
-include_lib("snabbkaffe/include/snabbkaffe.hrl").
|
||||
|
||||
-define(TOPIC, <<"t">>).
|
||||
-define(CNT, 100).
|
||||
|
@ -32,7 +33,17 @@
|
|||
all() -> emqx_common_test_helpers:all(?MODULE).
|
||||
|
||||
init_per_suite(Config) ->
|
||||
emqx_common_test_helpers:start_apps([]),
|
||||
?check_trace(
|
||||
?wait_async_action(
|
||||
emqx_common_test_helpers:start_apps([]),
|
||||
#{?snk_kind := listener_started, bind := 1883},
|
||||
timer:seconds(5)
|
||||
),
|
||||
fun(Trace) ->
|
||||
%% more than one listener
|
||||
?assertMatch([_ | _], ?of_kind(listener_started, Trace))
|
||||
end
|
||||
),
|
||||
Config.
|
||||
|
||||
end_per_suite(_Config) ->
|
||||
|
|
Loading…
Reference in New Issue