Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add new helper function to enable cets/mnesia in big_tests #4155

Merged
merged 1 commit into from
Nov 7, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 0 additions & 3 deletions big_tests/test.config
Original file line number Diff line number Diff line change
Expand Up @@ -246,9 +246,6 @@
{component_backend, "\"cets\""},
{s2s_backend, "\"cets\""},
{stream_management_backend, cets},
{muc_online_backend, cets},
Copy link
Member

@chrzaszcz chrzaszcz Nov 7, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There are a few more options to clean up here, and they are unused. This can be done separately.

{jingle_sip_backend, cets},
{keystore_backend, cets},
{auth_anonymous_backend, cets},
{auth_method, "rdbms"},
{internal_databases, "[internal_databases.cets]
Expand Down
2 changes: 1 addition & 1 deletion big_tests/tests/carboncopy_SUITE.erl
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ end_per_suite(C) ->
escalus:end_per_suite(C).

init_per_group(muc, Config) ->
muc_helper:load_muc(Config),
muc_helper:load_muc(),
Config;
init_per_group(_GroupName, Config) ->
Config.
Expand Down
15 changes: 11 additions & 4 deletions big_tests/tests/ct_helper.erl
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@
repeat_all_until_any_fail/1,
repeat_all_until_any_fail/2,
groups_to_all/1,
get_preset_var/3]).
get_preset_var/3,
get_internal_database/0]).

-type group_name() :: atom().

Expand Down Expand Up @@ -118,9 +119,15 @@ groups_to_all(Groups) ->

get_preset_var(Config, Opt, Def) ->
case proplists:get_value(preset, Config, undefined) of
undefined ->
Def;
Preset ->
PresetAtom = list_to_existing_atom(Preset),
ct:get_config({presets, toml, PresetAtom, Opt}, Def);
_ ->
Def
ct:get_config({presets, toml, PresetAtom, Opt}, Def)
end.

get_internal_database() ->
case distributed_helper:lookup_config_opt([internal_databases, cets]) of
{ok, _} -> cets;
{error, not_found} -> mnesia
end.
3 changes: 3 additions & 0 deletions big_tests/tests/distributed_helper.erl
Original file line number Diff line number Diff line change
Expand Up @@ -202,3 +202,6 @@ mongooseim_script(Node, Cmd, Args, Config) ->

subhost_pattern(SubhostTemplate) ->
rpc(mim(), mongoose_subdomain_utils, make_subdomain_pattern, [SubhostTemplate]).

lookup_config_opt(Key) ->
rpc(mim(), mongoose_config, lookup_opt, [Key]).
2 changes: 1 addition & 1 deletion big_tests/tests/domain_removal_SUITE.erl
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ is_internal_or_rdbms() ->
%%%===================================================================

init_per_testcase(muc_removal, Config) ->
muc_helper:load_muc(Config),
muc_helper:load_muc(),
mongoose_helper:ensure_muc_clean(),
escalus:init_per_testcase(muc_removal, Config);
init_per_testcase(roster_removal, ConfigIn) ->
Expand Down
4 changes: 2 additions & 2 deletions big_tests/tests/gdpr_SUITE.erl
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ all_mam_testcases() ->
init_per_suite(Config) ->
#{node := MimNode} = distributed_helper:mim(),
Config1 = [{{ejabberd_cwd, MimNode}, get_mim_cwd()} | dynamic_modules:save_modules(host_type(), Config)],
muc_helper:load_muc(Config),
muc_helper:load_muc(),
escalus:init_per_suite(Config1).

end_per_suite(Config) ->
Expand Down Expand Up @@ -243,7 +243,7 @@ init_per_testcase(CN, Config) when
Config1;
init_per_testcase(CN, Config) when CN =:= retrieve_inbox_muc;
CN =:= remove_inbox_muc ->
muc_helper:load_muc(Config),
muc_helper:load_muc(),
Config0 = init_inbox(CN, Config, muc),
Config0;

Expand Down
12 changes: 6 additions & 6 deletions big_tests/tests/graphql_muc_SUITE.erl
Original file line number Diff line number Diff line change
Expand Up @@ -237,20 +237,20 @@ init_per_group(admin_cli, Config) ->
graphql_helper:init_admin_cli(Config);
init_per_group(domain_admin_muc, Config) ->
maybe_enable_mam(),
ensure_muc_started(Config),
ensure_muc_started(),
graphql_helper:init_domain_admin_handler(Config);
init_per_group(user, Config) ->
graphql_helper:init_user(Config);
init_per_group(Group, Config) when Group =:= admin_muc_configured;
Group =:= user_muc_configured ->
disable_mam(),
ensure_muc_started(Config),
ensure_muc_started(),
Config;
init_per_group(Group, Config) when Group =:= admin_muc_and_mam_configured;
Group =:= user_muc_and_mam_configured ->
case maybe_enable_mam() of
true ->
ensure_muc_started(Config),
ensure_muc_started(),
ensure_muc_light_started(Config);
false ->
{skip, "No MAM backend available"}
Expand All @@ -277,10 +277,10 @@ maybe_enable_mam() ->
true
end.

