From 99b60849b4d6ce6e8d909de23b795f9c32b660bf Mon Sep 17 00:00:00 2001 From: "Zaiming (Stone) Shi" Date: Mon, 18 Sep 2023 20:44:38 +0200 Subject: [PATCH] test: fix flaky test emqx_falpping_SUITE:t_conf_update_timer --- apps/emqx/src/emqx_cm_sup.erl | 8 ++++++++ apps/emqx/test/emqx_flapping_SUITE.erl | 4 +++- .../test/emqx_bridge_kafka_impl_producer_SUITE.erl | 2 +- 3 files changed, 12 insertions(+), 2 deletions(-) diff --git a/apps/emqx/src/emqx_cm_sup.erl b/apps/emqx/src/emqx_cm_sup.erl index 221e78c40..9db73e8e4 100644 --- a/apps/emqx/src/emqx_cm_sup.erl +++ b/apps/emqx/src/emqx_cm_sup.erl @@ -22,6 +22,9 @@ -export([init/1]). +%% for test +-export([restart_flapping/0]). + %%-------------------------------------------------------------------- %% API %%-------------------------------------------------------------------- @@ -59,3 +62,8 @@ child_spec(Mod, Shutdown, Type) -> type => Type, modules => [Mod] }. + +restart_flapping() -> + ok = supervisor:terminate_child(?MODULE, emqx_flapping), + {ok, _} = supervisor:restart_child(?MODULE, emqx_flapping), + ok. diff --git a/apps/emqx/test/emqx_flapping_SUITE.erl b/apps/emqx/test/emqx_flapping_SUITE.erl index 021eaddbf..e580e58e3 100644 --- a/apps/emqx/test/emqx_flapping_SUITE.erl +++ b/apps/emqx/test/emqx_flapping_SUITE.erl @@ -133,7 +133,9 @@ t_conf_update(_) -> ok. t_conf_update_timer(_Config) -> - _ = emqx_flapping:start_link(), + %% delete all zones + ?assertMatch({ok, _}, emqx:update_config([zones], #{})), + emqx_cm_sup:restart_flapping(), validate_timer([{default, true}]), %% change zones {ok, _} = diff --git a/apps/emqx_bridge_kafka/test/emqx_bridge_kafka_impl_producer_SUITE.erl b/apps/emqx_bridge_kafka/test/emqx_bridge_kafka_impl_producer_SUITE.erl index 432ce8697..1dd5adab2 100644 --- a/apps/emqx_bridge_kafka/test/emqx_bridge_kafka_impl_producer_SUITE.erl +++ b/apps/emqx_bridge_kafka/test/emqx_bridge_kafka_impl_producer_SUITE.erl @@ -29,7 +29,7 @@ -include_lib("eunit/include/eunit.hrl"). -include_lib("emqx/include/emqx.hrl"). --include("emqx_dashboard.hrl"). +-include_lib("emqx_dashboard/include/emqx_dashboard.hrl"). -define(HOST, "http://127.0.0.1:18083").