Просмотр исходного кода

Merge pull request #10530 from thalesmg/fix-wait-ssl-crl-test-v50

test(crl): ensure ssl_manager is ready to avoid flakiness
Thales Macedo Garitezi 2 лет назад
Родитель
Сommit
c984449bad
1 измененных файлов с 16 добавлено и 1 удалено
  1. 16 1
      apps/emqx/test/emqx_crl_cache_SUITE.erl

+ 16 - 1
apps/emqx/test/emqx_crl_cache_SUITE.erl

@@ -35,6 +35,7 @@ all() ->
 
 init_per_suite(Config) ->
     application:load(emqx),
+    {ok, _} = application:ensure_all_started(ssl),
     emqx_config:save_schema_mod_and_names(emqx_schema),
     emqx_common_test_helpers:boot_modules(all),
     Config.
@@ -328,7 +329,15 @@ drain_msgs() ->
 
 clear_crl_cache() ->
     %% reset the CRL cache
+    Ref = monitor(process, whereis(ssl_manager)),
     exit(whereis(ssl_manager), kill),
+    receive
+        {'DOWN', Ref, process, _, _} ->
+            ok
+    after 1_000 ->
+        ct:fail("ssl_manager didn't die")
+    end,
+    ensure_ssl_manager_alive(),
     ok.
 
 force_cacertfile(Cacertfile) ->
@@ -382,7 +391,6 @@ setup_crl_options(Config, #{is_cached := IsCached} = Opts) ->
         false ->
             %% ensure cache is empty
             clear_crl_cache(),
-            ct:sleep(200),
             ok
     end,
     drain_msgs(),
@@ -459,6 +467,13 @@ of_kinds(Trace0, Kinds0) ->
         Trace0
     ).
 
+ensure_ssl_manager_alive() ->
+    ?retry(
+        _Sleep0 = 200,
+        _Attempts0 = 50,
+        true = is_pid(whereis(ssl_manager))
+    ).
+
 %%--------------------------------------------------------------------
 %% Test cases
 %%--------------------------------------------------------------------