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"},
|
{description, "EMQX Enterprise ClickHouse Bridge"},
|
||||||
{vsn, "0.2.0"},
|
{vsn, "0.2.0"},
|
||||||
{registered, []},
|
{registered, []},
|
||||||
{applications, [kernel, stdlib, clickhouse]},
|
{applications, [kernel, stdlib, clickhouse, emqx_resource]},
|
||||||
{env, []},
|
{env, []},
|
||||||
{modules, []},
|
{modules, []},
|
||||||
{links, []}
|
{links, []}
|
||||||
|
|
|
@ -3,7 +3,6 @@
|
||||||
%%--------------------------------------------------------------------
|
%%--------------------------------------------------------------------
|
||||||
-module(emqx_bridge_clickhouse).
|
-module(emqx_bridge_clickhouse).
|
||||||
|
|
||||||
-include_lib("emqx_bridge/include/emqx_bridge.hrl").
|
|
||||||
-include_lib("typerefl/include/types.hrl").
|
-include_lib("typerefl/include/types.hrl").
|
||||||
-include_lib("hocon/include/hoconsc.hrl").
|
-include_lib("hocon/include/hoconsc.hrl").
|
||||||
-include_lib("emqx_resource/include/emqx_resource.hrl").
|
-include_lib("emqx_resource/include/emqx_resource.hrl").
|
||||||
|
|
|
@ -7,6 +7,7 @@
|
||||||
-compile(nowarn_export_all).
|
-compile(nowarn_export_all).
|
||||||
-compile(export_all).
|
-compile(export_all).
|
||||||
|
|
||||||
|
-define(APP, emqx_bridge_clickhouse).
|
||||||
-define(CLICKHOUSE_HOST, "clickhouse").
|
-define(CLICKHOUSE_HOST, "clickhouse").
|
||||||
-include_lib("emqx_connector/include/emqx_connector.hrl").
|
-include_lib("emqx_connector/include/emqx_connector.hrl").
|
||||||
|
|
||||||
|
@ -25,10 +26,7 @@ init_per_suite(Config) ->
|
||||||
true ->
|
true ->
|
||||||
emqx_common_test_helpers:render_and_load_app_config(emqx_conf),
|
emqx_common_test_helpers:render_and_load_app_config(emqx_conf),
|
||||||
ok = emqx_common_test_helpers:start_apps([emqx_conf, emqx_bridge]),
|
ok = emqx_common_test_helpers:start_apps([emqx_conf, emqx_bridge]),
|
||||||
ok = emqx_connector_test_helpers:start_apps([emqx_resource]),
|
ok = emqx_connector_test_helpers:start_apps([emqx_resource, ?APP]),
|
||||||
{ok, _} = application:ensure_all_started(emqx_connector),
|
|
||||||
{ok, _} = application:ensure_all_started(emqx_ee_connector),
|
|
||||||
{ok, _} = application:ensure_all_started(emqx_ee_bridge),
|
|
||||||
snabbkaffe:fix_ct_logging(),
|
snabbkaffe:fix_ct_logging(),
|
||||||
%% Create the db table
|
%% Create the db table
|
||||||
Conn = start_clickhouse_connection(),
|
Conn = start_clickhouse_connection(),
|
||||||
|
@ -75,11 +73,8 @@ start_clickhouse_connection() ->
|
||||||
end_per_suite(Config) ->
|
end_per_suite(Config) ->
|
||||||
ClickhouseConnection = proplists:get_value(clickhouse_connection, Config),
|
ClickhouseConnection = proplists:get_value(clickhouse_connection, Config),
|
||||||
clickhouse:stop(ClickhouseConnection),
|
clickhouse:stop(ClickhouseConnection),
|
||||||
ok = emqx_common_test_helpers:stop_apps([emqx_conf]),
|
ok = emqx_connector_test_helpers:stop_apps([?APP, emqx_resource]),
|
||||||
ok = emqx_connector_test_helpers:stop_apps([emqx_resource]),
|
ok = emqx_common_test_helpers:stop_apps([emqx_bridge, emqx_conf]).
|
||||||
_ = application:stop(emqx_connector),
|
|
||||||
_ = application:stop(emqx_ee_connector),
|
|
||||||
_ = application:stop(emqx_bridge).
|
|
||||||
|
|
||||||
init_per_testcase(_, Config) ->
|
init_per_testcase(_, Config) ->
|
||||||
reset_table(Config),
|
reset_table(Config),
|
||||||
|
|
|
@ -9,9 +9,9 @@
|
||||||
|
|
||||||
-include("emqx_connector.hrl").
|
-include("emqx_connector.hrl").
|
||||||
-include_lib("eunit/include/eunit.hrl").
|
-include_lib("eunit/include/eunit.hrl").
|
||||||
-include_lib("emqx/include/emqx.hrl").
|
|
||||||
-include_lib("stdlib/include/assert.hrl").
|
-include_lib("stdlib/include/assert.hrl").
|
||||||
|
|
||||||
|
-define(APP, emqx_bridge_clickhouse).
|
||||||
-define(CLICKHOUSE_HOST, "clickhouse").
|
-define(CLICKHOUSE_HOST, "clickhouse").
|
||||||
-define(CLICKHOUSE_RESOURCE_MOD, emqx_bridge_clickhouse_connector).
|
-define(CLICKHOUSE_RESOURCE_MOD, emqx_bridge_clickhouse_connector).
|
||||||
|
|
||||||
|
@ -51,9 +51,7 @@ init_per_suite(Config) ->
|
||||||
of
|
of
|
||||||
true ->
|
true ->
|
||||||
ok = emqx_common_test_helpers:start_apps([emqx_conf]),
|
ok = emqx_common_test_helpers:start_apps([emqx_conf]),
|
||||||
ok = emqx_connector_test_helpers:start_apps([emqx_resource]),
|
ok = emqx_connector_test_helpers:start_apps([emqx_resource, ?APP]),
|
||||||
{ok, _} = application:ensure_all_started(emqx_connector),
|
|
||||||
{ok, _} = application:ensure_all_started(emqx_ee_connector),
|
|
||||||
%% Create the db table
|
%% Create the db table
|
||||||
{ok, Conn} =
|
{ok, Conn} =
|
||||||
clickhouse:start_link([
|
clickhouse:start_link([
|
||||||
|
@ -76,8 +74,7 @@ init_per_suite(Config) ->
|
||||||
|
|
||||||
end_per_suite(_Config) ->
|
end_per_suite(_Config) ->
|
||||||
ok = emqx_common_test_helpers:stop_apps([emqx_conf]),
|
ok = emqx_common_test_helpers:stop_apps([emqx_conf]),
|
||||||
ok = emqx_connector_test_helpers:stop_apps([emqx_resource]),
|
ok = emqx_connector_test_helpers:stop_apps([?APP, emqx_resource]).
|
||||||
_ = application:stop(emqx_connector).
|
|
||||||
|
|
||||||
init_per_testcase(_, Config) ->
|
init_per_testcase(_, Config) ->
|
||||||
Config.
|
Config.
|
||||||
|
|
|
@ -9,6 +9,7 @@
|
||||||
stdlib,
|
stdlib,
|
||||||
gproc,
|
gproc,
|
||||||
jsx,
|
jsx,
|
||||||
|
ecpool,
|
||||||
emqx,
|
emqx,
|
||||||
telemetry
|
telemetry
|
||||||
]},
|
]},
|
||||||
|
|
Loading…
Reference in New Issue