-
Notifications
You must be signed in to change notification settings - Fork 428
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #3092 from esl/mu-delete-domain-fast
Add remove_domain handler for MAM This PR addresses "Ensure efficient indexing and removal of persistent data by domain name". MAM already have proper indexes in the mam_server_user table. We should just LEFT JOIN it. OK, we can't LEFT JOIN in DELETEs. But we can use WHERE IN instead. Proposed changes include: * remove_domain/3 handler for MAM/MUC MAM. * a tip in schema. Because we use the same table to track MAM archive IDs for both MAM and MUC MAM.
- Loading branch information
Showing
7 changed files
with
197 additions
and
47 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,114 @@ | ||
-module(domain_removal_SUITE). | ||
|
||
%% API | ||
-export([all/0, | ||
groups/0, | ||
init_per_suite/1, | ||
end_per_suite/1, | ||
init_per_group/2, | ||
end_per_group/2, | ||
init_per_testcase/2, | ||
end_per_testcase/2]). | ||
|
||
-export([mam_pm_removal/1, | ||
mam_muc_removal/1]). | ||
|
||
-import(distributed_helper, [mim/0, rpc/4]). | ||
|
||
-include("mam_helper.hrl"). | ||
-include_lib("escalus/include/escalus.hrl"). | ||
-include_lib("escalus/include/escalus_xmlns.hrl"). | ||
-include_lib("common_test/include/ct.hrl"). | ||
-include_lib("exml/include/exml_stream.hrl"). | ||
|
||
all() -> | ||
[{group, mam_removal}]. | ||
|
||
groups() -> | ||
[ | ||
{mam_removal, [], [mam_pm_removal, | ||
mam_muc_removal]} | ||
]. | ||
|
||
domain() -> | ||
ct:get_config({hosts, mim, domain}). | ||
|
||
%%%=================================================================== | ||
%%% Overall setup/teardown | ||
%%%=================================================================== | ||
init_per_suite(Config) -> | ||
escalus:init_per_suite(Config). | ||
|
||
end_per_suite(Config) -> | ||
escalus:end_per_suite(Config). | ||
|
||
%%%=================================================================== | ||
%%% Group specific setup/teardown | ||
%%%=================================================================== | ||
init_per_group(Group, Config) -> | ||
case mongoose_helper:is_rdbms_enabled(domain()) of | ||
true -> | ||
Config2 = dynamic_modules:save_modules(domain(), Config), | ||
rpc(mim(), gen_mod_deps, start_modules, [domain(), group_to_modules(Group)]), | ||
Config2; | ||
false -> | ||
{skip, require_rdbms} | ||
end. | ||
|
||
end_per_group(_Groupname, Config) -> | ||
case mongoose_helper:is_rdbms_enabled(domain()) of | ||
true -> | ||
dynamic_modules:restore_modules(domain(), Config); | ||
false -> | ||
ok | ||
end, | ||
ok. | ||
|
||
group_to_modules(mam_removal) -> | ||
MH = muc_light_helper:muc_host(), | ||
[{mod_mam_meta, [{backend, rdbms}, {pm, []}, {muc, [{host, MH}]}]}, | ||
{mod_muc_light, []}]. | ||
|
||
%%%=================================================================== | ||
%%% Testcase specific setup/teardown | ||
%%%=================================================================== | ||
|
||
init_per_testcase(TestCase, Config) -> | ||
escalus:init_per_testcase(TestCase, Config). | ||
|
||
end_per_testcase(TestCase, Config) -> | ||
escalus:end_per_testcase(TestCase, Config). | ||
|
||
%%%=================================================================== | ||
%%% Test Cases | ||
%%%=================================================================== | ||
|
||
mam_pm_removal(Config) -> | ||
F = fun(Alice, Bob) -> | ||
escalus:send(Alice, escalus_stanza:chat_to(Bob, <<"OH, HAI!">>)), | ||
escalus:wait_for_stanza(Bob), | ||
mam_helper:wait_for_archive_size(Alice, 1), | ||
mam_helper:wait_for_archive_size(Bob, 1), | ||
run_remove_domain(), | ||
mam_helper:wait_for_archive_size(Alice, 0), | ||
mam_helper:wait_for_archive_size(Bob, 0) | ||
end, | ||
escalus_fresh:story(Config, [{alice, 1}, {bob, 1}], F). | ||
|
||
mam_muc_removal(Config0) -> | ||
F = fun(Config, Alice) -> | ||
Room = muc_helper:fresh_room_name(), | ||
MucHost = muc_light_helper:muc_host(), | ||
muc_light_helper:create_room(Room, MucHost, alice, | ||
[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), | ||
mam_helper:wait_for_room_archive_size(MucHost, Room, 1), | ||
run_remove_domain(), | ||
mam_helper:wait_for_room_archive_size(MucHost, Room, 0) | ||
end, | ||
escalus_fresh:story_with_config(Config0, [{alice, 1}], F). | ||
|
||
run_remove_domain() -> | ||
rpc(mim(), mongoose_hooks, remove_domain, [domain(), domain()]). |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters