test: allow emqx_ws_connection_SUITE to run without erasing configs
This commit is contained in:
parent
95cb262067
commit
b65a71b498
|
@ -31,6 +31,7 @@
|
||||||
start_apps/2,
|
start_apps/2,
|
||||||
start_apps/3,
|
start_apps/3,
|
||||||
stop_apps/1,
|
stop_apps/1,
|
||||||
|
stop_apps/2,
|
||||||
reload/2,
|
reload/2,
|
||||||
app_path/2,
|
app_path/2,
|
||||||
proj_root/0,
|
proj_root/0,
|
||||||
|
@ -313,12 +314,21 @@ generate_config(SchemaModule, ConfigFile) when is_atom(SchemaModule) ->
|
||||||
|
|
||||||
-spec stop_apps(list()) -> ok.
|
-spec stop_apps(list()) -> ok.
|
||||||
stop_apps(Apps) ->
|
stop_apps(Apps) ->
|
||||||
|
stop_apps(Apps, #{}).
|
||||||
|
|
||||||
|
stop_apps(Apps, Opts) ->
|
||||||
[application:stop(App) || App <- Apps ++ [emqx, ekka, mria, mnesia]],
|
[application:stop(App) || App <- Apps ++ [emqx, ekka, mria, mnesia]],
|
||||||
ok = mria_mnesia:delete_schema(),
|
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),
|
||||||
emqx_config:erase_all(),
|
case Opts of
|
||||||
|
#{erase_all_configs := false} ->
|
||||||
|
%% FIXME: this means inter-suite or inter-test dependencies
|
||||||
|
ok;
|
||||||
|
_ ->
|
||||||
|
emqx_config:erase_all()
|
||||||
|
end,
|
||||||
ok = emqx_config:delete_override_conf_files(),
|
ok = emqx_config:delete_override_conf_files(),
|
||||||
application:unset_env(emqx, local_override_conf_file),
|
application:unset_env(emqx, local_override_conf_file),
|
||||||
application:unset_env(emqx, cluster_override_conf_file),
|
application:unset_env(emqx, cluster_override_conf_file),
|
||||||
|
|
|
@ -138,13 +138,13 @@ end_per_testcase(t_ws_non_check_origin, Config) ->
|
||||||
del_bucket(),
|
del_bucket(),
|
||||||
PrevConfig = ?config(prev_config, Config),
|
PrevConfig = ?config(prev_config, Config),
|
||||||
emqx_config:put_listener_conf(ws, default, [websocket], PrevConfig),
|
emqx_config:put_listener_conf(ws, default, [websocket], PrevConfig),
|
||||||
emqx_common_test_helpers:stop_apps([]),
|
stop_apps(),
|
||||||
ok;
|
ok;
|
||||||
end_per_testcase(_, Config) ->
|
end_per_testcase(_, Config) ->
|
||||||
del_bucket(),
|
del_bucket(),
|
||||||
PrevConfig = ?config(prev_config, Config),
|
PrevConfig = ?config(prev_config, Config),
|
||||||
emqx_config:put_listener_conf(ws, default, [websocket], PrevConfig),
|
emqx_config:put_listener_conf(ws, default, [websocket], PrevConfig),
|
||||||
emqx_common_test_helpers:stop_apps([]),
|
stop_apps(),
|
||||||
Config.
|
Config.
|
||||||
|
|
||||||
init_per_suite(Config) ->
|
init_per_suite(Config) ->
|
||||||
|
@ -156,6 +156,10 @@ end_per_suite(_) ->
|
||||||
emqx_common_test_helpers:stop_apps([]),
|
emqx_common_test_helpers:stop_apps([]),
|
||||||
ok.
|
ok.
|
||||||
|
|
||||||
|
%% FIXME: this is a temp fix to tests share configs.
|
||||||
|
stop_apps() ->
|
||||||
|
emqx_common_test_helpers:stop_apps([], #{erase_all_configs => false}).
|
||||||
|
|
||||||
%%--------------------------------------------------------------------
|
%%--------------------------------------------------------------------
|
||||||
%% Test Cases
|
%% Test Cases
|
||||||
%%--------------------------------------------------------------------
|
%%--------------------------------------------------------------------
|
||||||
|
|
Loading…
Reference in New Issue