Selaa lähdekoodia

feat(ds): Add schema for builtin_local backend

ieQu1 1 vuosi sitten
vanhempi
commit
5a8818edf3

+ 5 - 1
apps/emqx/src/emqx_ds_schema.erl

@@ -32,7 +32,11 @@
 %% Type declarations
 %%================================================================================
 
--if(defined(EMQX_RELEASE_EDITION) andalso EMQX_RELEASE_EDITION == ee).
+-ifndef(EMQX_RELEASE_EDITION).
+-define(EMQX_RELEASE_EDITION, ce).
+-endif.
+
+-if(?EMQX_RELEASE_EDITION == ee).
 -define(DEFAULT_BACKEND, builtin_raft).
 -define(BUILTIN_BACKENDS, [ref(builtin_raft), ref(builtin_local)]).
 -else.

+ 20 - 15
apps/emqx_ds_backends/test/emqx_ds_backends_SUITE.erl

@@ -553,9 +553,17 @@ delete(DB, It0, Selector, BatchSize, Acc) ->
 -if(?EMQX_RELEASE_EDITION == ee).
 all() ->
     [{group, builtin_local}, {group, builtin_raft}].
+
+%% kernel-10 OTP application (OTP 27) introduces
+%% `optional_applications` application spec flag. Once we migrate to
+%% OTP27, this won't be needed, as application controller will
+%% automatically load raft backend when available:
+-define(MAYBE_RAFT, [emqx_ds_builtin_raft]).
 -else.
 all() ->
     [{group, builtin_local}].
+
+-define(MAYBE_RAFT, []).
 -endif.
 
 groups() ->
@@ -587,25 +595,22 @@ end_per_group(_Group, Config) ->
     Config.
 
 init_per_suite(Config) ->
-    emqx_common_test_helpers:clear_screen(),
-    Apps = emqx_cth_suite:start(
-        [mria, emqx_ds_backends],
-        #{work_dir => ?config(priv_dir, Config)}
-    ),
-    [{apps, Apps} | Config].
+    Config.
 
-end_per_suite(Config) ->
-    ok = emqx_cth_suite:stop(?config(apps, Config)),
+end_per_suite(_Config) ->
     ok.
 
-init_per_testcase(_TC, Config) ->
-    application:ensure_all_started(emqx_durable_storage),
-    Config.
+init_per_testcase(TC, Config) ->
+    Apps = emqx_cth_suite:start(
+        [emqx_durable_storage, emqx_ds_backends | ?MAYBE_RAFT],
+        #{work_dir => emqx_cth_suite:work_dir(TC, Config)}
+    ),
+    ct:pal("Apps: ~p", [Apps]),
+    [{apps, Apps} | Config].
 
-end_per_testcase(TC, _Config) ->
+end_per_testcase(TC, Config) ->
     ok = emqx_ds:drop_db(TC),
-    snabbkaffe:stop(),
-    ok = application:stop(emqx_durable_storage),
-    mria:stop(),
+    ok = emqx_cth_suite:stop(?config(apps, Config)),
     _ = mnesia:delete_schema([node()]),
+    snabbkaffe:stop(),
     ok.

+ 2 - 0
apps/emqx_machine/src/emqx_machine_boot.erl

@@ -188,6 +188,8 @@ runtime_deps() ->
         {emqx_connector, fun(App) -> lists:prefix("emqx_bridge_", atom_to_list(App)) end},
         %% emqx_fdb is an EE app
         {emqx_durable_storage, emqx_fdb},
+        %% emqx_ds_builtin is an EE app
+        {emqx_ds_backends, emqx_ds_builtin_raft},
         {emqx_dashboard, emqx_license}
     ].