fix(emqx_schema): start emqx as standalone app failed

This commit is contained in:
Shawn 2021-07-17 10:19:06 +08:00
parent dfa9026ea3
commit 7a77f4f54e
6 changed files with 31 additions and 1 deletions

View File

@ -61,8 +61,11 @@
structs() -> ["cluster", "node", "rpc", "log", "lager", structs() -> ["cluster", "node", "rpc", "log", "lager",
"zones", "listeners", "broker", "zones", "listeners", "broker",
"plugins", "sysmon", "alarm"] "plugins", "sysmon", "alarm"]
++ includes(). ++ ?MODULE:includes().
-ifdef(TEST).
includes() ->[].
-else.
includes() -> includes() ->
[ "emqx_data_bridge" [ "emqx_data_bridge"
, "emqx_telemetry" , "emqx_telemetry"
@ -75,6 +78,7 @@ includes() ->
, "emqx_management" , "emqx_management"
, "emqx_gateway" , "emqx_gateway"
]. ].
-endif.
fields("cluster") -> fields("cluster") ->
[ {"name", t(atom(), "ekka.cluster_name", emqxcl)} [ {"name", t(atom(), "ekka.cluster_name", emqxcl)}

View File

@ -43,6 +43,10 @@ groups() ->
[]. [].
init_per_suite(Config) -> init_per_suite(Config) ->
%% important! let emqx_schema include the current app!
meck:new(emqx_schema, [non_strict, passthrough, no_history, no_link]),
meck:expect(emqx_schema, includes, fun() -> ["emqx_authz"] end ),
ok = emqx_ct_helpers:start_apps([emqx_authz, emqx_management], fun set_special_configs/1), ok = emqx_ct_helpers:start_apps([emqx_authz, emqx_management], fun set_special_configs/1),
create_default_app(), create_default_app(),
Config. Config.
@ -50,6 +54,7 @@ init_per_suite(Config) ->
end_per_suite(_Config) -> end_per_suite(_Config) ->
delete_default_app(), delete_default_app(),
file:delete(filename:join(emqx:get_env(plugins_etc_dir), 'authz.conf')), file:delete(filename:join(emqx:get_env(plugins_etc_dir), 'authz.conf')),
meck:unload(emqx_schema),
emqx_ct_helpers:stop_apps([emqx_authz, emqx_management]). emqx_ct_helpers:stop_apps([emqx_authz, emqx_management]).
set_special_configs(emqx) -> set_special_configs(emqx) ->

View File

@ -31,6 +31,11 @@ groups() ->
init_per_suite(Config) -> init_per_suite(Config) ->
meck:new(emqx_resource, [non_strict, passthrough, no_history, no_link]), meck:new(emqx_resource, [non_strict, passthrough, no_history, no_link]),
meck:expect(emqx_resource, create, fun(_, _, _) -> {ok, meck_data} end ), meck:expect(emqx_resource, create, fun(_, _, _) -> {ok, meck_data} end ),
%% important! let emqx_schema include the current app!
meck:new(emqx_schema, [non_strict, passthrough, no_history, no_link]),
meck:expect(emqx_schema, includes, fun() -> ["emqx_authz"] end ),
ok = emqx_ct_helpers:start_apps([emqx_authz]), ok = emqx_ct_helpers:start_apps([emqx_authz]),
ct:pal("---- emqx_hooks: ~p", [ets:tab2list(emqx_hooks)]), ct:pal("---- emqx_hooks: ~p", [ets:tab2list(emqx_hooks)]),
ok = emqx_config:update_config([zones, default, acl, cache, enable], false), ok = emqx_config:update_config([zones, default, acl, cache, enable], false),
@ -52,6 +57,7 @@ init_per_suite(Config) ->
end_per_suite(_Config) -> end_per_suite(_Config) ->
file:delete(filename:join(emqx:get_env(plugins_etc_dir), 'authz.conf')), file:delete(filename:join(emqx:get_env(plugins_etc_dir), 'authz.conf')),
emqx_ct_helpers:stop_apps([emqx_authz, emqx_resource]), emqx_ct_helpers:stop_apps([emqx_authz, emqx_resource]),
meck:unload(emqx_schema),
meck:unload(emqx_resource). meck:unload(emqx_resource).
-define(RULE1,[#{<<"topics">> => [<<"#">>], -define(RULE1,[#{<<"topics">> => [<<"#">>],

View File

@ -29,6 +29,10 @@ groups() ->
[]. [].
init_per_suite(Config) -> init_per_suite(Config) ->
%% important! let emqx_schema include the current app!
meck:new(emqx_schema, [non_strict, passthrough, no_history, no_link]),
meck:expect(emqx_schema, includes, fun() -> ["emqx_authz"] end ),
meck:new(emqx_resource, [non_strict, passthrough, no_history, no_link]), meck:new(emqx_resource, [non_strict, passthrough, no_history, no_link]),
meck:expect(emqx_resource, create, fun(_, _, _) -> {ok, meck_data} end ), meck:expect(emqx_resource, create, fun(_, _, _) -> {ok, meck_data} end ),
ok = emqx_ct_helpers:start_apps([emqx_authz]), ok = emqx_ct_helpers:start_apps([emqx_authz]),
@ -52,6 +56,7 @@ init_per_suite(Config) ->
end_per_suite(_Config) -> end_per_suite(_Config) ->
file:delete(filename:join(emqx:get_env(plugins_etc_dir), 'authz.conf')), file:delete(filename:join(emqx:get_env(plugins_etc_dir), 'authz.conf')),
emqx_ct_helpers:stop_apps([emqx_authz, emqx_resource]), emqx_ct_helpers:stop_apps([emqx_authz, emqx_resource]),
meck:unload(emqx_schema),
meck:unload(emqx_resource). meck:unload(emqx_resource).
-define(COLUMNS, [ <<"ipaddress">> -define(COLUMNS, [ <<"ipaddress">>

View File

@ -29,6 +29,10 @@ groups() ->
[]. [].
init_per_suite(Config) -> init_per_suite(Config) ->
%% important! let emqx_schema include the current app!
meck:new(emqx_schema, [non_strict, passthrough, no_history, no_link]),
meck:expect(emqx_schema, includes, fun() -> ["emqx_authz"] end ),
meck:new(emqx_resource, [non_strict, passthrough, no_history, no_link]), meck:new(emqx_resource, [non_strict, passthrough, no_history, no_link]),
meck:expect(emqx_resource, create, fun(_, _, _) -> {ok, meck_data} end ), meck:expect(emqx_resource, create, fun(_, _, _) -> {ok, meck_data} end ),
ok = emqx_ct_helpers:start_apps([emqx_authz]), ok = emqx_ct_helpers:start_apps([emqx_authz]),
@ -51,6 +55,7 @@ init_per_suite(Config) ->
end_per_suite(_Config) -> end_per_suite(_Config) ->
file:delete(filename:join(emqx:get_env(plugins_etc_dir), 'authz.conf')), file:delete(filename:join(emqx:get_env(plugins_etc_dir), 'authz.conf')),
emqx_ct_helpers:stop_apps([emqx_authz, emqx_resource]), emqx_ct_helpers:stop_apps([emqx_authz, emqx_resource]),
meck:unload(emqx_schema),
meck:unload(emqx_resource). meck:unload(emqx_resource).
-define(COLUMNS, [ {column, <<"ipaddress">>, meck, meck, meck, meck, meck, meck, meck} -define(COLUMNS, [ {column, <<"ipaddress">>, meck, meck, meck, meck, meck, meck, meck}

View File

@ -29,6 +29,10 @@ groups() ->
[]. [].
init_per_suite(Config) -> init_per_suite(Config) ->
%% important! let emqx_schema include the current app!
meck:new(emqx_schema, [non_strict, passthrough, no_history, no_link]),
meck:expect(emqx_schema, includes, fun() -> ["emqx_authz"] end ),
meck:new(emqx_resource, [non_strict, passthrough, no_history, no_link]), meck:new(emqx_resource, [non_strict, passthrough, no_history, no_link]),
meck:expect(emqx_resource, create, fun(_, _, _) -> {ok, meck_data} end ), meck:expect(emqx_resource, create, fun(_, _, _) -> {ok, meck_data} end ),
ok = emqx_ct_helpers:start_apps([emqx_authz]), ok = emqx_ct_helpers:start_apps([emqx_authz]),
@ -50,6 +54,7 @@ init_per_suite(Config) ->
end_per_suite(_Config) -> end_per_suite(_Config) ->
file:delete(filename:join(emqx:get_env(plugins_etc_dir), 'authz.conf')), file:delete(filename:join(emqx:get_env(plugins_etc_dir), 'authz.conf')),
emqx_ct_helpers:stop_apps([emqx_authz, emqx_resource]), emqx_ct_helpers:stop_apps([emqx_authz, emqx_resource]),
meck:unload(emqx_schema),
meck:unload(emqx_resource). meck:unload(emqx_resource).
-define(RULE1, [<<"test/%u">>, <<"publish">>]). -define(RULE1, [<<"test/%u">>, <<"publish">>]).