test(emqx): switch select test suites to use `emqx_cth_suite`

This commit is contained in:
Andrew Mayorov 2023-12-05 19:12:53 +01:00
parent f5e184ec24
commit 6f5228e991
No known key found for this signature in database
GPG Key ID: 2837C62ACFBFED5D
5 changed files with 24 additions and 44 deletions

View File

@ -19,7 +19,6 @@
-compile(export_all). -compile(export_all).
-compile(nowarn_export_all). -compile(nowarn_export_all).
-include_lib("emqx/include/emqx.hrl").
-include_lib("eunit/include/eunit.hrl"). -include_lib("eunit/include/eunit.hrl").
-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").
@ -39,12 +38,11 @@
all() -> emqx_common_test_helpers:all(?MODULE). all() -> emqx_common_test_helpers:all(?MODULE).
init_per_suite(Config) -> init_per_suite(Config) ->
emqx_common_test_helpers:boot_modules(all), Apps = emqx_cth_suite:start([emqx], #{work_dir => emqx_cth_suite:work_dir(Config)}),
emqx_common_test_helpers:start_apps([]), [{apps, Apps} | Config].
Config.
end_per_suite(_Config) -> end_per_suite(Config) ->
emqx_common_test_helpers:stop_apps([]). emqx_cth_suite:stop(proplists:get_value(apps, Config)).
init_per_testcase(TestCase, Config) -> init_per_testcase(TestCase, Config) ->
case erlang:function_exported(?MODULE, TestCase, 2) of case erlang:function_exported(?MODULE, TestCase, 2) of

View File

@ -26,12 +26,11 @@ all() ->
emqx_common_test_helpers:all(?MODULE). emqx_common_test_helpers:all(?MODULE).
init_per_suite(Config) -> init_per_suite(Config) ->
emqx_common_test_helpers:start_apps([]), Apps = emqx_cth_suite:start([emqx], #{work_dir => emqx_cth_suite:work_dir(Config)}),
Config. [{apps, Apps} | Config].
end_per_suite(_Config) -> end_per_suite(Config) ->
emqx_common_test_helpers:stop_apps([]), emqx_cth_suite:stop(proplists:get_value(apps, Config)).
ok.
t_check_pub(_) -> t_check_pub(_) ->
OldConf = emqx:get_config([zones], #{}), OldConf = emqx:get_config([zones], #{}),

View File

@ -19,7 +19,6 @@
-compile(export_all). -compile(export_all).
-compile(nowarn_export_all). -compile(nowarn_export_all).
-include_lib("emqx/include/emqx.hrl").
-include_lib("emqx/include/emqx_mqtt.hrl"). -include_lib("emqx/include/emqx_mqtt.hrl").
-include_lib("eunit/include/eunit.hrl"). -include_lib("eunit/include/eunit.hrl").
-include_lib("snabbkaffe/include/snabbkaffe.hrl"). -include_lib("snabbkaffe/include/snabbkaffe.hrl").
@ -59,31 +58,17 @@ groups() ->
]. ].
init_per_group(tcp, Config) -> init_per_group(tcp, Config) ->
emqx_common_test_helpers:start_apps([]), Apps = emqx_cth_suite:start([emqx], #{work_dir => emqx_cth_suite:work_dir(Config)}),
[{port, 1883}, {conn_fun, connect} | Config]; [{port, 1883}, {conn_fun, connect}, {group_apps, Apps} | Config];
init_per_group(quic, Config) -> init_per_group(quic, Config) ->
UdpPort = 1884, Apps = emqx_cth_suite:start(
emqx_common_test_helpers:start_apps([]), [{emqx, "listeners.quic.test { enable = true, bind = 1884 }"}],
emqx_common_test_helpers:ensure_quic_listener(?MODULE, UdpPort), #{work_dir => emqx_cth_suite:work_dir(Config)}
[{port, UdpPort}, {conn_fun, quic_connect} | Config]; ),
init_per_group(_, Config) -> [{port, 1884}, {conn_fun, quic_connect}, {group_apps, Apps} | Config].
emqx_common_test_helpers:stop_apps([]),
Config.
end_per_group(quic, _Config) -> end_per_group(_Group, Config) ->
emqx_config:put([listeners, quic], #{}), emqx_cth_suite:stop(?config(group_apps, Config)).
ok;
end_per_group(_Group, _Config) ->
ok.
init_per_suite(Config) ->
%% Start Apps
emqx_common_test_helpers:boot_modules(all),
emqx_common_test_helpers:start_apps([]),
Config.
end_per_suite(_Config) ->
emqx_common_test_helpers:stop_apps([]).
init_per_testcase(TestCase, Config) -> init_per_testcase(TestCase, Config) ->
case erlang:function_exported(?MODULE, TestCase, 2) of case erlang:function_exported(?MODULE, TestCase, 2) of

View File

@ -26,14 +26,13 @@
all() -> emqx_common_test_helpers:all(?MODULE). all() -> emqx_common_test_helpers:all(?MODULE).
init_per_suite(Config) -> init_per_suite(Config) ->
emqx_common_test_helpers:boot_modules(all), Apps = emqx_cth_suite:start([emqx], #{work_dir => emqx_cth_suite:work_dir(Config)}),
emqx_common_test_helpers:start_apps([]),
OldSch = erlang:system_flag(schedulers_online, 1), OldSch = erlang:system_flag(schedulers_online, 1),
[{old_sch, OldSch} | Config]. [{apps, Apps}, {old_sch, OldSch} | Config].
end_per_suite(Config) -> end_per_suite(Config) ->
erlang:system_flag(schedulers_online, ?config(old_sch, Config)), erlang:system_flag(schedulers_online, ?config(old_sch, Config)),
emqx_common_test_helpers:stop_apps([]). emqx_cth_suite:stop(?config(apps, Config)).
init_per_testcase(_, Config) -> init_per_testcase(_, Config) ->
emqx_common_test_helpers:boot_modules(all), emqx_common_test_helpers:boot_modules(all),

View File

@ -24,12 +24,11 @@
all() -> emqx_common_test_helpers:all(?MODULE). all() -> emqx_common_test_helpers:all(?MODULE).
init_per_suite(Config) -> init_per_suite(Config) ->
emqx_common_test_helpers:boot_modules(all), Apps = emqx_cth_suite:start([emqx], #{work_dir => emqx_cth_suite:work_dir(Config)}),
emqx_common_test_helpers:start_apps([]), [{apps, Apps} | Config].
Config.
end_per_suite(_Config) -> end_per_suite(Config) ->
emqx_common_test_helpers:stop_apps([]). emqx_cth_suite:stop(proplists:get_value(apps, Config)).
init_per_testcase(t_cpu_check_alarm, Config) -> init_per_testcase(t_cpu_check_alarm, Config) ->
SysMon = emqx_config:get([sysmon, os], #{}), SysMon = emqx_config:get([sysmon, os], #{}),