-
Notifications
You must be signed in to change notification settings - Fork 428
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 remove_domain handler for MAM #3092
Merged
Merged
Changes from 5 commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
3289f5d
Add remove_domain handler for MAM
arcusfelis a869d1e
Remove unused stuff from domain_removal_SUITE
arcusfelis 0c8c546
Use hooks/1 function for mam rdbms backends
arcusfelis 4db482c
Make remove_domain hook host type specific
arcusfelis a20de39
Clean mam_config table
arcusfelis 8c4266b
Export remove_domain/3 hook handle from ejabberd_auth
arcusfelis File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
how optimal is this query? what if we have over 100k records selected by
SELECT id FROM mam_server_user where server = ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it should work.
ids would go into a temp table in this case. And use similar logic as left joins.
It would be a pretty long transaction though. And it could deadlock still (as always).