Merge pull request #10212 from keynslug/test/EMQX-9269/cluster-env
test(bridge-api): also run testcases in cluster environment
This commit is contained in:
commit
89108594f0
|
@ -299,6 +299,7 @@ generate_config(SchemaModule, ConfigFile) when is_atom(SchemaModule) ->
|
||||||
-spec stop_apps(list()) -> ok.
|
-spec stop_apps(list()) -> ok.
|
||||||
stop_apps(Apps) ->
|
stop_apps(Apps) ->
|
||||||
[application:stop(App) || App <- Apps ++ [emqx, ekka, mria, mnesia]],
|
[application:stop(App) || App <- Apps ++ [emqx, ekka, mria, mnesia]],
|
||||||
|
ok = mria_mnesia:delete_schema(),
|
||||||
%% to avoid inter-suite flakiness
|
%% to avoid inter-suite flakiness
|
||||||
application:unset_env(emqx, init_config_load_done),
|
application:unset_env(emqx, init_config_load_done),
|
||||||
persistent_term:erase(?EMQX_AUTHENTICATION_SCHEMA_MODULE_PT_KEY),
|
persistent_term:erase(?EMQX_AUTHENTICATION_SCHEMA_MODULE_PT_KEY),
|
||||||
|
@ -723,7 +724,7 @@ setup_node(Node, Opts) when is_map(Opts) ->
|
||||||
ConfigureGenRpc = maps:get(configure_gen_rpc, Opts, true),
|
ConfigureGenRpc = maps:get(configure_gen_rpc, Opts, true),
|
||||||
LoadSchema = maps:get(load_schema, Opts, true),
|
LoadSchema = maps:get(load_schema, Opts, true),
|
||||||
SchemaMod = maps:get(schema_mod, Opts, emqx_schema),
|
SchemaMod = maps:get(schema_mod, Opts, emqx_schema),
|
||||||
LoadApps = maps:get(load_apps, Opts, [gen_rpc, emqx, ekka, mria] ++ Apps),
|
LoadApps = maps:get(load_apps, Opts, Apps),
|
||||||
Env = maps:get(env, Opts, []),
|
Env = maps:get(env, Opts, []),
|
||||||
Conf = maps:get(conf, Opts, []),
|
Conf = maps:get(conf, Opts, []),
|
||||||
ListenerPorts = maps:get(listener_ports, Opts, [
|
ListenerPorts = maps:get(listener_ports, Opts, [
|
||||||
|
@ -741,12 +742,13 @@ setup_node(Node, Opts) when is_map(Opts) ->
|
||||||
StartAutocluster = maps:get(start_autocluster, Opts, false),
|
StartAutocluster = maps:get(start_autocluster, Opts, false),
|
||||||
|
|
||||||
%% Load env before doing anything to avoid overriding
|
%% Load env before doing anything to avoid overriding
|
||||||
lists:foreach(fun(App) -> rpc:call(Node, ?MODULE, load, [App]) end, LoadApps),
|
[ok = erpc:call(Node, ?MODULE, load, [App]) || App <- [gen_rpc, ekka, mria, emqx | LoadApps]],
|
||||||
|
|
||||||
%% Ensure a clean mnesia directory for each run to avoid
|
%% Ensure a clean mnesia directory for each run to avoid
|
||||||
%% inter-test flakiness.
|
%% inter-test flakiness.
|
||||||
MnesiaDataDir = filename:join([
|
MnesiaDataDir = filename:join([
|
||||||
PrivDataDir,
|
PrivDataDir,
|
||||||
node(),
|
Node,
|
||||||
integer_to_list(erlang:unique_integer()),
|
integer_to_list(erlang:unique_integer()),
|
||||||
"mnesia"
|
"mnesia"
|
||||||
]),
|
]),
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -262,7 +262,7 @@ i18n_file() ->
|
||||||
end.
|
end.
|
||||||
|
|
||||||
listeners() ->
|
listeners() ->
|
||||||
emqx_conf:get([dashboard, listeners], []).
|
emqx_conf:get([dashboard, listeners], #{}).
|
||||||
|
|
||||||
api_key_authorize(Req, Key, Secret) ->
|
api_key_authorize(Req, Key, Secret) ->
|
||||||
Path = cowboy_req:path(Req),
|
Path = cowboy_req:path(Req),
|
||||||
|
|
|
@ -57,22 +57,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(
|
emqx_mgmt_api_test_util:init_suite([emqx_management]),
|
||||||
[emqx_management, emqx_dashboard],
|
|
||||||
fun set_special_configs/1
|
|
||||||
),
|
|
||||||
Config.
|
Config.
|
||||||
|
|
||||||
end_per_suite(_Config) ->
|
end_per_suite(_Config) ->
|
||||||
mnesia:clear_table(?ADMIN),
|
emqx_mgmt_api_test_util:end_suite([emqx_management]).
|
||||||
emqx_common_test_helpers:stop_apps([emqx_dashboard, emqx_management]),
|
|
||||||
mria:stop().
|
|
||||||
|
|
||||||
set_special_configs(emqx_dashboard) ->
|
|
||||||
emqx_dashboard_api_test_helpers:set_default_config(),
|
|
||||||
ok;
|
|
||||||
set_special_configs(_) ->
|
|
||||||
ok.
|
|
||||||
|
|
||||||
t_overview(_) ->
|
t_overview(_) ->
|
||||||
mnesia:clear_table(?ADMIN),
|
mnesia:clear_table(?ADMIN),
|
||||||
|
|
|
@ -19,36 +19,22 @@
|
||||||
-compile(export_all).
|
-compile(export_all).
|
||||||
|
|
||||||
-include("emqx_dashboard.hrl").
|
-include("emqx_dashboard.hrl").
|
||||||
-include_lib("emqx/include/http_api.hrl").
|
|
||||||
-include_lib("eunit/include/eunit.hrl").
|
-include_lib("eunit/include/eunit.hrl").
|
||||||
|
|
||||||
all() ->
|
all() ->
|
||||||
emqx_common_test_helpers:all(?MODULE).
|
emqx_common_test_helpers:all(?MODULE).
|
||||||
|
|
||||||
init_per_suite(Config) ->
|
init_per_suite(Config) ->
|
||||||
mria:start(),
|
emqx_mgmt_api_test_util:init_suite([emqx_conf]),
|
||||||
application:load(emqx_dashboard),
|
|
||||||
emqx_common_test_helpers:start_apps([emqx_conf, emqx_dashboard], fun set_special_configs/1),
|
|
||||||
Config.
|
Config.
|
||||||
|
|
||||||
set_special_configs(emqx_dashboard) ->
|
end_per_suite(_Config) ->
|
||||||
emqx_dashboard_api_test_helpers:set_default_config(),
|
emqx_mgmt_api_test_util:end_suite([emqx_conf]).
|
||||||
ok;
|
|
||||||
set_special_configs(_) ->
|
|
||||||
ok.
|
|
||||||
|
|
||||||
end_per_suite(Config) ->
|
|
||||||
end_suite(),
|
|
||||||
Config.
|
|
||||||
|
|
||||||
end_per_testcase(_, _Config) ->
|
end_per_testcase(_, _Config) ->
|
||||||
All = emqx_dashboard_admin:all_users(),
|
All = emqx_dashboard_admin:all_users(),
|
||||||
[emqx_dashboard_admin:remove_user(Name) || #{username := Name} <- All].
|
[emqx_dashboard_admin:remove_user(Name) || #{username := Name} <- All].
|
||||||
|
|
||||||
end_suite() ->
|
|
||||||
application:unload(emqx_management),
|
|
||||||
emqx_common_test_helpers:stop_apps([emqx_dashboard]).
|
|
||||||
|
|
||||||
t_check_user(_) ->
|
t_check_user(_) ->
|
||||||
Username = <<"admin1">>,
|
Username = <<"admin1">>,
|
||||||
Password = <<"public_1">>,
|
Password = <<"public_1">>,
|
||||||
|
|
|
@ -31,15 +31,10 @@ all() ->
|
||||||
emqx_common_test_helpers:all(?MODULE).
|
emqx_common_test_helpers:all(?MODULE).
|
||||||
|
|
||||||
init_per_suite(Config) ->
|
init_per_suite(Config) ->
|
||||||
mria:start(),
|
|
||||||
emqx_mgmt_api_test_util:init_suite([emqx_conf]),
|
emqx_mgmt_api_test_util:init_suite([emqx_conf]),
|
||||||
Config.
|
Config.
|
||||||
|
|
||||||
end_per_suite(Config) ->
|
end_per_suite(_Config) ->
|
||||||
end_suite(),
|
|
||||||
Config.
|
|
||||||
|
|
||||||
end_suite() ->
|
|
||||||
emqx_mgmt_api_test_util:end_suite([emqx_conf]).
|
emqx_mgmt_api_test_util:end_suite([emqx_conf]).
|
||||||
|
|
||||||
t_bad_api_path(_) ->
|
t_bad_api_path(_) ->
|
||||||
|
|
|
@ -29,24 +29,11 @@ all() ->
|
||||||
emqx_common_test_helpers:all(?MODULE).
|
emqx_common_test_helpers:all(?MODULE).
|
||||||
|
|
||||||
init_per_suite(Config) ->
|
init_per_suite(Config) ->
|
||||||
mria:start(),
|
emqx_mgmt_api_test_util:init_suite([emqx_conf]),
|
||||||
application:load(emqx_dashboard),
|
|
||||||
emqx_common_test_helpers:start_apps([emqx_conf, emqx_dashboard], fun set_special_configs/1),
|
|
||||||
Config.
|
Config.
|
||||||
|
|
||||||
set_special_configs(emqx_dashboard) ->
|
end_per_suite(_Config) ->
|
||||||
emqx_dashboard_api_test_helpers:set_default_config(),
|
emqx_mgmt_api_test_util:end_suite([emqx_conf]).
|
||||||
ok;
|
|
||||||
set_special_configs(_) ->
|
|
||||||
ok.
|
|
||||||
|
|
||||||
end_per_suite(Config) ->
|
|
||||||
end_suite(),
|
|
||||||
Config.
|
|
||||||
|
|
||||||
end_suite() ->
|
|
||||||
application:unload(emqx_management),
|
|
||||||
emqx_common_test_helpers:stop_apps([emqx_dashboard]).
|
|
||||||
|
|
||||||
t_all_code(_) ->
|
t_all_code(_) ->
|
||||||
HrlDef = ?ERROR_CODES,
|
HrlDef = ?ERROR_CODES,
|
||||||
|
|
|
@ -26,10 +26,7 @@ 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(
|
emqx_mgmt_api_test_util:init_suite([emqx_management], fun set_special_configs/1),
|
||||||
[emqx_management, emqx_dashboard],
|
|
||||||
fun set_special_configs/1
|
|
||||||
),
|
|
||||||
Config.
|
Config.
|
||||||
|
|
||||||
set_special_configs(emqx_dashboard) ->
|
set_special_configs(emqx_dashboard) ->
|
||||||
|
@ -38,12 +35,8 @@ set_special_configs(emqx_dashboard) ->
|
||||||
set_special_configs(_) ->
|
set_special_configs(_) ->
|
||||||
ok.
|
ok.
|
||||||
|
|
||||||
end_per_suite(Config) ->
|
end_per_suite(_Config) ->
|
||||||
application:unload(emqx_management),
|
emqx_mgmt_api_test_util:end_suite([emqx_management]).
|
||||||
mnesia:clear_table(?ADMIN),
|
|
||||||
emqx_common_test_helpers:stop_apps([emqx_dashboard, emqx_management]),
|
|
||||||
mria:stop(),
|
|
||||||
Config.
|
|
||||||
|
|
||||||
t_status(_Config) ->
|
t_status(_Config) ->
|
||||||
ProxyInfo = #{
|
ProxyInfo = #{
|
||||||
|
|
|
@ -31,22 +31,11 @@ all() ->
|
||||||
emqx_common_test_helpers:all(?MODULE).
|
emqx_common_test_helpers:all(?MODULE).
|
||||||
|
|
||||||
init_per_suite(Config) ->
|
init_per_suite(Config) ->
|
||||||
application:load(emqx_dashboard),
|
emqx_mgmt_api_test_util:init_suite([]),
|
||||||
mria:start(),
|
|
||||||
mnesia:clear_table(?ADMIN),
|
|
||||||
emqx_common_test_helpers:start_apps([emqx_dashboard], fun set_special_configs/1),
|
|
||||||
Config.
|
Config.
|
||||||
|
|
||||||
end_per_suite(Config) ->
|
end_per_suite(_Config) ->
|
||||||
mnesia:clear_table(?ADMIN),
|
emqx_mgmt_api_test_util:end_suite([]).
|
||||||
emqx_common_test_helpers:stop_apps([emqx_dashboard]),
|
|
||||||
Config.
|
|
||||||
|
|
||||||
set_special_configs(emqx_dashboard) ->
|
|
||||||
emqx_dashboard_api_test_helpers:set_default_config(),
|
|
||||||
ok;
|
|
||||||
set_special_configs(_) ->
|
|
||||||
ok.
|
|
||||||
|
|
||||||
t_monitor_samplers_all(_Config) ->
|
t_monitor_samplers_all(_Config) ->
|
||||||
timer:sleep(?DEFAULT_SAMPLE_INTERVAL * 2 * 1000 + 20),
|
timer:sleep(?DEFAULT_SAMPLE_INTERVAL * 2 * 1000 + 20),
|
||||||
|
|
|
@ -63,25 +63,12 @@ groups() ->
|
||||||
].
|
].
|
||||||
|
|
||||||
init_per_suite(Config) ->
|
init_per_suite(Config) ->
|
||||||
mria:start(),
|
emqx_mgmt_api_test_util:init_suite([emqx_conf]),
|
||||||
application:load(emqx_dashboard),
|
|
||||||
emqx_common_test_helpers:start_apps([emqx_conf, emqx_dashboard], fun set_special_configs/1),
|
|
||||||
emqx_dashboard:init_i18n(),
|
emqx_dashboard:init_i18n(),
|
||||||
Config.
|
Config.
|
||||||
|
|
||||||
set_special_configs(emqx_dashboard) ->
|
end_per_suite(_Config) ->
|
||||||
emqx_dashboard_api_test_helpers:set_default_config(),
|
emqx_mgmt_api_test_util:end_suite([emqx_conf]).
|
||||||
ok;
|
|
||||||
set_special_configs(_) ->
|
|
||||||
ok.
|
|
||||||
|
|
||||||
end_per_suite(Config) ->
|
|
||||||
end_suite(),
|
|
||||||
Config.
|
|
||||||
|
|
||||||
end_suite() ->
|
|
||||||
application:unload(emqx_management),
|
|
||||||
emqx_common_test_helpers:stop_apps([emqx_dashboard]).
|
|
||||||
|
|
||||||
t_in_path(_Config) ->
|
t_in_path(_Config) ->
|
||||||
Expect =
|
Expect =
|
||||||
|
|
|
@ -32,25 +32,17 @@
|
||||||
all() -> emqx_common_test_helpers:all(?MODULE).
|
all() -> emqx_common_test_helpers:all(?MODULE).
|
||||||
|
|
||||||
init_per_suite(Config) ->
|
init_per_suite(Config) ->
|
||||||
mria:start(),
|
emqx_mgmt_api_test_util:init_suite([emqx_conf]),
|
||||||
application:load(emqx_dashboard),
|
|
||||||
emqx_common_test_helpers:start_apps([emqx_conf, emqx_dashboard], fun set_special_configs/1),
|
|
||||||
emqx_dashboard:init_i18n(),
|
emqx_dashboard:init_i18n(),
|
||||||
Config.
|
Config.
|
||||||
|
|
||||||
set_special_configs(emqx_dashboard) ->
|
|
||||||
emqx_dashboard_api_test_helpers:set_default_config(),
|
|
||||||
ok;
|
|
||||||
set_special_configs(_) ->
|
|
||||||
ok.
|
|
||||||
|
|
||||||
end_per_suite(Config) ->
|
end_per_suite(Config) ->
|
||||||
end_suite(),
|
end_suite(),
|
||||||
Config.
|
Config.
|
||||||
|
|
||||||
end_suite() ->
|
end_suite() ->
|
||||||
application:unload(emqx_management),
|
application:unload(emqx_management),
|
||||||
emqx_common_test_helpers:stop_apps([emqx_dashboard]).
|
emqx_mgmt_api_test_util:end_suite([emqx_conf]).
|
||||||
|
|
||||||
t_simple_binary(_config) ->
|
t_simple_binary(_config) ->
|
||||||
Path = "/simple/bin",
|
Path = "/simple/bin",
|
||||||
|
|
Loading…
Reference in New Issue