From 406a2d7a5298346cacc56efb943b2a34577df332 Mon Sep 17 00:00:00 2001 From: "Zaiming (Stone) Shi" Date: Thu, 14 Dec 2023 14:43:49 +0100 Subject: [PATCH] test: fix shared sub test case flaky --- apps/emqx/test/emqx_shared_sub_SUITE.erl | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/apps/emqx/test/emqx_shared_sub_SUITE.erl b/apps/emqx/test/emqx_shared_sub_SUITE.erl index a5d2567d0..b732735bd 100644 --- a/apps/emqx/test/emqx_shared_sub_SUITE.erl +++ b/apps/emqx/test/emqx_shared_sub_SUITE.erl @@ -739,11 +739,16 @@ t_qos1_random_dispatch_if_all_members_are_down(Config) when is_list(Config) -> ?assert(is_process_alive(Pid2)), {ok, _} = emqtt:publish(ConnPub, Topic, <<"hello11">>, 1), - ct:sleep(100), - Msgs1 = emqx_mqueue:to_list(get_mqueue(Pid1)), - Msgs2 = emqx_mqueue:to_list(get_mqueue(Pid2)), - %% assert the message is in mqueue (because socket is closed) - ?assertMatch([#message{payload = <<"hello11">>}], Msgs1 ++ Msgs2), + ?retry( + 100, + 10, + begin + Msgs1 = emqx_mqueue:to_list(get_mqueue(Pid1)), + Msgs2 = emqx_mqueue:to_list(get_mqueue(Pid2)), + %% assert the message is in mqueue (because socket is closed) + ?assertMatch([#message{payload = <<"hello11">>}], Msgs1 ++ Msgs2) + end + ), emqtt:stop(ConnPub), ok.