test: render config for emqx_conf only for ee bridge tests
This commit is contained in:
parent
c87c9e886e
commit
dc14cd450d
|
@ -33,7 +33,8 @@
|
||||||
proj_root/0,
|
proj_root/0,
|
||||||
deps_path/2,
|
deps_path/2,
|
||||||
flush/0,
|
flush/0,
|
||||||
flush/1
|
flush/1,
|
||||||
|
render_and_load_app_config/1
|
||||||
]).
|
]).
|
||||||
|
|
||||||
-export([
|
-export([
|
||||||
|
@ -167,14 +168,6 @@ start_apps(Apps, SpecAppConfig) when is_function(SpecAppConfig) ->
|
||||||
%% Load all application code to beam vm first
|
%% Load all application code to beam vm first
|
||||||
%% Because, minirest, ekka etc.. application will scan these modules
|
%% Because, minirest, ekka etc.. application will scan these modules
|
||||||
lists:foreach(fun load/1, [emqx | Apps]),
|
lists:foreach(fun load/1, [emqx | Apps]),
|
||||||
%% load emqx_conf config before starting ekka
|
|
||||||
case application:load(emqx_conf) of
|
|
||||||
{error, _} ->
|
|
||||||
%% running test only for emqx app (standalone)
|
|
||||||
ok;
|
|
||||||
_ ->
|
|
||||||
render_and_load_app_config(emqx_conf)
|
|
||||||
end,
|
|
||||||
ok = start_ekka(),
|
ok = start_ekka(),
|
||||||
ok = emqx_ratelimiter_SUITE:load_conf(),
|
ok = emqx_ratelimiter_SUITE:load_conf(),
|
||||||
lists:foreach(fun(App) -> start_app(App, SpecAppConfig) end, [emqx | Apps]).
|
lists:foreach(fun(App) -> start_app(App, SpecAppConfig) end, [emqx | Apps]).
|
||||||
|
@ -187,6 +180,7 @@ load(App) ->
|
||||||
end.
|
end.
|
||||||
|
|
||||||
render_and_load_app_config(App) ->
|
render_and_load_app_config(App) ->
|
||||||
|
load(App),
|
||||||
Schema = app_schema(App),
|
Schema = app_schema(App),
|
||||||
Conf = app_path(App, filename:join(["etc", app_conf_file(App)])),
|
Conf = app_path(App, filename:join(["etc", app_conf_file(App)])),
|
||||||
try
|
try
|
||||||
|
|
|
@ -67,6 +67,8 @@ init_per_suite(Config) ->
|
||||||
%% Need to unload emqx_authz. See emqx_machine_SUITE:init_per_suite for
|
%% Need to unload emqx_authz. See emqx_machine_SUITE:init_per_suite for
|
||||||
%% more info.
|
%% more info.
|
||||||
application:unload(emqx_authz),
|
application:unload(emqx_authz),
|
||||||
|
%% some configs in emqx_conf app are mandatory
|
||||||
|
emqx_common_test_helpers:render_and_load_app_config(emqx_conf),
|
||||||
emqx_common_test_helpers:start_apps(
|
emqx_common_test_helpers:start_apps(
|
||||||
[emqx_conf, emqx_rule_engine, emqx_bridge, emqx_management, emqx_dashboard],
|
[emqx_conf, emqx_rule_engine, emqx_bridge, emqx_management, emqx_dashboard],
|
||||||
fun set_special_configs/1
|
fun set_special_configs/1
|
||||||
|
|
|
@ -89,8 +89,7 @@ init_per_group(InfluxDBType, Config0) when
|
||||||
ProxyHost = os:getenv("PROXY_HOST", "toxiproxy"),
|
ProxyHost = os:getenv("PROXY_HOST", "toxiproxy"),
|
||||||
ProxyPort = list_to_integer(os:getenv("PROXY_PORT", "8474")),
|
ProxyPort = list_to_integer(os:getenv("PROXY_PORT", "8474")),
|
||||||
emqx_common_test_helpers:reset_proxy(ProxyHost, ProxyPort),
|
emqx_common_test_helpers:reset_proxy(ProxyHost, ProxyPort),
|
||||||
ok = emqx_common_test_helpers:start_apps([emqx_conf]),
|
ok = start_apps(),
|
||||||
ok = emqx_connector_test_helpers:start_apps([emqx_resource, emqx_bridge]),
|
|
||||||
{ok, _} = application:ensure_all_started(emqx_connector),
|
{ok, _} = application:ensure_all_started(emqx_connector),
|
||||||
Config = [{use_tls, UseTLS} | Config0],
|
Config = [{use_tls, UseTLS} | Config0],
|
||||||
{Name, ConfigString, InfluxDBConfig} = influxdb_config(
|
{Name, ConfigString, InfluxDBConfig} = influxdb_config(
|
||||||
|
@ -158,8 +157,7 @@ init_per_group(InfluxDBType, Config0) when
|
||||||
ProxyHost = os:getenv("PROXY_HOST", "toxiproxy"),
|
ProxyHost = os:getenv("PROXY_HOST", "toxiproxy"),
|
||||||
ProxyPort = list_to_integer(os:getenv("PROXY_PORT", "8474")),
|
ProxyPort = list_to_integer(os:getenv("PROXY_PORT", "8474")),
|
||||||
emqx_common_test_helpers:reset_proxy(ProxyHost, ProxyPort),
|
emqx_common_test_helpers:reset_proxy(ProxyHost, ProxyPort),
|
||||||
ok = emqx_common_test_helpers:start_apps([emqx_conf]),
|
ok = start_apps(),
|
||||||
ok = emqx_connector_test_helpers:start_apps([emqx_resource, emqx_bridge]),
|
|
||||||
{ok, _} = application:ensure_all_started(emqx_connector),
|
{ok, _} = application:ensure_all_started(emqx_connector),
|
||||||
Config = [{use_tls, UseTLS} | Config0],
|
Config = [{use_tls, UseTLS} | Config0],
|
||||||
{Name, ConfigString, InfluxDBConfig} = influxdb_config(
|
{Name, ConfigString, InfluxDBConfig} = influxdb_config(
|
||||||
|
@ -855,3 +853,11 @@ t_write_failure(Config) ->
|
||||||
end
|
end
|
||||||
),
|
),
|
||||||
ok.
|
ok.
|
||||||
|
|
||||||
|
start_apps() ->
|
||||||
|
%% some configs in emqx_conf app are mandatory
|
||||||
|
%% we want to make sure they are loaded before
|
||||||
|
%% ekka start in emqx_common_test_helpers:start_apps/1
|
||||||
|
emqx_common_test_helpers:render_and_load_app_config(emqx_conf),
|
||||||
|
ok = emqx_common_test_helpers:start_apps([emqx_conf]),
|
||||||
|
ok = emqx_connector_test_helpers:start_apps([emqx_resource, emqx_bridge]).
|
||||||
|
|
|
@ -40,8 +40,7 @@ init_per_group(Type = rs, Config) ->
|
||||||
MongoPort = list_to_integer(os:getenv("MONGO_RS_PORT", "27017")),
|
MongoPort = list_to_integer(os:getenv("MONGO_RS_PORT", "27017")),
|
||||||
case emqx_common_test_helpers:is_tcp_server_available(MongoHost, MongoPort) of
|
case emqx_common_test_helpers:is_tcp_server_available(MongoHost, MongoPort) of
|
||||||
true ->
|
true ->
|
||||||
ensure_loaded(),
|
ok = start_apps(),
|
||||||
ok = emqx_common_test_helpers:start_apps([emqx_conf, emqx_bridge]),
|
|
||||||
emqx_mgmt_api_test_util:init_suite(),
|
emqx_mgmt_api_test_util:init_suite(),
|
||||||
{Name, MongoConfig} = mongo_config(MongoHost, MongoPort, Type),
|
{Name, MongoConfig} = mongo_config(MongoHost, MongoPort, Type),
|
||||||
[
|
[
|
||||||
|
@ -60,8 +59,7 @@ init_per_group(Type = sharded, Config) ->
|
||||||
MongoPort = list_to_integer(os:getenv("MONGO_SHARDED_PORT", "27017")),
|
MongoPort = list_to_integer(os:getenv("MONGO_SHARDED_PORT", "27017")),
|
||||||
case emqx_common_test_helpers:is_tcp_server_available(MongoHost, MongoPort) of
|
case emqx_common_test_helpers:is_tcp_server_available(MongoHost, MongoPort) of
|
||||||
true ->
|
true ->
|
||||||
ensure_loaded(),
|
ok = start_apps(),
|
||||||
ok = emqx_common_test_helpers:start_apps([emqx_conf, emqx_bridge]),
|
|
||||||
emqx_mgmt_api_test_util:init_suite(),
|
emqx_mgmt_api_test_util:init_suite(),
|
||||||
{Name, MongoConfig} = mongo_config(MongoHost, MongoPort, Type),
|
{Name, MongoConfig} = mongo_config(MongoHost, MongoPort, Type),
|
||||||
[
|
[
|
||||||
|
@ -80,8 +78,7 @@ init_per_group(Type = single, Config) ->
|
||||||
MongoPort = list_to_integer(os:getenv("MONGO_SINGLE_PORT", "27017")),
|
MongoPort = list_to_integer(os:getenv("MONGO_SINGLE_PORT", "27017")),
|
||||||
case emqx_common_test_helpers:is_tcp_server_available(MongoHost, MongoPort) of
|
case emqx_common_test_helpers:is_tcp_server_available(MongoHost, MongoPort) of
|
||||||
true ->
|
true ->
|
||||||
ensure_loaded(),
|
ok = start_apps(),
|
||||||
ok = emqx_common_test_helpers:start_apps([emqx_conf, emqx_bridge]),
|
|
||||||
emqx_mgmt_api_test_util:init_suite(),
|
emqx_mgmt_api_test_util:init_suite(),
|
||||||
{Name, MongoConfig} = mongo_config(MongoHost, MongoPort, Type),
|
{Name, MongoConfig} = mongo_config(MongoHost, MongoPort, Type),
|
||||||
[
|
[
|
||||||
|
@ -121,6 +118,14 @@ end_per_testcase(_Testcase, Config) ->
|
||||||
%% Helper fns
|
%% Helper fns
|
||||||
%%------------------------------------------------------------------------------
|
%%------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
start_apps() ->
|
||||||
|
ensure_loaded(),
|
||||||
|
%% some configs in emqx_conf app are mandatory,
|
||||||
|
%% we want to make sure they are loaded before
|
||||||
|
%% ekka start in emqx_common_test_helpers:start_apps/1
|
||||||
|
emqx_common_test_helpers:render_and_load_app_config(emqx_conf),
|
||||||
|
ok = emqx_common_test_helpers:start_apps([emqx_conf, emqx_bridge]).
|
||||||
|
|
||||||
ensure_loaded() ->
|
ensure_loaded() ->
|
||||||
_ = application:load(emqx_ee_bridge),
|
_ = application:load(emqx_ee_bridge),
|
||||||
_ = emqx_ee_bridge:module_info(),
|
_ = emqx_ee_bridge:module_info(),
|
||||||
|
|
Loading…
Reference in New Issue