Skip to content

Commit

Permalink
Fix big suites
Browse files Browse the repository at this point in the history
  • Loading branch information
chrzaszcz committed Feb 28, 2022
1 parent 0ed95f9 commit 2b317e8
Show file tree
Hide file tree
Showing 13 changed files with 165 additions and 174 deletions.
8 changes: 3 additions & 5 deletions big_tests/tests/amp_big_SUITE.erl
Original file line number Diff line number Diff line change
Expand Up @@ -988,12 +988,10 @@ required_modules(_) ->
[].

mam_modules(on) ->
[{mod_mam_rdbms_user, [pm]},
{mod_mam_rdbms_prefs, [pm]},
{mod_mam_rdbms_arch, []},
{mod_mam, []}];
[{mod_mam_meta, mam_helper:config_opts(#{pm => #{},
async_writer => #{enabled => false}})}];
mam_modules(off) ->
[{mod_mam, stopped}].
[{mod_mam_meta, stopped}].

offline_modules(on) ->
[{mod_offline, [{access_max_user_messages, max_user_offline_messages}]}];
Expand Down
8 changes: 6 additions & 2 deletions big_tests/tests/domain_removal_SUITE.erl
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

-import(distributed_helper, [mim/0, rpc/4, subhost_pattern/1]).
-import(domain_helper, [host_type/0, domain_to_host_type/2, domain/0]).
-import(config_parser_helper, [config/2, default_config/1, mod_config/2]).

-include("mam_helper.hrl").
-include_lib("eunit/include/eunit.hrl").
Expand Down Expand Up @@ -79,10 +80,13 @@ group_to_modules(auth_removal) ->
[];
group_to_modules(cache_removal) ->
[{mod_cache_users, []},
{mod_mam_meta, [{backend, rdbms}, {pm, []}]}];
{mod_mam_meta, mod_config(mod_mam_meta,
#{pm => default_config([modules, mod_mam_meta, pm])})}];
group_to_modules(mam_removal) ->
MucHost = subhost_pattern(muc_light_helper:muc_host_pattern()),
[{mod_mam_meta, [{backend, rdbms}, {pm, []}, {muc, [{host, MucHost}]}]},
[{mod_mam_meta, mod_config(mod_mam_meta,
#{pm => default_config([modules, mod_mam_meta, pm]),
muc => config([modules, mod_mam_meta, muc], #{host => MucHost})})},
{mod_muc_light, [{backend, rdbms}, {host, MucHost}]}];
group_to_modules(muc_light_removal) ->
MucHost = subhost_pattern(muc_light_helper:muc_host_pattern()),
Expand Down
37 changes: 16 additions & 21 deletions big_tests/tests/gdpr_SUITE.erl
Original file line number Diff line number Diff line change
Expand Up @@ -57,11 +57,8 @@
]).

-import(mongooseimctl_helper, [mongooseimctl/3]).

-import(distributed_helper, [mim/0, subhost_pattern/1, rpc/4]).

-import(muc_light_helper, [room_bin_jid/1]).

-import(domain_helper, [host_type/0]).

-define(ROOM, <<"tt1">>).
Expand Down Expand Up @@ -223,7 +220,7 @@ init_per_group(_GN, Config) ->
end_per_group(_GN, Config) ->
Config.

try_backend_for_mam( Config,Backend) ->
try_backend_for_mam(Config, Backend) ->
case is_backend_enabled(Backend) of
true -> [{mam_backend, Backend} | Config];
false -> {skip, backend_is_not_configured}
Expand Down Expand Up @@ -357,36 +354,34 @@ groupchat_module(muclight) ->
{rooms_in_rosters, true}]}].

mam_required_modules(CN, Backend) when CN =:= remove_mam_pm;
CN =:= retrieve_mam_pm->
[{mod_mam_meta, [{backend, Backend},
{pm, [{archive_groupchats, false}]}]}];
CN =:= retrieve_mam_pm ->
[{mod_mam_meta, mam_helper:config_opts(#{backend => Backend, pm => #{}})}];
mam_required_modules(CN, Backend) when CN =:= retrieve_mam_pm_and_muc_light_dont_interfere;
CN =:= retrieve_mam_muc_light ->
HostPattern = subhost_pattern(muc_light_helper:muc_host_pattern()),
[{mod_mam_meta, [{backend, Backend},
{pm, [{archive_groupchats, false}]},
{muc, [{host, HostPattern}]}]},
[{mod_mam_meta, mam_helper:config_opts(#{backend => Backend,
pm => #{},
muc => #{host => HostPattern}})},
{mod_muc_light, [{host, HostPattern}]}];
mam_required_modules(retrieve_mam_pm_and_muc_light_interfere, Backend) ->
HostPattern = subhost_pattern(muc_light_helper:muc_host_pattern()),
[{mod_mam_meta, [{backend, Backend},
{rdbms_message_format, simple}, %% ignored for any other than rdbms backend
simple, %% used only by cassandra backend
{pm, [{archive_groupchats, true}]},
{muc, [{host, HostPattern}]}]},
[{mod_mam_meta, mam_helper:config_opts(#{backend => Backend,
db_message_format => mam_message_xml,
pm => #{archive_groupchats => true},
muc => #{host => HostPattern}})},
{mod_muc_light, [{host, HostPattern}]}];
mam_required_modules(CN, Backend) when CN =:= retrieve_mam_muc_private_msg;
CN =:= retrieve_mam_muc ->
HostPattern = subhost_pattern(muc_helper:muc_host_pattern()),
[{mod_mam_meta, [{backend, Backend},
{pm, [{archive_groupchats, false}]},
{muc, [{host, HostPattern}]}]},
[{mod_mam_meta, mam_helper:config_opts(#{backend => Backend,
pm => #{},
muc => #{host => HostPattern}})},
{mod_muc, [{host, HostPattern}]}];
mam_required_modules(retrieve_mam_muc_store_pm, Backend) ->
HostPattern = subhost_pattern(muc_helper:muc_host_pattern()),
[{mod_mam_meta, [{backend, Backend},
{pm, [{archive_groupchats, true}]},
{muc, [{host, HostPattern}]}]},
[{mod_mam_meta, mam_helper:config_opts(#{backend => Backend,
pm => #{archive_groupchats => true},
muc => #{host => HostPattern}})},
{mod_muc, [{host, HostPattern}]}].

pick_enabled_backend() ->
Expand Down
40 changes: 13 additions & 27 deletions big_tests/tests/mam_SUITE.erl
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,8 @@
run_set_and_get_prefs_case/4,
muc_light_host/0,
host_type/0,
set_wait_for_parallel_writer/2
set_wait_for_parallel_writer/2,
config_opts/1
]).

-import(muc_light_helper,
Expand All @@ -215,9 +216,6 @@

-import(domain_helper, [domain/0]).

-import(config_parser_helper, [config/2, default_config/1,
mod_config/2, default_mod_config/1]).

-include("mam_helper.hrl").
-include_lib("escalus/include/escalus.hrl").
-include_lib("escalus/include/escalus_xmlns.hrl").
Expand Down Expand Up @@ -654,21 +652,20 @@ end_per_group(Group, Config) ->
required_modules_for_group(C, muc_light, Config) ->
Extra = mam_opts_for_conf(C),
MUCHost = subhost_pattern(muc_light_helper:muc_host_pattern()),
MUCOpts = #{host => MUCHost},
Opts = mod_config(mod_mam_meta, Extra#{pm => pm_opts(#{}), muc => muc_opts(MUCOpts)}),
Opts = config_opts(Extra#{pm => #{}, muc => #{host => MUCHost}}),
Config1 = maybe_set_wait(C, [muc, pm], [{mam_meta_opts, Opts} | Config]),
{[{mod_muc_light, [{host, MUCHost}]},
{mod_mam_meta, Opts}], Config1};
required_modules_for_group(C, BG, Config) when BG =:= muc_all;
BG =:= muc_disabled_retraction ->
Extra = maps:merge(mam_opts_for_conf(C), mam_opts_for_base_group(BG)),
MUCOpts = #{host => subhost_pattern(muc_domain(Config))},
Opts = mod_config(mod_mam_meta, Extra#{muc => muc_opts(MUCOpts)}),
MUCHost = subhost_pattern(muc_domain(Config)),
Opts = config_opts(Extra#{muc => #{host => MUCHost}}),
Config1 = maybe_set_wait(C, [muc], [{mam_meta_opts, Opts} | Config]),
{[{mod_mam_meta, Opts}], Config1};
required_modules_for_group(C, BG, Config) ->
Extra = maps:merge(mam_opts_for_conf(C), mam_opts_for_base_group(BG)),
Opts = mod_config(mod_mam_meta, Extra#{pm => pm_opts(#{})}),
Opts = config_opts(Extra#{pm => #{}}),
Config1 = maybe_set_wait(C, [pm], [{mam_meta_opts, Opts} | Config]),
{[{mod_mam_meta, Opts}], Config1}.

Expand All @@ -680,8 +677,7 @@ maybe_set_wait(_C, _, Config) ->

mam_opts_for_conf(riak_timed_yz_buckets) ->
#{backend => riak,
user_prefs_store => mnesia,
riak => default_config([modules, mod_mam_meta, riak])};
user_prefs_store => mnesia};
mam_opts_for_conf(elasticsearch) ->
#{backend => elasticsearch,
user_prefs_store => mnesia};
Expand All @@ -694,35 +690,25 @@ mam_opts_for_conf(rdbms_simple) ->
maps:merge(SimpleOpts, mam_opts_for_conf(rdbms));
mam_opts_for_conf(rdbms) ->
#{user_prefs_store => rdbms,
async_writer => async_opts(#{enabled => false}),
async_writer => #{enabled => false},
cache_users => false};
mam_opts_for_conf(rdbms_async_pool) ->
#{user_prefs_store => rdbms,
async_writer => async_opts(#{flush_interval => 1}),
async_writer => #{flush_interval => 1},
cache_users => false};
mam_opts_for_conf(rdbms_mnesia) ->
#{user_prefs_store => mnesia,
async_writer => async_opts(#{enabled => false}),
async_writer => #{enabled => false},
cache_users => false};
mam_opts_for_conf(rdbms_cache) ->
#{user_prefs_store => rdbms,
async_writer => async_opts(#{enabled => false})};
async_writer => #{enabled => false}};
mam_opts_for_conf(rdbms_async_cache) ->
#{user_prefs_store => rdbms,
async_writer => async_opts(#{flush_interval => 1})};
async_writer => #{flush_interval => 1}};
mam_opts_for_conf(rdbms_mnesia_cache) ->
#{user_prefs_store => mnesia,
async_writer => async_opts(#{enabled => false})}.

async_opts(Extra) ->
AsyncOpts = default_config([modules, mod_mam_meta, async_writer]),
maps:merge(AsyncOpts, Extra).

pm_opts(Extra) ->
config([modules, mod_mam_meta, pm], Extra).

muc_opts(Extra) ->
config([modules, mod_mam_meta, muc], Extra).
async_writer => #{enabled => false}}.

muc_domain(Config) ->
proplists:get_value(muc_domain, Config, muc_helper:muc_host_pattern()).
Expand Down
22 changes: 21 additions & 1 deletion big_tests/tests/mam_helper.erl
Original file line number Diff line number Diff line change
Expand Up @@ -115,9 +115,29 @@
generate_msg_for_date_user/3,
generate_msg_for_date_user/4,
random_text/0,
put_msg/1
put_msg/1,
config_opts/1
]).

-import(config_parser_helper, [config/2, mod_config/2]).

config_opts(ExtraOpts) ->
lists:foldl(fun(Step, OptsIn) -> set_opts(Step, OptsIn) end,
ExtraOpts, [defaults, backend, pm, muc, async_writer]).

set_opts(defaults, Opts) ->
mod_config(mod_mam_meta, Opts);
set_opts(backend, #{backend := riak} = Opts) ->
Opts#{riak => config([modules, mod_mam_meta, riak], maps:get(riak, Opts, #{}))};
set_opts(pm, #{pm := PMExtra} = Opts) ->
Opts#{pm := config([modules, mod_mam_meta, pm], PMExtra)};
set_opts(muc, #{muc := MUCExtra} = Opts) ->
Opts#{muc := config([modules, mod_mam_meta, muc], MUCExtra)};
set_opts(async_writer, #{async_writer := AsyncExtra} = Opts) ->
Opts#{async_writer := config([modules, mod_mam_meta, async_writer], AsyncExtra)};
set_opts(_, Opts) ->
Opts.

rpc_apply(M, F, Args) ->
case rpc_call(M, F, Args) of
{badrpc, Reason} ->
Expand Down
12 changes: 9 additions & 3 deletions big_tests/tests/mam_proper_SUITE.erl
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
-import(distributed_helper, [mim/0,
require_rpc_nodes/1,
rpc/4]).
-import(domain_helper, [host_type/0]).

%% Common Test init/teardown functions
suite() ->
Expand All @@ -19,17 +20,22 @@ groups() ->

init_per_suite(C) ->
application:ensure_all_started(jid),
escalus:init_per_suite(C).
C1 = dynamic_modules:save_modules(host_type(), C),
escalus:init_per_suite(C1).

end_per_suite(C) ->
dynamic_modules:restore_modules(C),
escalus:end_per_suite(C).

init_per_group(_G, C) ->
init_per_group(G, _C) ->
case mongoose_helper:is_rdbms_enabled(domain_helper:host_type()) of
true -> C;
true -> dynamic_modules:ensure_modules(host_type(), required_modules(G));
false -> {skip, "rdbms not enabled"}
end.

required_modules(_G) ->
[{mod_mam_meta, mam_helper:config_opts(#{pm => #{}})}].

end_per_group(_G, C) ->
C.

Expand Down
5 changes: 3 additions & 2 deletions big_tests/tests/mam_send_message_SUITE.erl
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,9 @@ end_per_group(_Groupname, Config) ->

group_to_modules(send_message) ->
MH = subhost_pattern(muc_light_helper:muc_host_pattern()),
[{mod_mam_meta, [{backend, rdbms}, {pm, []}, {muc, [{host, MH}]},
{send_message, mam_send_message_example}]},
[{mod_mam_meta, mam_helper:config_opts(#{pm => #{},
muc => #{host => MH},
send_message => mam_send_message_example})},
{mod_muc_light, [{host, subhost_pattern(muc_light_helper:muc_host_pattern())},
{backend, mongoose_helper:mnesia_or_rdbms_backend()}]},
{mam_send_message_example, []}].
Expand Down
Loading

0 comments on commit 2b317e8

Please sign in to comment.