Skip to content

Commit

Permalink
test(gw-authn): switch to emqx_cth_suite + simplify testsuite
Browse files Browse the repository at this point in the history
  • Loading branch information
keynslug committed Dec 20, 2023
1 parent 76c89ad commit ccb9a97
Showing 1 changed file with 25 additions and 28 deletions.
53 changes: 25 additions & 28 deletions apps/emqx_gateway/test/emqx_gateway_authn_SUITE.erl
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
-include_lib("eunit/include/eunit.hrl").
-include_lib("common_test/include/ct.hrl").

-import(emqx_gateway_auth_ct, [init_gateway_conf/0, with_resource/3]).
-import(emqx_gateway_auth_ct, [with_resource/3]).

-define(checkMatch(Guard),
(fun(Expr) ->
Expand Down Expand Up @@ -54,40 +54,37 @@ groups() ->
emqx_gateway_auth_ct:init_groups(?MODULE, ?AUTHNS).

init_per_group(AuthName, Conf) ->
ct:pal("on group start:~p~n", [AuthName]),
{ok, _} = emqx_cluster_rpc:start_link(node(), emqx_cluster_rpc, 1000),
emqx_gateway_auth_ct:start_auth(AuthName),
timer:sleep(500),
Conf.
Apps = emqx_cth_suite:start(
[
emqx_conf,
emqx_auth,
emqx_auth_http,
emqx_management,
{emqx_dashboard, "dashboard.listeners.http { enable = true, bind = 18083 }"},
{emqx_gateway, emqx_gateway_auth_ct:list_gateway_conf()}
| emqx_gateway_test_utils:all_gateway_apps()
],
#{work_dir => emqx_cth_suite:work_dir(Conf)}
),
_ = emqx_common_test_http:create_default_app(),
ok = emqx_gateway_auth_ct:start_auth(AuthName),
[{group_apps, Apps} | Conf].

end_per_group(AuthName, Conf) ->
ct:pal("on group stop:~p~n", [AuthName]),
emqx_gateway_auth_ct:stop_auth(AuthName),
ok = emqx_gateway_auth_ct:stop_auth(AuthName),
_ = emqx_common_test_http:delete_default_app(),
ok = emqx_cth_suite:stop(?config(group_apps, Conf)),
Conf.

init_per_suite(Config) ->
emqx_gateway_test_utils:load_all_gateway_apps(),
emqx_config:erase(gateway),
init_gateway_conf(),
emqx_mgmt_api_test_util:init_suite([grpc, emqx_conf, emqx_auth, emqx_auth_http, emqx_gateway]),
application:ensure_all_started(cowboy),
emqx_gateway_auth_ct:start(),
timer:sleep(500),
Config.
{ok, Apps1} = application:ensure_all_started(grpc),
{ok, Apps2} = application:ensure_all_started(cowboy),
{ok, _} = emqx_gateway_auth_ct:start(),
[{suite_apps, Apps1 ++ Apps2} | Config].

end_per_suite(Config) ->
emqx_gateway_auth_ct:stop(),
emqx_config:erase(gateway),
emqx_mgmt_api_test_util:end_suite([
cowboy, emqx_conf, emqx_auth, emqx_auth_http, emqx_gateway, grpc
]),
Config.

init_per_testcase(_Case, Config) ->
{ok, _} = emqx_cluster_rpc:start_link(node(), emqx_cluster_rpc, 1000),
Config.

end_per_testcase(_Case, Config) ->
ok = emqx_gateway_auth_ct:stop(),
ok = emqx_cth_suite:stop_apps(?config(suite_apps, Config)),
Config.

%%------------------------------------------------------------------------------
Expand Down

0 comments on commit ccb9a97

Please sign in to comment.