test(emqx): switch rest of test suite to use `emqx_cth_suite`
This commit is contained in:
parent
c2c9de69b4
commit
074dc8ce11
|
@ -35,8 +35,6 @@ end_per_suite(Config) ->
|
||||||
emqx_cth_suite:stop(?config(apps, Config)).
|
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:start_apps([]),
|
|
||||||
emqx_olp:enable(),
|
emqx_olp:enable(),
|
||||||
case wait_for(fun() -> lc_sup:whereis_runq_flagman() end, 10) of
|
case wait_for(fun() -> lc_sup:whereis_runq_flagman() end, 10) of
|
||||||
true -> ok;
|
true -> ok;
|
||||||
|
|
|
@ -144,19 +144,35 @@ groups() ->
|
||||||
].
|
].
|
||||||
|
|
||||||
init_per_suite(Config) ->
|
init_per_suite(Config) ->
|
||||||
emqx_common_test_helpers:start_apps([]),
|
Apps = start_emqx(Config),
|
||||||
UdpPort = 14567,
|
[{port, 14567}, {pub_qos, 0}, {sub_qos, 0}, {apps, Apps} | Config].
|
||||||
start_emqx_quic(UdpPort),
|
|
||||||
%% Turn off force_shutdown policy.
|
|
||||||
ShutdownPolicy = emqx_config:get_zone_conf(default, [force_shutdown]),
|
|
||||||
ct:pal("force shutdown config: ~p", [ShutdownPolicy]),
|
|
||||||
emqx_config:put_zone_conf(default, [force_shutdown], ShutdownPolicy#{enable := false}),
|
|
||||||
[{shutdown_policy, ShutdownPolicy}, {port, UdpPort}, {pub_qos, 0}, {sub_qos, 0} | Config].
|
|
||||||
|
|
||||||
end_per_suite(Config) ->
|
end_per_suite(Config) ->
|
||||||
emqx_config:put_zone_conf(default, [force_shutdown], ?config(shutdown_policy, Config)),
|
emqx_cth_suite:stop(?config(apps, Config)).
|
||||||
emqx_common_test_helpers:stop_apps([]),
|
|
||||||
ok.
|
start_emqx(Config) ->
|
||||||
|
emqx_cth_suite:start(
|
||||||
|
[mk_emqx_spec()],
|
||||||
|
#{work_dir => emqx_cth_suite:work_dir(Config)}
|
||||||
|
).
|
||||||
|
|
||||||
|
stop_emqx(Config) ->
|
||||||
|
emqx_cth_suite:stop(?config(apps, Config)).
|
||||||
|
|
||||||
|
restart_emqx(Config) ->
|
||||||
|
ok = stop_emqx(Config),
|
||||||
|
emqx_cth_suite:start(
|
||||||
|
[mk_emqx_spec()],
|
||||||
|
#{work_dir => emqx_cth_suite:work_dir(Config), boot_type => restart}
|
||||||
|
).
|
||||||
|
|
||||||
|
mk_emqx_spec() ->
|
||||||
|
{emqx,
|
||||||
|
%% Turn off force_shutdown policy.
|
||||||
|
"force_shutdown.enable = false"
|
||||||
|
"\n listeners.quic.default {"
|
||||||
|
"\n enable = true, bind = 14567, acceptors = 16, idle_timeout_ms = 15000"
|
||||||
|
"\n }"}.
|
||||||
|
|
||||||
init_per_group(pub_qos0, Config) ->
|
init_per_group(pub_qos0, Config) ->
|
||||||
[{pub_qos, 0} | Config];
|
[{pub_qos, 0} | Config];
|
||||||
|
@ -190,11 +206,6 @@ init_per_group(_, Config) ->
|
||||||
end_per_group(_, Config) ->
|
end_per_group(_, Config) ->
|
||||||
Config.
|
Config.
|
||||||
|
|
||||||
init_per_testcase(_, Config) ->
|
|
||||||
emqx_common_test_helpers:start_apps([]),
|
|
||||||
start_emqx_quic(?config(port, Config)),
|
|
||||||
Config.
|
|
||||||
|
|
||||||
t_quic_sock(Config) ->
|
t_quic_sock(Config) ->
|
||||||
Port = 4567,
|
Port = 4567,
|
||||||
SslOpts = [
|
SslOpts = [
|
||||||
|
@ -1582,9 +1593,13 @@ t_multi_streams_remote_shutdown(Config) ->
|
||||||
|
|
||||||
{quic, _Conn, _Ctrlstream} = proplists:get_value(socket, emqtt:info(C)),
|
{quic, _Conn, _Ctrlstream} = proplists:get_value(socket, emqtt:info(C)),
|
||||||
|
|
||||||
ok = stop_emqx(),
|
ok = stop_emqx(Config),
|
||||||
|
try
|
||||||
%% Client should be closed
|
%% Client should be closed
|
||||||
assert_client_die(C, 100, 200).
|
assert_client_die(C, 100, 200)
|
||||||
|
after
|
||||||
|
restart_emqx(Config)
|
||||||
|
end.
|
||||||
|
|
||||||
t_multi_streams_remote_shutdown_with_reconnect(Config) ->
|
t_multi_streams_remote_shutdown_with_reconnect(Config) ->
|
||||||
erlang:process_flag(trap_exit, true),
|
erlang:process_flag(trap_exit, true),
|
||||||
|
@ -1636,10 +1651,8 @@ t_multi_streams_remote_shutdown_with_reconnect(Config) ->
|
||||||
|
|
||||||
{quic, _Conn, _Ctrlstream} = proplists:get_value(socket, emqtt:info(C)),
|
{quic, _Conn, _Ctrlstream} = proplists:get_value(socket, emqtt:info(C)),
|
||||||
|
|
||||||
ok = stop_emqx(),
|
_Apps = restart_emqx(Config),
|
||||||
|
|
||||||
timer:sleep(200),
|
|
||||||
start_emqx_quic(?config(port, Config)),
|
|
||||||
?assert(is_list(emqtt:info(C))),
|
?assert(is_list(emqtt:info(C))),
|
||||||
emqtt:stop(C).
|
emqtt:stop(C).
|
||||||
|
|
||||||
|
@ -2028,16 +2041,6 @@ calc_pkt_id(1, Id) ->
|
||||||
calc_pkt_id(2, Id) ->
|
calc_pkt_id(2, Id) ->
|
||||||
Id.
|
Id.
|
||||||
|
|
||||||
-spec start_emqx_quic(inet:port_number()) -> ok.
|
|
||||||
start_emqx_quic(UdpPort) ->
|
|
||||||
emqx_common_test_helpers:start_apps([]),
|
|
||||||
application:ensure_all_started(quicer),
|
|
||||||
emqx_common_test_helpers:ensure_quic_listener(?MODULE, UdpPort).
|
|
||||||
|
|
||||||
-spec stop_emqx() -> ok.
|
|
||||||
stop_emqx() ->
|
|
||||||
emqx_common_test_helpers:stop_apps([]).
|
|
||||||
|
|
||||||
%% select a random port picked by OS
|
%% select a random port picked by OS
|
||||||
-spec select_port() -> inet:port_number().
|
-spec select_port() -> inet:port_number().
|
||||||
select_port() ->
|
select_port() ->
|
||||||
|
|
|
@ -47,23 +47,23 @@ all() ->
|
||||||
emqx_common_test_helpers:all(?MODULE).
|
emqx_common_test_helpers:all(?MODULE).
|
||||||
|
|
||||||
init_per_suite(Config) ->
|
init_per_suite(Config) ->
|
||||||
load_conf(),
|
Apps = emqx_cth_suite:start([emqx], #{work_dir => emqx_cth_suite:work_dir(Config)}),
|
||||||
emqx_common_test_helpers:start_apps([?APP]),
|
ok = load_conf(),
|
||||||
Config.
|
[{apps, Apps} | Config].
|
||||||
|
|
||||||
end_per_suite(_Config) ->
|
end_per_suite(Config) ->
|
||||||
emqx_common_test_helpers:stop_apps([?APP]).
|
emqx_cth_suite:stop(?config(apps, Config)).
|
||||||
|
|
||||||
init_per_testcase(_TestCase, Config) ->
|
init_per_testcase(_TestCase, Config) ->
|
||||||
emqx_config:erase(limiter),
|
ok = emqx_config:erase(limiter),
|
||||||
load_conf(),
|
ok = load_conf(),
|
||||||
Config.
|
Config.
|
||||||
|
|
||||||
end_per_testcase(_TestCase, Config) ->
|
end_per_testcase(_TestCase, Config) ->
|
||||||
Config.
|
Config.
|
||||||
|
|
||||||
load_conf() ->
|
load_conf() ->
|
||||||
ok = emqx_common_test_helpers:load_config(emqx_limiter_schema, ?BASE_CONF).
|
emqx_common_test_helpers:load_config(emqx_limiter_schema, ?BASE_CONF).
|
||||||
|
|
||||||
init_config() ->
|
init_config() ->
|
||||||
emqx_config:init_load(emqx_limiter_schema, ?BASE_CONF).
|
emqx_config:init_load(emqx_limiter_schema, ?BASE_CONF).
|
||||||
|
|
|
@ -22,12 +22,11 @@
|
||||||
-include_lib("common_test/include/ct.hrl").
|
-include_lib("common_test/include/ct.hrl").
|
||||||
|
|
||||||
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(?config(apps, Config)).
|
||||||
|
|
||||||
all() ->
|
all() ->
|
||||||
emqx_common_test_helpers:all(?MODULE).
|
emqx_common_test_helpers:all(?MODULE).
|
||||||
|
|
|
@ -49,31 +49,11 @@
|
||||||
all() -> emqx_common_test_helpers:all(?SUITE).
|
all() -> emqx_common_test_helpers:all(?SUITE).
|
||||||
|
|
||||||
init_per_suite(Config) ->
|
init_per_suite(Config) ->
|
||||||
DistPid =
|
Apps = emqx_cth_suite:start([emqx], #{work_dir => emqx_cth_suite:work_dir(Config)}),
|
||||||
case net_kernel:nodename() of
|
[{apps, Apps} | Config].
|
||||||
ignored ->
|
|
||||||
%% calling `net_kernel:start' without `epmd'
|
|
||||||
%% running will result in a failure.
|
|
||||||
emqx_common_test_helpers:start_epmd(),
|
|
||||||
{ok, Pid} = net_kernel:start(['master@127.0.0.1', longnames]),
|
|
||||||
ct:pal("start epmd, node name: ~p", [node()]),
|
|
||||||
Pid;
|
|
||||||
_ ->
|
|
||||||
undefined
|
|
||||||
end,
|
|
||||||
emqx_common_test_helpers:boot_modules(all),
|
|
||||||
emqx_common_test_helpers:start_apps([]),
|
|
||||||
[{dist_pid, DistPid} | Config].
|
|
||||||
|
|
||||||
end_per_suite(Config) ->
|
end_per_suite(Config) ->
|
||||||
DistPid = ?config(dist_pid, Config),
|
emqx_cth_suite:stop(?config(apps, Config)).
|
||||||
case DistPid of
|
|
||||||
Pid when is_pid(Pid) ->
|
|
||||||
net_kernel:stop();
|
|
||||||
_ ->
|
|
||||||
ok
|
|
||||||
end,
|
|
||||||
emqx_common_test_helpers:stop_apps([]).
|
|
||||||
|
|
||||||
init_per_testcase(Case, Config) ->
|
init_per_testcase(Case, Config) ->
|
||||||
try
|
try
|
||||||
|
|
|
@ -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)).
|
||||||
|
|
||||||
t_child(_) ->
|
t_child(_) ->
|
||||||
?assertMatch({error, _}, emqx_sup:start_child(undef, worker)),
|
?assertMatch({error, _}, emqx_sup:start_child(undef, worker)),
|
||||||
|
|
Loading…
Reference in New Issue