feat(ds): Add schema for builtin_local backend

This commit is contained in:
ieQu1 2024-06-14 15:47:19 +02:00
parent 4484f30021
commit 5a8818edf3
No known key found for this signature in database
GPG Key ID: 488654DF3FED6FDE
3 changed files with 31 additions and 20 deletions

View File

@ -32,7 +32,11 @@
%% Type declarations %% 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(DEFAULT_BACKEND, builtin_raft).
-define(BUILTIN_BACKENDS, [ref(builtin_raft), ref(builtin_local)]). -define(BUILTIN_BACKENDS, [ref(builtin_raft), ref(builtin_local)]).
-else. -else.

View File

@ -553,9 +553,17 @@ delete(DB, It0, Selector, BatchSize, Acc) ->
-if(?EMQX_RELEASE_EDITION == ee). -if(?EMQX_RELEASE_EDITION == ee).
all() -> all() ->
[{group, builtin_local}, {group, builtin_raft}]. [{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. -else.
all() -> all() ->
[{group, builtin_local}]. [{group, builtin_local}].
-define(MAYBE_RAFT, []).
-endif. -endif.
groups() -> groups() ->
@ -587,25 +595,22 @@ end_per_group(_Group, Config) ->
Config. Config.
init_per_suite(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].
end_per_suite(Config) ->
ok = emqx_cth_suite:stop(?config(apps, Config)),
ok.
init_per_testcase(_TC, Config) ->
application:ensure_all_started(emqx_durable_storage),
Config. Config.
end_per_testcase(TC, _Config) -> end_per_suite(_Config) ->
ok = emqx_ds:drop_db(TC), ok.
snabbkaffe:stop(),
ok = application:stop(emqx_durable_storage), init_per_testcase(TC, Config) ->
mria:stop(), Apps = emqx_cth_suite:start(
_ = mnesia:delete_schema([node()]), [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) ->
ok = emqx_ds:drop_db(TC),
ok = emqx_cth_suite:stop(?config(apps, Config)),
_ = mnesia:delete_schema([node()]),
snabbkaffe:stop(),
ok. ok.

View File

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