From 56044085c85cfefd890604bab2f3f383cbe7d76f Mon Sep 17 00:00:00 2001 From: Shawn <506895667@qq.com> Date: Wed, 20 Apr 2022 12:04:29 +0800 Subject: [PATCH] fix(test): make mria fall back to use mnesia db_backend when running test --- apps/emqx/test/emqx_common_test_helpers.erl | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/apps/emqx/test/emqx_common_test_helpers.erl b/apps/emqx/test/emqx_common_test_helpers.erl index 33943ddbd..cda953a76 100644 --- a/apps/emqx/test/emqx_common_test_helpers.erl +++ b/apps/emqx/test/emqx_common_test_helpers.erl @@ -150,7 +150,7 @@ start_apps(Apps, Handler) when is_function(Handler) -> %% Load all application code to beam vm first %% Because, minirest, ekka etc.. application will scan these modules lists:foreach(fun load/1, [emqx | Apps]), - ekka:start(), + ok = start_ekka(), ok = emqx_ratelimiter_SUITE:base_conf(), lists:foreach(fun(App) -> start_app(App, Handler) end, [emqx | Apps]). @@ -484,3 +484,12 @@ is_tcp_server_available(Host, Port, Timeout) -> {error, _} -> false end. + +start_ekka() -> + try mnesia_hook:module_info() of + _ -> ekka:start() + catch _:_ -> + %% Falling back to using Mnesia DB backend. + application:set_env(mria, db_backend, mnesia), + ekka:start() + end.