ensure_muc_started(Config) ->
ensure_muc_started() ->
SecondaryHostType = domain_helper:secondary_host_type(),
muc_helper:load_muc(Config),
muc_helper:load_muc(Config, SecondaryHostType),
muc_helper:load_muc(),
muc_helper:load_muc(SecondaryHostType),
mongoose_helper:ensure_muc_clean().

ensure_muc_stopped() ->
Expand Down
6 changes: 3 additions & 3 deletions big_tests/tests/graphql_muc_light_SUITE.erl
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,7 @@ init_per_group(Group, Config) when Group =:= user_muc_light_with_mam;
Group =:= domain_admin_muc_light_with_mam ->
case maybe_enable_mam() of
true ->
ensure_muc_started(Config),
ensure_muc_started(),
ensure_muc_light_started(Config);
false ->
{skip, "No MAM backend available"}
Expand Down Expand Up @@ -281,8 +281,8 @@ ensure_muc_light_stopped(Config) ->
dynamic_modules:ensure_modules(SecondaryHostType, [{mod_muc_light, stopped}]),
[{muc_light_host, <<"NON_EXISTING">>} | Config].

ensure_muc_started(Config) ->
muc_helper:load_muc(Config),
ensure_muc_started() ->
muc_helper:load_muc(),
mongoose_helper:ensure_muc_clean().

ensure_muc_stopped() ->
Expand Down
6 changes: 3 additions & 3 deletions big_tests/tests/graphql_token_SUITE.erl
Original file line number Diff line number Diff line change
Expand Up @@ -82,10 +82,10 @@ end_per_suite(Config) ->
dynamic_modules:restore_modules(Config),
escalus:end_per_suite(Config).

required_modules(Config) ->
required_modules() ->
KeyOpts = #{keys => #{token_secret => ram,
provision_pre_shared => ram},
backend => ct_helper:get_preset_var(Config, keystore_backend, mnesia)},
backend => ct_helper:get_internal_database()},
KeyStoreOpts = config_parser_helper:mod_config(mod_keystore, KeyOpts),
[{mod_keystore, KeyStoreOpts},
{mod_auth_token, auth_token_opts()}].
Expand Down Expand Up @@ -113,7 +113,7 @@ init_per_group(user, Config) ->

ensure_token_started(Config) ->
HostType = domain_helper:host_type(),
dynamic_modules:ensure_modules(HostType, required_modules(Config)),
dynamic_modules:ensure_modules(HostType, required_modules()),
Config.

