fix(clickhouse): start app in tests
Otherwise, depending on the test execution order, tests might sometimes fail. Moreover, ensure that applications describe their dependecies correctly and avoid starting irrelevant apps in tests.
This commit is contained in:
parent
e4701a71da
commit
ba6b208df2
|
@ -2,7 +2,7 @@
|
|||
{description, "EMQX Enterprise ClickHouse Bridge"},
|
||||
{vsn, "0.2.0"},
|
||||
{registered, []},
|
||||
{applications, [kernel, stdlib, clickhouse]},
|
||||
{applications, [kernel, stdlib, clickhouse, emqx_resource]},
|
||||
{env, []},
|
||||
{modules, []},
|
||||
{links, []}
|
||||
|
|
|
@ -3,7 +3,6 @@
|
|||
%%--------------------------------------------------------------------
|
||||
-module(emqx_bridge_clickhouse).
|
||||
|
||||
-include_lib("emqx_bridge/include/emqx_bridge.hrl").
|
||||
-include_lib("typerefl/include/types.hrl").
|
||||
-include_lib("hocon/include/hoconsc.hrl").
|
||||
-include_lib("emqx_resource/include/emqx_resource.hrl").
|
||||
|
|
|
@ -7,6 +7,7 @@
|
|||
-compile(nowarn_export_all).
|
||||
-compile(export_all).
|
||||
|
||||
-define(APP, emqx_bridge_clickhouse).
|
||||
-define(CLICKHOUSE_HOST, "clickhouse").
|
||||
-include_lib("emqx_connector/include/emqx_connector.hrl").
|
||||
|
||||
|
@ -25,10 +26,7 @@ init_per_suite(Config) ->
|
|||
true ->
|
||||
emqx_common_test_helpers:render_and_load_app_config(emqx_conf),
|
||||
ok = emqx_common_test_helpers:start_apps([emqx_conf, emqx_bridge]),
|
||||
ok = emqx_connector_test_helpers:start_apps([emqx_resource]),
|
||||
{ok, _} = application:ensure_all_started(emqx_connector),
|
||||
{ok, _} = application:ensure_all_started(emqx_ee_connector),
|
||||
{ok, _} = application:ensure_all_started(emqx_ee_bridge),
|
||||
ok = emqx_connector_test_helpers:start_apps([emqx_resource, ?APP]),
|
||||
snabbkaffe:fix_ct_logging(),
|
||||
%% Create the db table
|
||||
Conn = start_clickhouse_connection(),
|
||||
|
@ -75,11 +73,8 @@ start_clickhouse_connection() ->
|
|||
end_per_suite(Config) ->
|
||||
ClickhouseConnection = proplists:get_value(clickhouse_connection, Config),
|
||||
clickhouse:stop(ClickhouseConnection),
|
||||
ok = emqx_common_test_helpers:stop_apps([emqx_conf]),
|
||||
ok = emqx_connector_test_helpers:stop_apps([emqx_resource]),
|
||||
_ = application:stop(emqx_connector),
|
||||
_ = application:stop(emqx_ee_connector),
|
||||
_ = application:stop(emqx_bridge).
|
||||
ok = emqx_connector_test_helpers:stop_apps([?APP, emqx_resource]),
|
||||
ok = emqx_common_test_helpers:stop_apps([emqx_bridge, emqx_conf]).
|
||||
|
||||
init_per_testcase(_, Config) ->
|
||||
reset_table(Config),
|
||||
|
|
|
@ -9,9 +9,9 @@
|
|||
|
||||
-include("emqx_connector.hrl").
|
||||
-include_lib("eunit/include/eunit.hrl").
|
||||
-include_lib("emqx/include/emqx.hrl").
|
||||
-include_lib("stdlib/include/assert.hrl").
|
||||
|
||||
-define(APP, emqx_bridge_clickhouse).
|
||||
-define(CLICKHOUSE_HOST, "clickhouse").
|
||||
-define(CLICKHOUSE_RESOURCE_MOD, emqx_bridge_clickhouse_connector).
|
||||
|
||||
|
@ -51,9 +51,7 @@ init_per_suite(Config) ->
|
|||
of
|
||||
true ->
|
||||
ok = emqx_common_test_helpers:start_apps([emqx_conf]),
|
||||
ok = emqx_connector_test_helpers:start_apps([emqx_resource]),
|
||||
{ok, _} = application:ensure_all_started(emqx_connector),
|
||||
{ok, _} = application:ensure_all_started(emqx_ee_connector),
|
||||
ok = emqx_connector_test_helpers:start_apps([emqx_resource, ?APP]),
|
||||
%% Create the db table
|
||||
{ok, Conn} =
|
||||
clickhouse:start_link([
|
||||
|
@ -76,8 +74,7 @@ init_per_suite(Config) ->
|
|||
|
||||
end_per_suite(_Config) ->
|
||||
ok = emqx_common_test_helpers:stop_apps([emqx_conf]),
|
||||
ok = emqx_connector_test_helpers:stop_apps([emqx_resource]),
|
||||
_ = application:stop(emqx_connector).
|
||||
ok = emqx_connector_test_helpers:stop_apps([?APP, emqx_resource]).
|
||||
|
||||
init_per_testcase(_, Config) ->
|
||||
Config.
|
||||
|
|
|
@ -9,6 +9,7 @@
|
|||
stdlib,
|
||||
gproc,
|
||||
jsx,
|
||||
ecpool,
|
||||
emqx,
|
||||
telemetry
|
||||
]},
|
||||
|
|
Loading…
Reference in New Issue