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

test(crl): ensure ssl_manager is ready to avoid flakiness
This commit is contained in:
Thales Macedo Garitezi 2023-04-27 11:59:34 -03:00 committed by GitHub
commit c984449bad
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 16 additions and 1 deletions

View File

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