fix: reboot emqx_dashboard after emqx_licencse
This commit is contained in:
parent
4eb0260eaf
commit
3bc6e546e0
|
@ -166,8 +166,9 @@ is_app(Name) ->
|
||||||
sorted_reboot_apps() ->
|
sorted_reboot_apps() ->
|
||||||
RebootApps = reboot_apps(),
|
RebootApps = reboot_apps(),
|
||||||
Apps0 = [{App, app_deps(App, RebootApps)} || App <- RebootApps],
|
Apps0 = [{App, app_deps(App, RebootApps)} || App <- RebootApps],
|
||||||
Apps = inject_bridge_deps(Apps0),
|
Apps1 = inject_bridge_deps(Apps0),
|
||||||
sorted_reboot_apps(Apps).
|
Apps2 = inject_dashboard_deps(Apps1),
|
||||||
|
sorted_reboot_apps(Apps2).
|
||||||
|
|
||||||
app_deps(App, RebootApps) ->
|
app_deps(App, RebootApps) ->
|
||||||
case application:get_key(App, applications) of
|
case application:get_key(App, applications) of
|
||||||
|
@ -193,6 +194,18 @@ inject_bridge_deps(RebootAppDeps) ->
|
||||||
end,
|
end,
|
||||||
RebootAppDeps
|
RebootAppDeps
|
||||||
).
|
).
|
||||||
|
inject_dashboard_deps(Reboots) ->
|
||||||
|
Apps = [emqx_license],
|
||||||
|
Deps = lists:filter(fun(App) -> lists:keymember(App, 1, Reboots) end, Apps),
|
||||||
|
lists:map(
|
||||||
|
fun
|
||||||
|
({emqx_dashboard, Deps0}) when is_list(Deps0) ->
|
||||||
|
{emqx_dashboard, Deps0 ++ Deps};
|
||||||
|
(App) ->
|
||||||
|
App
|
||||||
|
end,
|
||||||
|
Reboots
|
||||||
|
).
|
||||||
|
|
||||||
sorted_reboot_apps(Apps) ->
|
sorted_reboot_apps(Apps) ->
|
||||||
G = digraph:new(),
|
G = digraph:new(),
|
||||||
|
@ -201,7 +214,8 @@ sorted_reboot_apps(Apps) ->
|
||||||
case digraph_utils:topsort(G) of
|
case digraph_utils:topsort(G) of
|
||||||
Sorted when is_list(Sorted) ->
|
Sorted when is_list(Sorted) ->
|
||||||
%% ensure emqx_conf boot up first
|
%% ensure emqx_conf boot up first
|
||||||
[emqx_conf | Sorted ++ (NoDepApps -- Sorted)];
|
AllApps = Sorted ++ (NoDepApps -- Sorted),
|
||||||
|
[emqx_conf | lists:delete(emqx_conf, AllApps)];
|
||||||
false ->
|
false ->
|
||||||
Loops = find_loops(G),
|
Loops = find_loops(G),
|
||||||
error({circular_application_dependency, Loops})
|
error({circular_application_dependency, Loops})
|
||||||
|
|
|
@ -24,11 +24,7 @@
|
||||||
-include_lib("common_test/include/ct.hrl").
|
-include_lib("common_test/include/ct.hrl").
|
||||||
-include_lib("snabbkaffe/include/snabbkaffe.hrl").
|
-include_lib("snabbkaffe/include/snabbkaffe.hrl").
|
||||||
|
|
||||||
all() -> emqx_common_test_helpers:all(?MODULE).
|
-define(APPS, [
|
||||||
|
|
||||||
init_per_suite(Config) ->
|
|
||||||
emqx_common_test_helpers:start_apps([emqx_conf, emqx_opentelemetry]),
|
|
||||||
application:set_env(emqx_machine, applications, [
|
|
||||||
emqx_prometheus,
|
emqx_prometheus,
|
||||||
emqx_modules,
|
emqx_modules,
|
||||||
emqx_dashboard,
|
emqx_dashboard,
|
||||||
|
@ -42,7 +38,13 @@ init_per_suite(Config) ->
|
||||||
emqx_auth,
|
emqx_auth,
|
||||||
emqx_plugin,
|
emqx_plugin,
|
||||||
emqx_opentelemetry
|
emqx_opentelemetry
|
||||||
]),
|
]).
|
||||||
|
|
||||||
|
all() -> emqx_common_test_helpers:all(?MODULE).
|
||||||
|
|
||||||
|
init_per_suite(Config) ->
|
||||||
|
emqx_common_test_helpers:start_apps([emqx_conf, emqx_opentelemetry]),
|
||||||
|
application:load(emqx_dashboard),
|
||||||
Config.
|
Config.
|
||||||
|
|
||||||
end_per_suite(_Config) ->
|
end_per_suite(_Config) ->
|
||||||
|
@ -60,7 +62,11 @@ init_per_testcase(t_open_ports_check = TestCase, Config) ->
|
||||||
],
|
],
|
||||||
Nodes = emqx_cth_cluster:start(Cluster, #{work_dir => emqx_cth_suite:work_dir(TestCase, Config)}),
|
Nodes = emqx_cth_cluster:start(Cluster, #{work_dir => emqx_cth_suite:work_dir(TestCase, Config)}),
|
||||||
[{nodes, Nodes} | Config];
|
[{nodes, Nodes} | Config];
|
||||||
|
init_per_testcase(t_sorted_reboot_apps, Config) ->
|
||||||
|
application:set_env(emqx_machine, applications, ?APPS ++ [emqx_license]),
|
||||||
|
Config;
|
||||||
init_per_testcase(_TestCase, Config) ->
|
init_per_testcase(_TestCase, Config) ->
|
||||||
|
application:set_env(emqx_machine, applications, ?APPS),
|
||||||
Config.
|
Config.
|
||||||
|
|
||||||
end_per_testcase(t_custom_shard_transports, Config) ->
|
end_per_testcase(t_custom_shard_transports, Config) ->
|
||||||
|
@ -88,6 +94,12 @@ t_shutdown_reboot(_Config) ->
|
||||||
ok = emqx_machine_boot:stop_apps(),
|
ok = emqx_machine_boot:stop_apps(),
|
||||||
false = emqx:is_running(node()).
|
false = emqx:is_running(node()).
|
||||||
|
|
||||||
|
t_sorted_reboot_apps(_Config) ->
|
||||||
|
Apps = emqx_machine_boot:sorted_reboot_apps(),
|
||||||
|
SortApps = [App || App <- Apps, (App =:= emqx_dashboard orelse App =:= emqx_license)],
|
||||||
|
%% make sure emqx_license start early than emqx_dashboard
|
||||||
|
?assertEqual([emqx_license, emqx_dashboard], SortApps).
|
||||||
|
|
||||||
t_custom_shard_transports(_Config) ->
|
t_custom_shard_transports(_Config) ->
|
||||||
%% used to ensure the atom exists
|
%% used to ensure the atom exists
|
||||||
Shard = test_shard,
|
Shard = test_shard,
|
||||||
|
|
|
@ -0,0 +1 @@
|
||||||
|
Fixed /license API request maybe crash during cluster join processes.
|
Loading…
Reference in New Issue