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

Rename MAM modules #3684

Merged
merged 5 commits into from
Jun 20, 2022
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
15 changes: 7 additions & 8 deletions big_tests/tests/amp_big_SUITE.erl
Original file line number Diff line number Diff line change
Expand Up @@ -302,7 +302,7 @@ notify_deliver_to_online_user_bare_jid_test(Config) ->
end).

notify_deliver_to_online_user_recipient_privacy_test(Config) ->
case is_module_loaded(mod_mam) of
case is_module_loaded(mod_mam_pm) of
true -> {skip, "MAM does not support privacy lists"};
false -> do_notify_deliver_to_online_user_recipient_privacy_test(Config)
end.
Expand Down Expand Up @@ -398,7 +398,7 @@ is_offline_storage_working(Config) ->
Status == mam orelse Status == offline.

notify_deliver_to_offline_user_recipient_privacy_test(Config) ->
case is_module_loaded(mod_mam) of
case is_module_loaded(mod_mam_pm) of
true -> {skip, "MAM does not support privacy lists"};
false -> do_notify_deliver_to_offline_user_recipient_privacy_test(Config)
end.
Expand Down Expand Up @@ -735,14 +735,14 @@ user_has_no_incoming_offline_messages(FreshConfig, UserName) ->
FreshConfig, [{UserName, 1}],
fun(User) ->
client_receives_nothing(User),
case is_module_loaded(mod_mam) of
case is_module_loaded(mod_mam_pm) of
true -> client_has_no_mam_messages(User);
false -> ok
end
end).

user_has_incoming_offline_message(FreshConfig, UserName, MsgText) ->
true = is_module_loaded(mod_mam) orelse is_module_loaded(mod_offline),
true = is_module_loaded(mod_mam_pm) orelse is_module_loaded(mod_offline),
{ok, Client} = escalus_client:start(FreshConfig, UserName, <<"new-session">>),
escalus:send(Client, escalus_stanza:presence(<<"available">>)),
case is_module_loaded(mod_offline) of
Expand All @@ -751,7 +751,7 @@ user_has_incoming_offline_message(FreshConfig, UserName, MsgText) ->
end,
Presence = escalus:wait_for_stanza(Client),
escalus:assert(is_presence, Presence),
case is_module_loaded(mod_mam) of
case is_module_loaded(mod_mam_pm) of
true -> client_has_mam_message(Client);
false -> ok
end,
Expand Down Expand Up @@ -988,10 +988,9 @@ required_modules(_) ->
[].

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

