From 206d0472e0e27b4a6ae6b1ffeea8793e3fd05579 Mon Sep 17 00:00:00 2001 From: Andrew Mayorov Date: Fri, 2 Jun 2023 22:21:33 +0300 Subject: [PATCH] fix(emqx): avoid interference in testsuites Also remove that `?wait_async_action` in `emqx_trace_SUITE` which consistently becomes stuck for 100 seconds. It's not clear why it was there in the first place because listeners should start synchronously, so `emqx_common_test_helpers:start_apps/1` won't return until required listeners are started. --- apps/emqx/test/emqx_common_test_helpers.erl | 1 + apps/emqx/test/emqx_tls_certfile_gc_SUITE.erl | 3 +-- apps/emqx/test/emqx_trace_SUITE.erl | 21 ++++++------------- 3 files changed, 8 insertions(+), 17 deletions(-) diff --git a/apps/emqx/test/emqx_common_test_helpers.erl b/apps/emqx/test/emqx_common_test_helpers.erl index 54b3b3ca9..e545bb624 100644 --- a/apps/emqx/test/emqx_common_test_helpers.erl +++ b/apps/emqx/test/emqx_common_test_helpers.erl @@ -347,6 +347,7 @@ stop_apps(Apps, Opts) -> ok = mria_mnesia:delete_schema(), %% to avoid inter-suite flakiness application:unset_env(emqx, init_config_load_done), + application:unset_env(emqx, boot_modules), persistent_term:erase(?EMQX_AUTHENTICATION_SCHEMA_MODULE_PT_KEY), case Opts of #{erase_all_configs := false} -> diff --git a/apps/emqx/test/emqx_tls_certfile_gc_SUITE.erl b/apps/emqx/test/emqx_tls_certfile_gc_SUITE.erl index 3b0d0cf0c..854319b03 100644 --- a/apps/emqx/test/emqx_tls_certfile_gc_SUITE.erl +++ b/apps/emqx/test/emqx_tls_certfile_gc_SUITE.erl @@ -326,8 +326,7 @@ t_gc_active(_Config) -> emqx_tls_certfile_gc:run() ) after - emqx_common_test_helpers:stop_apps([]), - emqx_common_test_helpers:boot_modules(all) + emqx_common_test_helpers:stop_apps([]) end. orphans() -> diff --git a/apps/emqx/test/emqx_trace_SUITE.erl b/apps/emqx/test/emqx_trace_SUITE.erl index 140ec79ff..0166613a4 100644 --- a/apps/emqx/test/emqx_trace_SUITE.erl +++ b/apps/emqx/test/emqx_trace_SUITE.erl @@ -33,21 +33,12 @@ all() -> emqx_common_test_helpers:all(?MODULE). init_per_suite(Config) -> - %% ensure dependent apps stopped - emqx_common_test_helpers:stop_apps([]), - ?check_trace( - ?wait_async_action( - emqx_common_test_helpers:start_apps([]), - #{?snk_kind := listener_started, bind := 1883}, - timer:seconds(100) - ), - fun(Trace) -> - ct:pal("listener start statuses: ~p", [ - ?of_kind([listener_started, listener_not_started], Trace) - ]), - %% more than one listener - ?assertMatch([_ | _], ?of_kind(listener_started, Trace)) - end + ok = emqx_common_test_helpers:start_apps([]), + Listeners = emqx_listeners:list(), + ct:pal("emqx_listeners:list() = ~p~n", [Listeners]), + ?assertMatch( + [_ | _], + [ID || {ID, #{running := true}} <- Listeners] ), Config.