ensure_token_stopped(Config) ->
Expand Down
2 changes: 1 addition & 1 deletion big_tests/tests/inbox_SUITE.erl
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ init_per_group(muclight_config, Config) ->
Config1 = inbox_helper:reload_inbox_option(Config, groupchat, [muclight]),
escalus:create_users(Config1, escalus:get_users([alice, alice_bis, bob, kate, mike]));
init_per_group(muc, Config) ->
muc_helper:load_muc(Config),
muc_helper:load_muc(),
inbox_helper:reload_inbox_option(Config, groupchat, [muc]);
init_per_group(limit_result, Config) ->
OptKey = [{modules, domain_helper:host_type()}, mod_inbox, max_result_limit],
Expand Down
12 changes: 6 additions & 6 deletions big_tests/tests/jingle_SUITE.erl
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ init_per_suite(Config) ->
case rpc(mim(), application, get_application, [nksip]) of
{ok, nksip} ->
distributed_helper:add_node_to_cluster(mim2(), Config),
start_nksip_in_mim_nodes(Config),
start_nksip_in_mim_nodes(),
application:ensure_all_started(esip),
spawn(fun() -> ets:new(jingle_sip_translator, [public, named_table]),
ets:new(jingle_sip_translator_bindings, [public, named_table]),
Expand All @@ -71,9 +71,9 @@ init_per_suite(Config) ->
{skip, build_was_not_configured_with_jingle_sip}
end.

start_nksip_in_mim_nodes(Config) ->
Pid1 = start_nskip_in_parallel(Config, mim(), #{}),
Pid2 = start_nskip_in_parallel(Config, mim2(), #{listen_port => 12346}),
start_nksip_in_mim_nodes() ->
Pid1 = start_nskip_in_parallel(mim(), #{}),
Pid2 = start_nskip_in_parallel(mim2(), #{listen_port => 12346}),
wait_for_process_to_stop(Pid1),
wait_for_process_to_stop(Pid2).

Expand All @@ -85,11 +85,11 @@ wait_for_process_to_stop(Pid) ->
ct:fail(wait_for_process_to_stop_timeout)
end.

start_nskip_in_parallel(Config, NodeSpec, ExtraOpts) ->
start_nskip_in_parallel(NodeSpec, ExtraOpts) ->
Domain = domain(),
Opts = #{proxy_host => <<"localhost">>,
proxy_port => 12345,
backend => ct_helper:get_preset_var(Config, jingle_sip_backend, mnesia)},
backend => ct_helper:get_internal_database()},
OptsWithExtra = maps:merge(Opts, ExtraOpts),
AllOpts = config_parser_helper:mod_config(mod_jingle_sip, OptsWithExtra),
RPCSpec = NodeSpec#{timeout => timer:seconds(60)},
Expand Down
2 changes: 1 addition & 1 deletion big_tests/tests/mam_SUITE.erl
Original file line number Diff line number Diff line change
Expand Up @@ -539,7 +539,7 @@ suite() ->
require_rpc_nodes([mim]) ++ escalus:suite().

init_per_suite(Config) ->
muc_helper:load_muc(Config),
muc_helper:load_muc(),
mam_helper:prepare_for_suite(
increase_limits(
delete_users([{escalus_user_db, {module, escalus_ejabberd}}
Expand Down
2 changes: 1 addition & 1 deletion big_tests/tests/mod_event_pusher_rabbit_SUITE.erl
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ init_per_suite(Config) ->
true ->
start_rabbit_wpool(domain()),
{ok, _} = application:ensure_all_started(amqp_client),
muc_helper:load_muc(Config),
muc_helper:load_muc(),
escalus:init_per_suite(Config);
false ->
{skip, "RabbitMQ server is not available on default port."}
Expand Down
2 changes: 1 addition & 1 deletion big_tests/tests/mod_event_pusher_sns_SUITE.erl
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ init_per_suite(Config) ->
%% For mocking with unnamed functions
mongoose_helper:inject_module(?MODULE),

muc_helper:load_muc(Config),
muc_helper:load_muc(),
escalus:init_per_suite(Config);
{error, _} ->
{skip, "erlcloud dependency is not enabled"}
Expand Down
2 changes: 1 addition & 1 deletion big_tests/tests/mod_global_distrib_SUITE.erl
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,7 @@ init_per_testcase(CaseName, Config)
{_, EuropeHost, _} = lists:keyfind(europe_node1, 1, get_hosts()),
trigger_rebalance(asia_node, EuropeHost),
%% Load muc on mim node
muc_helper:load_muc(Config),
muc_helper:load_muc(),
RegNode = ct:get_config({hosts, reg, node}),
%% Wait for muc.localhost to become visible from reg node
wait_for_domain(RegNode, muc_helper:muc_host()),
Expand Down
2 changes: 1 addition & 1 deletion big_tests/tests/muc_SUITE.erl
Original file line number Diff line number Diff line change
Expand Up @@ -329,7 +329,7 @@ init_per_suite(Config) ->
Config2 = escalus:init_per_suite(Config),
Config3 = dynamic_modules:save_modules(host_type(), Config2),
dynamic_modules:restart(host_type(), mod_disco, default_mod_config(mod_disco)),
muc_helper:load_muc(Config),
muc_helper:load_muc(),
mongoose_helper:ensure_muc_clean(),
Config3.

Expand Down
12 changes: 6 additions & 6 deletions big_tests/tests/muc_helper.erl
Original file line number Diff line number Diff line change
Expand Up @@ -52,15 +52,15 @@ foreach_recipient(Users, VerifyFun) ->
VerifyFun(escalus:wait_for_stanza(Recipient))
end, Users).

load_muc(Config) ->
load_muc(Config, domain_helper:host_type()).
load_muc() ->
load_muc(domain_helper:host_type()).

load_muc(Config, HostType) ->
load_muc(HostType) ->
Backend = muc_backend(),
MucHostPattern = ct:get_config({hosts, mim, muc_service_pattern}),
ct:log("Starting MUC for ~p", [HostType]),
Opts = #{host => subhost_pattern(MucHostPattern), backend => Backend,
online_backend => muc_online_backend(Config),
online_backend => muc_online_backend(),
hibernate_timeout => 2000,
hibernated_room_check_interval => 1000,
hibernated_room_timeout => 2000,
Expand All @@ -87,8 +87,8 @@ muc_host_pattern() ->
muc_backend() ->
mongoose_helper:mnesia_or_rdbms_backend().

muc_online_backend(Config) when is_list(Config) ->
ct_helper:get_preset_var(Config, muc_online_backend, mnesia).
muc_online_backend() ->
ct_helper:get_internal_database().

start_room(Config, User, Room, Nick, Opts) ->
From = generate_rpc_jid(User),
Expand Down
2 changes: 1 addition & 1 deletion big_tests/tests/muc_http_api_SUITE.erl
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ failure_response() ->
%%--------------------------------------------------------------------

init_per_suite(Config) ->
muc_helper:load_muc(Config),
muc_helper:load_muc(),
escalus:init_per_suite(Config).

end_per_suite(Config) ->
Expand Down
6 changes: 3 additions & 3 deletions big_tests/tests/oauth_SUITE.erl
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ init_per_suite(Config0) ->
true ->
HostType = domain_helper:host_type(),
Config = dynamic_modules:save_modules(HostType, Config0),
dynamic_modules:ensure_modules(HostType, required_modules(Config)),
dynamic_modules:ensure_modules(HostType, required_modules()),
escalus:init_per_suite(Config);
false ->
{skip, "RDBMS not available"}
Expand Down Expand Up @@ -459,8 +459,8 @@ serialize(ServerSideToken) ->
to_lower(B) when is_binary(B) ->
list_to_binary(string:to_lower(binary_to_list(B))).

required_modules(Config) ->
KeyOpts = #{backend => ct_helper:get_preset_var(Config, keystore_backend, mnesia),
required_modules() ->
KeyOpts = #{backend => ct_helper:get_internal_database(),
keys => #{token_secret => ram,
%% This is a hack for tests! As the name implies,
%% a pre-shared key should be read from a file stored
Expand Down
16 changes: 8 additions & 8 deletions big_tests/tests/sm_SUITE.erl
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ init_per_group(Group, Config) when Group =:= parallel_unacknowledged_message_hoo
Group =:= manual_ack_freq_long_session_timeout;
Group =:= parallel_manual_ack_freq_1;
Group =:= manual_ack_freq_2 ->
dynamic_modules:ensure_modules(host_type(), required_modules(Config, group, Group)),
dynamic_modules:ensure_modules(host_type(), required_modules(group, Group)),
Config;
init_per_group(stale_h, Config) ->
Config;
Expand All @@ -152,18 +152,18 @@ init_per_group(stream_mgmt_disabled, Config) ->
rpc(mim(), mnesia, delete_table, [sm_session]),
Config;
init_per_group(Group, Config) ->
dynamic_modules:ensure_modules(host_type(), required_modules(Config, group, Group)),
dynamic_modules:ensure_modules(host_type(), required_modules(group, Group)),
Config.

end_per_group(_Group, _Config) ->
ok.

init_per_testcase(resume_expired_session_returns_correct_h = CN, Config) ->
dynamic_modules:ensure_modules(host_type(), required_modules(Config, testcase, CN)),
dynamic_modules:ensure_modules(host_type(), required_modules(testcase, CN)),
escalus:init_per_testcase(CN, Config);
init_per_testcase(CN, Config) when CN =:= gc_repeat_after_never_means_no_cleaning;
CN =:= gc_repeat_after_timeout_does_clean ->
dynamic_modules:ensure_modules(host_type(), required_modules(Config, testcase, CN)),
dynamic_modules:ensure_modules(host_type(), required_modules(testcase, CN)),
Config2 = register_some_smid_h(Config),
escalus:init_per_testcase(CN, Config2);
init_per_testcase(server_requests_ack_freq_2 = CN, Config) ->
Expand All @@ -188,10 +188,10 @@ end_per_testcase(CaseName, Config) ->

%% Module configuration per group (in case of stale_h group it is per testcase)

required_modules(Config, Scope, Name) ->
required_modules(Scope, Name) ->
SMConfig = case required_sm_opts(Scope, Name) of
stopped -> stopped;
ExtraOpts -> maps:merge(common_sm_opts(Config), ExtraOpts)
ExtraOpts -> maps:merge(common_sm_opts(), ExtraOpts)
end,
Backend = mongoose_helper:mnesia_or_rdbms_backend(),
[{mod_stream_management, config_parser_helper:mod_config(mod_stream_management, SMConfig)},
Expand Down Expand Up @@ -219,8 +219,8 @@ required_sm_opts(testcase, gc_repeat_after_never_means_no_cleaning) ->
required_sm_opts(testcase, gc_repeat_after_timeout_does_clean) ->
#{stale_h => stale_h(?SHORT_TIMEOUT, ?SHORT_TIMEOUT)}.

common_sm_opts(Config) ->
Backend = ct_helper:get_preset_var(Config, stream_management_backend, mnesia),
common_sm_opts() ->
Backend = ct_helper:get_internal_database(),
#{buffer_max => ?SMALL_SM_BUFFER, backend => Backend}.

stale_h(RepeatAfter, Geriatric) ->
Expand Down