test: merge broker and router boot modules

This commit is contained in:
Zaiming (Stone) Shi 2023-09-06 21:36:16 +02:00
parent 18c6bfec97
commit 7c2f87fabe
11 changed files with 14 additions and 21 deletions

View File

@ -18,9 +18,9 @@
-export([is_enabled/1]). -export([is_enabled/1]).
-define(BOOT_MODULES, [router, broker, listeners]). -define(BOOT_MODULES, [broker, listeners]).
-spec is_enabled(all | router | broker | listeners) -> boolean(). -spec is_enabled(all | broker | listeners) -> boolean().
is_enabled(Mod) -> is_enabled(Mod) ->
(BootMods = boot_modules()) =:= all orelse lists:member(Mod, BootMods). (BootMods = boot_modules()) =:= all orelse lists:member(Mod, BootMods).

View File

@ -74,7 +74,7 @@ init([]) ->
Children = Children =
[KernelSup] ++ [KernelSup] ++
[SessionSup || emqx_persistent_session:is_store_enabled()] ++ [SessionSup || emqx_persistent_session:is_store_enabled()] ++
[RouterSup || emqx_boot:is_enabled(router)] ++ [RouterSup || emqx_boot:is_enabled(broker)] ++
[BrokerSup || emqx_boot:is_enabled(broker)] ++ [BrokerSup || emqx_boot:is_enabled(broker)] ++
[CMSup || emqx_boot:is_enabled(broker)] ++ [CMSup || emqx_boot:is_enabled(broker)] ++
[SysSup, Limiter], [SysSup, Limiter],

View File

@ -26,7 +26,7 @@
all() -> emqx_common_test_helpers:all(?MODULE). all() -> emqx_common_test_helpers:all(?MODULE).
init_per_suite(Config) -> init_per_suite(Config) ->
emqx_common_test_helpers:boot_modules([router, broker]), emqx_common_test_helpers:boot_modules([broker]),
emqx_common_test_helpers:start_apps([]), emqx_common_test_helpers:start_apps([]),
Config. Config.

View File

@ -26,19 +26,12 @@ all() -> emqx_common_test_helpers:all(?MODULE).
t_is_enabled(_) -> t_is_enabled(_) ->
try try
ok = application:set_env(emqx, boot_modules, all), ok = application:set_env(emqx, boot_modules, all),
?assert(emqx_boot:is_enabled(router)),
?assert(emqx_boot:is_enabled(broker)), ?assert(emqx_boot:is_enabled(broker)),
?assert(emqx_boot:is_enabled(listeners)), ?assert(emqx_boot:is_enabled(listeners)),
ok = application:set_env(emqx, boot_modules, [router]), ok = application:set_env(emqx, boot_modules, [broker]),
?assert(emqx_boot:is_enabled(router)),
?assertNot(emqx_boot:is_enabled(broker)),
?assertNot(emqx_boot:is_enabled(listeners)),
ok = application:set_env(emqx, boot_modules, [router, broker]),
?assert(emqx_boot:is_enabled(router)),
?assert(emqx_boot:is_enabled(broker)), ?assert(emqx_boot:is_enabled(broker)),
?assertNot(emqx_boot:is_enabled(listeners)), ?assertNot(emqx_boot:is_enabled(listeners)),
ok = application:set_env(emqx, boot_modules, [router, broker, listeners]), ok = application:set_env(emqx, boot_modules, [broker, listeners]),
?assert(emqx_boot:is_enabled(router)),
?assert(emqx_boot:is_enabled(broker)), ?assert(emqx_boot:is_enabled(broker)),
?assert(emqx_boot:is_enabled(listeners)) ?assert(emqx_boot:is_enabled(listeners))
after after

View File

@ -44,7 +44,7 @@ init_per_group(GroupName, Config) ->
AppSpecs = [ AppSpecs = [
{emqx, #{ {emqx, #{
config => mk_config(GroupName), config => mk_config(GroupName),
override_env => [{boot_modules, [router]}] override_env => [{boot_modules, [broker]}]
}} }}
], ],
Apps = emqx_cth_suite:start(AppSpecs, #{work_dir => WorkDir}), Apps = emqx_cth_suite:start(AppSpecs, #{work_dir => WorkDir}),

View File

@ -51,12 +51,12 @@ end_per_group(_GroupName, Config) ->
mk_config(routing_schema_v1) -> mk_config(routing_schema_v1) ->
#{ #{
config => "broker.routing.storage_schema = v1", config => "broker.routing.storage_schema = v1",
override_env => [{boot_modules, [router]}] override_env => [{boot_modules, [broker]}]
}; };
mk_config(routing_schema_v2) -> mk_config(routing_schema_v2) ->
#{ #{
config => "broker.routing.storage_schema = v2", config => "broker.routing.storage_schema = v2",
override_env => [{boot_modules, [router]}] override_env => [{boot_modules, [broker]}]
}. }.
init_per_testcase(_TestCase, Config) -> init_per_testcase(_TestCase, Config) ->

View File

@ -577,7 +577,7 @@ cluster(Config) ->
{schema_mod, emqx_enterprise_schema}, {schema_mod, emqx_enterprise_schema},
{env_handler, fun {env_handler, fun
(emqx) -> (emqx) ->
application:set_env(emqx, boot_modules, [broker, router]), application:set_env(emqx, boot_modules, [broker]),
ok; ok;
(emqx_conf) -> (emqx_conf) ->
ok; ok;

View File

@ -1101,7 +1101,7 @@ cluster(Config) ->
{load_apps, [emqx_machine]}, {load_apps, [emqx_machine]},
{env_handler, fun {env_handler, fun
(emqx) -> (emqx) ->
application:set_env(emqx, boot_modules, [broker, router]), application:set_env(emqx, boot_modules, [broker]),
ExtraEnvHandlerHook(), ExtraEnvHandlerHook(),
ok; ok;
(emqx_conf) -> (emqx_conf) ->

View File

@ -536,7 +536,7 @@ cluster(Config) ->
{schema_mod, emqx_enterprise_schema}, {schema_mod, emqx_enterprise_schema},
{env_handler, fun {env_handler, fun
(emqx) -> (emqx) ->
application:set_env(emqx, boot_modules, [broker, router]), application:set_env(emqx, boot_modules, [broker]),
ok; ok;
(emqx_conf) -> (emqx_conf) ->
ok; ok;

View File

@ -432,7 +432,7 @@ create_test_tab(Attributes) ->
apps_to_start() -> apps_to_start() ->
[ [
{emqx, #{override_env => [{boot_modules, [broker, router]}]}}, {emqx, #{override_env => [{boot_modules, [broker]}]}},
{emqx_conf, #{config => #{dashboard => #{listeners => #{http => #{bind => <<"0">>}}}}}}, {emqx_conf, #{config => #{dashboard => #{listeners => #{http => #{bind => <<"0">>}}}}}},
emqx_psk, emqx_psk,
emqx_management, emqx_management,

View File

@ -368,7 +368,7 @@ cluster(Config) ->
{load_apps, [emqx_machine]}, {load_apps, [emqx_machine]},
{env_handler, fun {env_handler, fun
(emqx) -> (emqx) ->
application:set_env(emqx, boot_modules, [broker, router]), application:set_env(emqx, boot_modules, [broker]),
ok; ok;
(emqx_conf) -> (emqx_conf) ->
ok; ok;