test(sso): update and simplify testsuites setup

This commit is contained in:
Andrew Mayorov 2024-02-13 19:18:15 +01:00
parent b15e81baf2
commit a64850a84b
No known key found for this signature in database
GPG Key ID: 2837C62ACFBFED5D
2 changed files with 28 additions and 26 deletions

View File

@ -9,6 +9,7 @@
-include_lib("emqx_dashboard/include/emqx_dashboard.hrl").
-include_lib("eunit/include/eunit.hrl").
-include_lib("common_test/include/ct.hrl").
-include_lib("snabbkaffe/include/snabbkaffe.hrl").
-import(emqx_dashboard_sso_cli, [admins/1]).
@ -24,15 +25,19 @@
all() -> [t_add, t_passwd, t_del].
init_per_suite(Config) ->
_ = application:load(emqx_conf),
emqx_config:save_schema_mod_and_names(emqx_dashboard_schema),
emqx_mgmt_api_test_util:init_suite([emqx_dashboard, emqx_dashboard_sso]),
Config.
Apps = emqx_cth_suite:start(
[
emqx,
emqx_conf,
emqx_dashboard,
emqx_dashboard_sso
],
#{work_dir => emqx_cth_suite:work_dir(Config)}
),
[{suite_apps, Apps} | Config].
end_per_suite(_Config) ->
All = emqx_dashboard_admin:all_users(),
[emqx_dashboard_admin:remove_user(Name) || #{username := Name} <- All],
emqx_mgmt_api_test_util:end_suite([emqx_conf, emqx_dashboard_sso]).
end_per_suite(Config) ->
ok = emqx_cth_suite:stop(?config(suite_apps, Config)).
t_add(_) ->
admins(["add", "user1", "password1"]),

View File

@ -44,31 +44,28 @@ all() ->
].
init_per_suite(Config) ->
_ = application:load(emqx_conf),
emqx_config:save_schema_mod_and_names(emqx_dashboard_schema),
emqx_mgmt_api_test_util:init_suite([emqx_dashboard, emqx_dashboard_sso]),
Config.
Apps = emqx_cth_suite:start(
[
emqx,
emqx_conf,
emqx_management,
{emqx_dashboard, "dashboard.listeners.http { enable = true, bind = 18083 }"},
emqx_dashboard_sso
],
#{work_dir => emqx_cth_suite:work_dir(Config)}
),
_ = emqx_common_test_http:create_default_app(),
[{suite_apps, Apps} | Config].
end_per_suite(_Config) ->
All = emqx_dashboard_admin:all_users(),
[emqx_dashboard_admin:remove_user(Name) || #{username := Name} <- All],
emqx_mgmt_api_test_util:end_suite([emqx_conf, emqx_dashboard_sso]).
end_per_suite(Config) ->
ok = emqx_cth_suite:stop(?config(suite_apps, Config)).
init_per_testcase(Case, Config) ->
{ok, _} = emqx_cluster_rpc:start_link(),
?MODULE:Case({init, Config}),
Config.
end_per_testcase(Case, Config) ->
?MODULE:Case({'end', Config}),
case erlang:whereis(node()) of
undefined ->
ok;
P ->
erlang:unlink(P),
erlang:exit(P, kill)
end,
ok.
?MODULE:Case({'end', Config}).
t_bad_create({init, Config}) ->
Config;