Explorar o código

fix(test): make mria fall back to use mnesia db_backend when running test

Shawn %!s(int64=3) %!d(string=hai) anos
pai
achega
56044085c8
Modificáronse 1 ficheiros con 10 adicións e 1 borrados
  1. 10 1
      apps/emqx/test/emqx_common_test_helpers.erl

+ 10 - 1
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.