offline_modules(on) ->
[{mod_offline, config_parser_helper:mod_config(mod_offline,
Expand Down
4 changes: 2 additions & 2 deletions big_tests/tests/domain_removal_SUITE.erl
Original file line number Diff line number Diff line change
Expand Up @@ -84,10 +84,10 @@ group_to_modules(auth_removal) ->
[];
group_to_modules(cache_removal) ->
[{mod_cache_users, config_parser_helper:default_mod_config(mod_cache_users)},
{mod_mam_meta, mam_helper:config_opts(#{pm => #{}})}];
{mod_mam, mam_helper:config_opts(#{pm => #{}})}];
group_to_modules(mam_removal) ->
MucHost = subhost_pattern(muc_light_helper:muc_host_pattern()),
[{mod_mam_meta, mam_helper:config_opts(#{pm => #{}, muc => #{host => MucHost}})},
[{mod_mam, mam_helper:config_opts(#{pm => #{}, muc => #{host => MucHost}})},
{mod_muc_light, mod_config(mod_muc_light, #{backend => rdbms})}];
group_to_modules(muc_light_removal) ->
[{mod_muc_light, mod_config(mod_muc_light, #{backend => rdbms})}];
Expand Down
32 changes: 16 additions & 16 deletions big_tests/tests/gdpr_SUITE.erl
Original file line number Diff line number Diff line change
Expand Up @@ -354,33 +354,33 @@ groupchat_module(muclight) ->

mam_required_modules(CN, Backend) when CN =:= remove_mam_pm;
CN =:= retrieve_mam_pm ->
[{mod_mam_meta, mam_helper:config_opts(#{backend => Backend, pm => #{}})}];
[{mod_mam, 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, mam_helper:config_opts(#{backend => Backend,
pm => #{},
muc => #{host => HostPattern}})},
[{mod_mam, mam_helper:config_opts(#{backend => Backend,
pm => #{},
muc => #{host => HostPattern}})},
{mod_muc_light, default_mod_config(mod_muc_light)}];
mam_required_modules(retrieve_mam_pm_and_muc_light_interfere, Backend) ->
HostPattern = subhost_pattern(muc_light_helper:muc_host_pattern()),
[{mod_mam_meta, mam_helper:config_opts(#{backend => Backend,
db_message_format => mam_message_xml,
pm => #{archive_groupchats => true},
muc => #{host => HostPattern}})},
[{mod_mam, mam_helper:config_opts(#{backend => Backend,
db_message_format => mam_message_xml,
pm => #{archive_groupchats => true},
muc => #{host => HostPattern}})},
{mod_muc_light, default_mod_config(mod_muc_light)}];
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, mam_helper:config_opts(#{backend => Backend,
pm => #{},
muc => #{host => HostPattern}})},
[{mod_mam, mam_helper:config_opts(#{backend => Backend,
pm => #{},
muc => #{host => HostPattern}})},
{mod_muc, muc_helper:make_opts(#{host => HostPattern})}];
mam_required_modules(retrieve_mam_muc_store_pm, Backend) ->
HostPattern = subhost_pattern(muc_helper:muc_host_pattern()),
[{mod_mam_meta, mam_helper:config_opts(#{backend => Backend,
pm => #{archive_groupchats => true},
muc => #{host => HostPattern}})},
[{mod_mam, mam_helper:config_opts(#{backend => Backend,
pm => #{archive_groupchats => true},
muc => #{host => HostPattern}})},
{mod_muc, muc_helper:make_opts(#{host => HostPattern})}].

pick_enabled_backend() ->
Expand Down Expand Up @@ -866,7 +866,7 @@ retrieve_mam_pm_and_muc_light_dont_interfere(Config) ->
[mam_helper:wait_for_archive_size(User, 2) || User <- [Alice, Bob]],

false = mongoose_helper:successful_rpc(gen_mod, get_module_opt,
[host_type(), mod_mam, archive_groupchats, undefined]),
[host_type(), mod_mam_pm, archive_groupchats, undefined]),

AliceDir = retrieve_all_personal_data(Alice, Config),
BobDir = retrieve_all_personal_data(Bob, Config),
Expand Down Expand Up @@ -914,7 +914,7 @@ retrieve_mam_pm_and_muc_light_interfere(Config) ->
mam_helper:wait_for_archive_size(Kate, 3),

true = mongoose_helper:successful_rpc(gen_mod, get_module_opt,
[host_type(), mod_mam, archive_groupchats, undefined]),
[host_type(), mod_mam_pm, archive_groupchats, undefined]),

AliceDir = retrieve_all_personal_data(Alice, Config),
BobDir = retrieve_all_personal_data(Bob, Config),
Expand Down
22 changes: 11 additions & 11 deletions big_tests/tests/mam_SUITE.erl
Original file line number Diff line number Diff line change
Expand Up @@ -647,19 +647,19 @@ required_modules_for_group(C, muc_light, Config) ->
Opts = config_opts(Extra#{pm => #{}, muc => #{host => MUCHost}}),
Config1 = maybe_set_wait(C, [muc, pm], [{mam_meta_opts, Opts} | Config]),
{[{mod_muc_light, default_mod_config(mod_muc_light)},
{mod_mam_meta, Opts}], Config1};
{mod_mam, 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)),
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};
{[{mod_mam, Opts}], Config1};
required_modules_for_group(C, BG, Config) ->
Extra = maps:merge(mam_opts_for_conf(C), mam_opts_for_base_group(BG)),
Opts = config_opts(Extra#{pm => #{}}),
Config1 = maybe_set_wait(C, [pm], [{mam_meta_opts, Opts} | Config]),
{[{mod_mam_meta, Opts}], Config1}.
{[{mod_mam, Opts}], Config1}.

maybe_set_wait(C, Types, Config) when C =:= rdbms_async_pool;
C =:= rdbms_async_cache ->
Expand Down Expand Up @@ -980,31 +980,31 @@ end_per_testcase(CaseName, Config) ->
required_modules(muc_light_stored_in_pm_if_allowed_to, Config) ->
Opts = #{pm := PM} = ?config(mam_meta_opts, Config),
NewOpts = Opts#{pm := PM#{archive_groupchats => true}},
[{mod_mam_meta, NewOpts}];
[{mod_mam, NewOpts}];
required_modules(muc_light_chat_markers_are_archived_if_enabled, Config) ->
Opts = #{muc := MUC} = ?config(mam_meta_opts, Config),
NewOpts = Opts#{muc := MUC#{archive_chat_markers => true}},
[{mod_mam_meta, NewOpts}];
[{mod_mam, NewOpts}];
required_modules(muc_no_elements, Config) ->
Opts = #{muc := MUC} = ?config(mam_meta_opts, Config),
NewOpts = Opts#{muc := MUC#{no_stanzaid_element => true}},
[{mod_mam_meta, NewOpts}];
[{mod_mam, NewOpts}];
required_modules(muc_only_stanzaid, Config) ->
Opts = ?config(mam_meta_opts, Config),
[{mod_mam_meta, Opts}];
[{mod_mam, Opts}];
% configurable_archiveid basic group
required_modules(no_elements, Config) ->
Opts = #{pm := PM} = ?config(mam_meta_opts, Config),
NewOpts = Opts#{pm := PM#{no_stanzaid_element => true}},
[{mod_mam_meta, NewOpts}];
[{mod_mam, NewOpts}];
required_modules(CaseName, Config) when CaseName =:= same_stanza_id;
CaseName =:= retract_message_on_stanza_id ->
Opts = #{pm := PM} = ?config(mam_meta_opts, Config),
NewOpts = Opts#{pm := PM#{same_mam_id_for_peers => true}},
[{mod_mam_meta, NewOpts}];
[{mod_mam, NewOpts}];
required_modules(_, Config) ->
Opts = ?config(mam_meta_opts, Config),
[{mod_mam_meta, Opts}].
[{mod_mam, Opts}].

%%--------------------------------------------------------------------
%% Group name helpers
Expand Down Expand Up @@ -2850,7 +2850,7 @@ metric_incremented_on_archive_request(ConfigIn) ->
end,
HostType = domain_helper:host_type(mim),
HostTypePrefix = domain_helper:make_metrics_prefix(HostType),
MongooseMetrics = [{[HostTypePrefix, backends, mod_mam, lookup], changed}],
MongooseMetrics = [{[HostTypePrefix, backends, mod_mam_pm, lookup], changed}],
Config = [{mongoose_metrics, MongooseMetrics} | ConfigIn],
escalus_fresh:story(Config, [{alice, 1}], F).

Expand Down
20 changes: 10 additions & 10 deletions big_tests/tests/mam_helper.erl
Original file line number Diff line number Diff line change
Expand Up @@ -125,15 +125,15 @@ config_opts(ExtraOpts) ->
lists:foldl(fun set_opts/2, ExtraOpts, [defaults, backend, pm, muc, async_writer]).

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

Expand Down Expand Up @@ -801,16 +801,16 @@ wait_for_room_archive_size(Server, Username, ExpectedSize) ->


archive_size(Server, Username) ->
rpc_apply(mod_mam, archive_size, [Server, Username]).
rpc_apply(mod_mam_pm, archive_size, [Server, Username]).

archive_size_with_host_type(HostType, Server, Username) ->
rpc_apply(mod_mam, archive_size_with_host_type, [HostType, Server, Username]).
rpc_apply(mod_mam_pm, archive_size_with_host_type, [HostType, Server, Username]).

room_archive_size(Server, Username) ->
rpc_apply(mod_mam_muc, archive_size, [Server, Username]).

delete_archive(Server, Username) ->
rpc_apply(mod_mam, delete_archive, [Server, Username]).
rpc_apply(mod_mam_pm, delete_archive, [Server, Username]).

delete_room_archive(Server, Username) ->
rpc_apply(mod_mam_muc, delete_archive, [Server, Username]).
Expand Down Expand Up @@ -967,7 +967,7 @@ put_msg({{MsgIdOwner, MsgIdRemote},
archive_message(Map2).

archive_message(#{} = Map) ->
ok = rpc_apply(mod_mam, archive_message_from_ct, [Map]).
ok = rpc_apply(mod_mam_pm, archive_message_from_ct, [Map]).

muc_bootstrap_archive(Config) ->
Room = ?config(room, Config),
Expand Down Expand Up @@ -1017,7 +1017,7 @@ archive_muc_msg({{MsgID, _},
packet => Packet}]).

get_archive_id(Server, User) ->
rpc_apply(mod_mam, archive_id, [Server, User]).
rpc_apply(mod_mam_pm, archive_id, [Server, User]).

get_muc_archive_id(MucHost, Room) ->
rpc_apply(mod_mam_muc, archive_id, [MucHost, Room]).
Expand Down
2 changes: 1 addition & 1 deletion big_tests/tests/mam_proper_SUITE.erl
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ init_per_group(G, _C) ->
end.

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

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

group_to_modules(send_message) ->
MH = subhost_pattern(muc_light_helper:muc_host_pattern()),
[{mod_mam_meta, mam_helper:config_opts(#{pm => #{},
muc => #{host => MH},
send_message => mam_send_message_example})},
[{mod_mam, mam_helper:config_opts(#{pm => #{},
muc => #{host => MH},
send_message => mam_send_message_example})},
{mod_muc_light, mod_config(mod_muc_light,
#{backend => mongoose_helper:mnesia_or_rdbms_backend()})},
{mam_send_message_example, []}].
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 @@ -529,7 +529,7 @@ setup_mam(disabled) -> ok;
setup_mam(Backend) ->
HostPattern = subhost_pattern(muc_helper:muc_host_pattern()),
dynamic_modules:ensure_modules(
host_type(), [{mod_mam_meta,
host_type(), [{mod_mam,
mam_helper:config_opts(#{backend => Backend,
muc => #{host => HostPattern}})}]).

Expand Down
6 changes: 3 additions & 3 deletions big_tests/tests/muc_light_SUITE.erl
Original file line number Diff line number Diff line change
Expand Up @@ -259,12 +259,12 @@ end_per_testcase(CaseName, Config) ->
%% Module configuration per test case

required_modules(CaseName, MAMBackend) ->
[{mod_mam_meta, mam_helper:config_opts(#{backend => MAMBackend,
muc => #{host => subhost_pattern(?MUCHOST)}})} |
[{mod_mam, mam_helper:config_opts(#{backend => MAMBackend,
muc => #{host => subhost_pattern(?MUCHOST)}})} |
common_required_modules(CaseName)].

required_modules(CaseName) ->
[{mod_mam_meta, stopped} | common_required_modules(CaseName)].
[{mod_mam, stopped} | common_required_modules(CaseName)].

common_required_modules(CaseName) ->
BasicOpts = maps:merge(common_muc_light_opts(), muc_light_opts(CaseName)),
Expand Down
6 changes: 3 additions & 3 deletions big_tests/tests/muc_light_legacy_SUITE.erl
Original file line number Diff line number Diff line change
Expand Up @@ -191,12 +191,12 @@ end_per_testcase(CaseName, Config) ->
%% Module configuration per test case

required_modules(CaseName, MAMBackend) ->
[{mod_mam_meta, mam_helper:config_opts(#{backend => MAMBackend,
muc => #{host => subhost_pattern(?MUCHOST)}})} |
[{mod_mam, mam_helper:config_opts(#{backend => MAMBackend,
muc => #{host => subhost_pattern(?MUCHOST)}})} |
common_required_modules(CaseName)].

required_modules(CaseName) ->
[{mod_mam_meta, stopped} | common_required_modules(CaseName)].
[{mod_mam, stopped} | common_required_modules(CaseName)].

common_required_modules(CaseName) ->
Opts = maps:merge(common_muc_light_opts(), muc_light_opts(CaseName)),
Expand Down
12 changes: 6 additions & 6 deletions big_tests/tests/rest_helper.erl
Original file line number Diff line number Diff line change
Expand Up @@ -329,11 +329,11 @@ maybe_enable_mam(_, _, C) ->

required_mam_modules(Backend) ->
MucPattern = subhost_pattern(muc_light_helper:muc_host_pattern()),
[{mod_mam_meta, mam_helper:config_opts(#{backend => Backend,
pm => #{},
muc => #{host => MucPattern},
async_writer => #{enabled => false},
archive_chat_markers => true})}].
[{mod_mam, mam_helper:config_opts(#{backend => Backend,
pm => #{},
muc => #{host => MucPattern},
async_writer => #{enabled => false},
archive_chat_markers => true})}].

maybe_skip_mam_test_cases(CaseName, CasesRequireingMAM, Config) ->
case lists:member(CaseName, CasesRequireingMAM) of
Expand Down Expand Up @@ -377,7 +377,7 @@ make_arc_id(Client) ->
Server = escalus_client:server(Client),
Bin = escalus_client:short_jid(Client),
Jid = mongoose_helper:make_jid(User, Server, <<>>),
{Bin, Jid, mam_helper:rpc_apply(mod_mam, archive_id, [Server, User])}.
{Bin, Jid, mam_helper:rpc_apply(mod_mam_pm, archive_id, [Server, User])}.

fill_room_archive(RoomID, Users, AlreadyArchivedCount) ->
{TodayDate, _} = calendar:local_time(),
Expand Down
2 changes: 1 addition & 1 deletion big_tests/tests/service_domain_db_SUITE.erl
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,7 @@ end_per_testcase(TestcaseName, Config) ->
init_per_testcase2(TestcaseName, Config)
when TestcaseName =:= rest_delete_domain_cleans_data_from_mam ->
HostType = dummy_auth_host_type(),
Mods = [{mod_mam_meta, mam_helper:config_opts(#{pm => #{}})}],
Mods = [{mod_mam, mam_helper:config_opts(#{pm => #{}})}],
dynamic_modules:ensure_modules(HostType, Mods),
escalus:init_per_testcase(TestcaseName, Config);
init_per_testcase2(_, Config) ->
Expand Down
4 changes: 2 additions & 2 deletions big_tests/tests/service_mongoose_system_metrics_SUITE.erl
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,7 @@ rdbms_module_opts_are_reported(_Config) ->
mongoose_helper:wait_until(fun are_modules_reported/0, true),
check_module_backend(mod_auth_token, rdbms),
check_module_backend(mod_inbox, rdbms),
check_module_backend(mod_mam_meta, rdbms).
check_module_backend(mod_mam, rdbms).

check_module_backend(Module, Backend) ->
check_module_opt(Module, backend, atom_to_binary(Backend)).
Expand Down Expand Up @@ -356,7 +356,7 @@ modules_to_test(module_opts_are_reported) ->
modules_to_test(rdbms_module_opts_are_reported) ->
[required_module(mod_auth_token),
required_module(mod_inbox),
required_module(mod_mam_meta)].
required_module(mod_mam)].

required_module(Module) ->
required_module(Module, #{}).
Expand Down
7 changes: 7 additions & 0 deletions doc/migrations/5.1.0_6.0.0.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
## Configuration

The `mod_mam_meta` module is now named `mod_mam` for simplicity, so if you are using this module, you need to update the module name in `mongooseim.toml`.

## Metrics

The `mod_mam` backend module is now named `mod_mam_pm` for consistency with `mod_mam_muc`. As a result, the backend metrics have updated names, i.e. each `[backends, mod_mam, Metric]` name is changed to `[backends, mod_mam_pm, Metric]`, where `Metric` can be `lookup` or `archive`.
Loading