From 11c169501efa75644a0f60949f6b275da2d6a26c Mon Sep 17 00:00:00 2001 From: Thales Macedo Garitezi Date: Thu, 23 Dec 2021 08:48:11 -0300 Subject: [PATCH] chore(mix): fix app dependencies and reboot apps (emqx_conf) While declaring `emqx_conf` as an application dependency of `emqx_resource` worked for releases, it messed up the startup relationship during tests. Since only removing `emqx_conf` from the `applications` key in `emqx_resource` breaks the list of apps that need to be rebooted on config changes (since `emqx_conf` is not on any apps dependencies list, it was not being added to the final topologically sorted list), we now always add it as a vertex to ensure its presence there. This (apparently) makes the rebar3 release, the mix release and test runs behave normally. --- apps/emqx_machine/src/emqx_machine_boot.erl | 6 ++++++ apps/emqx_machine/test/emqx_machine_SUITE.erl | 2 +- apps/emqx_resource/src/emqx_resource.app.src | 3 +-- 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/apps/emqx_machine/src/emqx_machine_boot.erl b/apps/emqx_machine/src/emqx_machine_boot.erl index 24541990b..2084d3a05 100644 --- a/apps/emqx_machine/src/emqx_machine_boot.erl +++ b/apps/emqx_machine/src/emqx_machine_boot.erl @@ -135,6 +135,12 @@ add_app(G, App, undefined) -> ?SLOG(debug, #{msg => "app_is_not_loaded", app => App}), %% not loaded add_app(G, App, []); +% We ALWAYS want to add `emqx_conf', even if no other app declare a +% dependency on it. Otherwise, emqx may fail to load the config +% schemas, especially in the test profile. +add_app(G, App = emqx_conf, []) -> + digraph:add_vertex(G, App), + ok; add_app(_G, _App, []) -> ok; add_app(G, App, [Dep | Deps]) -> diff --git a/apps/emqx_machine/test/emqx_machine_SUITE.erl b/apps/emqx_machine/test/emqx_machine_SUITE.erl index 03d9e6ba9..a760d2f5f 100644 --- a/apps/emqx_machine/test/emqx_machine_SUITE.erl +++ b/apps/emqx_machine/test/emqx_machine_SUITE.erl @@ -43,7 +43,7 @@ init_per_suite(Config) -> %% application:unload(emqx_authz), - emqx_common_test_helpers:start_apps([]), + emqx_common_test_helpers:start_apps([emqx_conf]), Config. end_per_suite(_Config) -> diff --git a/apps/emqx_resource/src/emqx_resource.app.src b/apps/emqx_resource/src/emqx_resource.app.src index 8e5d12fea..9591c5718 100644 --- a/apps/emqx_resource/src/emqx_resource.app.src +++ b/apps/emqx_resource/src/emqx_resource.app.src @@ -9,8 +9,7 @@ stdlib, gproc, jsx, - emqx, - emqx_conf + emqx ]}, {env,[]}, {modules, []},