Skip to content

Commit

Permalink
Merge pull request #3235 from esl/mu-domain-removal-for-dynamic-domai…
Browse files Browse the repository at this point in the history
…ns-spec

Enable domain_removal_SUITE for dynamic_domains.spec
  • Loading branch information
chrzaszcz authored Aug 27, 2021
2 parents 35cd824 + d136282 commit 3e61c13
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 16 deletions.
1 change: 1 addition & 0 deletions big_tests/dynamic_domains.spec
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@

{suites, "tests", vcard_SUITE}.
{suites, "tests", vcard_simple_SUITE}.
{suites, "tests", domain_removal_SUITE}.

{config, ["dynamic_domains.config", "test.config"]}.

Expand Down
34 changes: 18 additions & 16 deletions big_tests/tests/domain_removal_SUITE.erl
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
private_removal/1]).

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

-include("mam_helper.hrl").
-include_lib("escalus/include/escalus.hrl").
Expand Down Expand Up @@ -57,30 +58,31 @@ end_per_suite(Config) ->
%%% Group specific setup/teardown
%%%===================================================================
init_per_group(Group, Config) ->
case mongoose_helper:is_rdbms_enabled(domain()) of
case mongoose_helper:is_rdbms_enabled(host_type()) of
true ->
Config2 = dynamic_modules:save_modules(domain(), Config),
rpc(mim(), gen_mod_deps, start_modules, [domain(), group_to_modules(Group)]),
Config2 = dynamic_modules:save_modules(host_type(), Config),
rpc(mim(), gen_mod_deps, start_modules, [host_type(), group_to_modules(Group)]),
Config2;
false ->
{skip, require_rdbms}
end.

end_per_group(_Groupname, Config) ->
case mongoose_helper:is_rdbms_enabled(domain()) of
case mongoose_helper:is_rdbms_enabled(host_type()) of
true ->
dynamic_modules:restore_modules(domain(), Config);
dynamic_modules:restore_modules(host_type(), Config);
false ->
ok
end,
ok.

group_to_modules(mam_removal) ->
HostPattern = subhost_pattern(muc_light_helper:muc_host()),
[{mod_mam_meta, [{backend, rdbms}, {pm, []}, {muc, [{host, HostPattern}]}]},
{mod_muc_light, []}];
MucHost = subhost_pattern(muc_light_helper:muc_host_pattern()),
[{mod_mam_meta, [{backend, rdbms}, {pm, []}, {muc, [{host, MucHost}]}]},
{mod_muc_light, [{backend, rdbms}, {host, MucHost}]}];
group_to_modules(muc_light_removal) ->
[{mod_muc_light, [{backend, rdbms}]}];
MucHost = subhost_pattern(muc_light_helper:muc_host_pattern()),
[{mod_muc_light, [{backend, rdbms}, {host, MucHost}]}];
group_to_modules(inbox_removal) ->
[{mod_inbox, []}];
group_to_modules(private_removal) ->
Expand Down Expand Up @@ -143,22 +145,22 @@ muc_light_removal(Config0) ->
%% GIVEN a room
Room = muc_helper:fresh_room_name(),
MucHost = muc_light_helper:muc_host(),
RoomAddr = <<Room/binary, "@", MucHost/binary>>,
muc_light_helper:create_room(Room, MucHost, alice,
[], Config, muc_light_helper:ver(1)),
RoomAddr = <<Room/binary, "@", MucHost/binary>>,
escalus:send(Alice, escalus_stanza:groupchat_to(RoomAddr, <<"text">>)),
escalus:wait_for_stanza(Alice),
RoomID = select_room_id(domain(), Room, MucHost),
{selected, [_]} = select_affs_by_room_id(domain(), RoomID),
{selected, [_|_]} = select_config_by_room_id(domain(), RoomID),
RoomID = select_room_id(host_type(), Room, MucHost),
{selected, [_]} = select_affs_by_room_id(host_type(), RoomID),
{selected, [_|_]} = select_config_by_room_id(host_type(), RoomID),
{ok, _RoomConfig, _AffUsers, _Version} = get_room_info(Room, MucHost),
%% WHEN domain hook called
run_remove_domain(),
%% THEN Room info not available
{error, not_exists} = get_room_info(Room, MucHost),
%% THEN Tables are empty
{selected, []} = select_affs_by_room_id(domain(), RoomID),
{selected, []} = select_config_by_room_id(domain(), RoomID)
{selected, []} = select_affs_by_room_id(host_type(), RoomID),
{selected, []} = select_config_by_room_id(host_type(), RoomID)
end,
escalus_fresh:story_with_config(Config0, [{alice, 1}], F).

Expand Down Expand Up @@ -198,7 +200,7 @@ private_removal(Config) ->
end).

run_remove_domain() ->
rpc(mim(), mongoose_hooks, remove_domain, [domain(), domain()]).
rpc(mim(), mongoose_hooks, remove_domain, [host_type(), domain()]).

get_room_info(RoomU, RoomS) ->
rpc(mim(), mod_muc_light_db_backend, get_info, [{RoomU, RoomS}]).
Expand Down

0 comments on commit 3e61c13

Please sign in to comment.