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

C2s/merge master #3790

Merged
merged 157 commits into from
Oct 7, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
157 commits
Select commit Hold shift + click to select a range
079be4d
Eliminate mongoose_commands from mongoose_client_api_contacts
chrzaszcz Jun 21, 2022
77ca788
Remove the legacy Client API
Jun 30, 2022
ffc778d
Merge pull request #3697 from esl/without-mongoose-commands
Premwoik Jul 1, 2022
f838ee1
Merge branch 'master' into feature/unified-rest-api
chrzaszcz Aug 25, 2022
95bf2d5
Merge branch 'master' into feature/unified-rest-api
chrzaszcz Sep 6, 2022
ecd2cf3
Domain admin tests in roster suite
jacekwegr Aug 26, 2022
f84b41b
Missing domain admin tests
jacekwegr Sep 2, 2022
77951fc
Merge pull request #3736 from esl/domain-admin-roster-tests
JanuszJakubiec Sep 9, 2022
8130597
Implement broadcasts in async pools
NelsonVides Sep 9, 2022
7e19c4f
Merge pull request #3755 from esl/async/broadcasts
arcusfelis Sep 9, 2022
9c2c138
OS extend aggregator requests
NelsonVides Sep 12, 2022
552a713
OS fix return type for transaction request
NelsonVides Sep 12, 2022
2864996
Test the aggregation
NelsonVides Sep 12, 2022
353186e
Cleanup async tests
NelsonVides Sep 12, 2022
b43756b
Test for bug where an error stops the aggregator!
NelsonVides Sep 12, 2022
b198cb0
Ensure to keep flushing until a request does not drop
NelsonVides Sep 12, 2022
3d55ec5
Refactored disco_local_features hook to a gen_hook format
pawlooss1 Sep 13, 2022
adc1136
Merge pull request #3757 from esl/async/drops
arcusfelis Sep 13, 2022
8a52cfb
Add mongoose_admin_api
Sep 7, 2022
d754a60
Add Admin API module for contacts (roster)
Sep 7, 2022
5d471f8
Add Admin API modules for stanzas and messages
Sep 7, 2022
6c5ffb7
Add Admin API module for inbox
Sep 7, 2022
2a49bc4
Add Admin API module for MUC
Sep 7, 2022
b5c8307
Add Admin API module for MUC Light
Sep 7, 2022
a04f373
Add Admin API module for sessions
Sep 7, 2022
34c72b3
Add Admin API module for users (accounts)
Sep 7, 2022
a9fdeac
Enable mongoose_admin_api (new) instead of mongoose_api_admin (old)
Sep 7, 2022
bffcc6c
Update REST tests for the new API
Sep 7, 2022
df90b8c
Cover error cases in rest_SUITE
Sep 7, 2022
96592b7
Cover error cases in inbox_SUITE
chrzaszcz Sep 8, 2022
e644cf2
Cover error cases in muc_http_api_SUITE
chrzaszcz Sep 9, 2022
4583d13
Cover error cases in muc_light_http_api_SUITE
chrzaszcz Sep 12, 2022
ecd29ce
Removed disco_local_features/3 from ignore_xref
pawlooss1 Sep 14, 2022
a08a82e
Fix types in subscribeAllToAll roster API
jacekwegr Sep 9, 2022
ebb3411
Merge pull request #3756 from esl/fix-types-in-subscribe-all-to-all-api
chrzaszcz Sep 14, 2022
3de6531
Adding server schema
Aug 31, 2022
26598b6
Adding graphql_server_admin_queries
Sep 5, 2022
9b6aa1a
Adding stop and restart commands
Sep 7, 2022
b48594c
Adding new graphql category, server
Sep 8, 2022
49f4a28
Fixing CR comments
Sep 13, 2022
0c74a8f
Merge pull request #3753 from esl/unified-admin-api
arcusfelis Sep 15, 2022
024fe41
Changed node_cleanup hook handler in ejabberd_router module to gen_ho…
pawlooss1 Sep 15, 2022
a1ff38e
Test mongoose_admin_api instead of the obsolete mongoose_api_admin
Sep 15, 2022
818bbf1
Finish replacing mongoose_api_admin with mongoose_admin_api
Sep 15, 2022
3d7e00b
Remove the obsolete mongoose_api_admin
Sep 15, 2022
898e162
Remove tests for mongoose_commands
Sep 15, 2022
a244b47
Remove mod_*commands from big tests
Sep 15, 2022
cdb4146
Remove mod_*commands
Sep 15, 2022
b5ec345
Remove the obsolete mongoose_commands
Sep 15, 2022
a59ac20
Remove and reorganize REST API helpers
Sep 15, 2022
80fcc62
Clean up unused functions
Sep 15, 2022
27e0486
Test the handling of invalid query string
Sep 15, 2022
72c0612
Merge pull request #3759 from esl/without-mongoose-commands
arcusfelis Sep 15, 2022
3ce9205
Fix cache affiliations key in the accumulator
NelsonVides Sep 15, 2022
0a2f070
Fixing CR issues, deleting .DS_STORE
Sep 15, 2022
9e8aa5d
Merge pull request #3761 from esl/fix_muclight_cache
chrzaszcz Sep 15, 2022
584fb59
Merge pull request #3744 from esl/graphql-server
chrzaszcz Sep 15, 2022
6e954af
Merge branch 'master' into feature/unified-rest-api
Sep 16, 2022
0cd1de7
Merge pull request #3758 from esl/hooks/disco_local_features
chrzaszcz Sep 16, 2022
563764e
Merge pull request #3760 from esl/hooks/ejabberd_router
chrzaszcz Sep 16, 2022
723d58b
Refactored hook handlers in ejabberd_s2s module
pawlooss1 Sep 15, 2022
8ba1dd9
Merge pull request #3762 from esl/hooks/ejabberd_s2s
NelsonVides Sep 16, 2022
82aa71f
Domain admin tests focused on existing domains
jacekwegr Sep 16, 2022
b235735
Simplify having an extra module for a very simple function
NelsonVides Sep 20, 2022
d4264b2
Update (maybe redundant) test suite
NelsonVides Sep 20, 2022
5cd7630
Merge pull request #3764 from esl/kill_redundant_module
chrzaszcz Sep 20, 2022
ee45d84
Merge pull request #3745 from esl/graphql-domain-admin-tests
chrzaszcz Sep 20, 2022
efcb40d
Refactored hook handlers in ejabberd_sm module
pawlooss1 Sep 16, 2022
0ba7a50
Changed params in remove_user hook from luser, lserver to jid
pawlooss1 Sep 20, 2022
2fcd129
Merge pull request #3763 from esl/hooks/ejabberd_sm
NelsonVides Sep 20, 2022
b8ff228
Merge branch 'master' into feature/unified-rest-api
Sep 21, 2022
bf99f2a
Include overlay vars from vars-toml.config
Sep 21, 2022
efee290
Get rid of rel/vars-toml.config.in
Sep 21, 2022
c30fd94
Fail if creds are provided, but not configured
Sep 22, 2022
065dafe
Integrate the domain handler with mongoose_admin_api
Sep 22, 2022
c8be0be
Remove tests for the deleted domain handler
Sep 22, 2022
cecd6e4
Remove the domain handler from the TOML config
Sep 22, 2022
33b5d9c
Adjust big tests for the domain REST API
Sep 22, 2022
9082e6e
Improve test coverage
Sep 22, 2022
222c6e5
Merge pull request #3768 from esl/unified-rest-api-domain
JanuszJakubiec Sep 22, 2022
6c3819f
Merge pull request #3766 from esl/fix-overlay-vars
arcusfelis Sep 22, 2022
df6df9c
Merge branch 'master' into feature/unified-rest-api
Sep 22, 2022
085b29b
Add metrics API handler with the logic from mongoose_api_metrics
Sep 23, 2022
e36eaac
Add the metric handlers to mongoose_admin_api
Sep 23, 2022
84ea45e
Disable the old mongoose_api in the config file
Sep 23, 2022
856b66b
Update metrics tests for the unified API
Sep 23, 2022
0879c5e
Remove the obsolete mongoose_api
Sep 23, 2022
2f17af3
Remove remaining references to the obsolete API
Sep 23, 2022
6e56f0d
Remove tests for non-existing old user API
Sep 23, 2022
4440aab
Add missing error tests and reorganize them
Sep 23, 2022
2679933
Fix an invalid metric name
Sep 23, 2022
fed9dcb
Documented missing GraphQL types
jacekwegr Sep 23, 2022
3eea77f
Prepare domains backend to allow retries
NelsonVides Sep 23, 2022
b3c25aa
Enable to notify of modules failing to remove their data
NelsonVides Sep 23, 2022
0b4cd4e
Merge pull request #3771 from esl/unified-rest-api-metrics
JanuszJakubiec Sep 26, 2022
471d300
Define Status in GraphQL schema
NelsonVides Sep 26, 2022
aec0106
Define a wrapper to catch error on deletion
NelsonVides Sep 23, 2022
abc5499
Fail if mam fails
NelsonVides Sep 23, 2022
9458f48
Fail if inbox fails
NelsonVides Sep 24, 2022
7ee654e
Fail if auth fails
NelsonVides Sep 24, 2022
2710bd4
Fail if muclight fails
NelsonVides Sep 24, 2022
f04024f
Remove whitespace
NelsonVides Sep 26, 2022
f875416
Test that the domain removal is stopped and can continue on retry
NelsonVides Sep 26, 2022
e79f084
Merge pull request #3774 from esl/remove_domain/retries
chrzaszcz Sep 27, 2022
d2b76db
Small refactor cleaup
NelsonVides Sep 27, 2022
64afba5
Add configuration flag for mam domain_delete operations
NelsonVides Sep 27, 2022
e9eca5b
Make Admin API handlers configurable
Sep 27, 2022
225a579
Simplify Client API handler config
Sep 27, 2022
5ed20d8
Relax the spec - there is no need for returning all opts
Sep 27, 2022
4ecb229
Update tests with the new API handler config
Sep 27, 2022
fecb1bd
Merge pull request #3776 from esl/unified-rest-api-handlers
arcusfelis Sep 27, 2022
9501f10
Implement a configurable incremental delete for mam
NelsonVides Sep 27, 2022
4f88463
Ensure incremental is tested
NelsonVides Sep 27, 2022
faecc8d
Merge pull request #3775 from esl/remove_domain/catch_hook_errors
chrzaszcz Sep 28, 2022
23618cb
Fix query to make it MySQL compatible
NelsonVides Sep 28, 2022
2c13138
Merge branch 'master' into feature/unified-rest-api
chrzaszcz Sep 28, 2022
03043cb
Update MySQL version
chrzaszcz Sep 28, 2022
6ddc8b4
Merge pull request #3779 from esl/update-mysql-version
NelsonVides Sep 28, 2022
975bb21
Merge pull request #3777 from esl/remove_domain/incremental_db_deletes
chrzaszcz Sep 28, 2022
aa9835d
Refactored hook handlers in mod_event_pusher_hook_translator module
pawlooss1 Sep 22, 2022
ccc1e3d
Removed From, To, Packet from params in user_send_packet and rest_use…
pawlooss1 Sep 28, 2022
054ecf2
Review changes
pawlooss1 Sep 29, 2022
572b0d3
Refactored hook handler in mod_event_pusher_push module
pawlooss1 Sep 30, 2022
b88ec04
Unified REST API docs (#3780)
chrzaszcz Oct 3, 2022
62738e1
Merge branch 'master' into feature/unified-rest-api
chrzaszcz Oct 3, 2022
0a7164f
Merge pull request #3741 from esl/feature/unified-rest-api
JanuszJakubiec Oct 4, 2022
e38a0d4
Merge pull request #3782 from esl/hooks/mod_event_pusher_push
NelsonVides Oct 4, 2022
b17712a
Merge pull request #3769 from esl/hooks/mod_event_pusher_hook_translator
DenysGonchar Oct 4, 2022
d7a4438
Refactored hook handler in mod_global_distrib module
pawlooss1 Oct 3, 2022
49f9b07
Merge pull request #3784 from esl/hooks/mod_global_distrib
NelsonVides Oct 4, 2022
54a1d18
Refactored hook handlers in mod_global_distrib_bounce module
pawlooss1 Oct 4, 2022
86bd669
More specific CLI help
jacekwegr Oct 3, 2022
0a67535
Merge pull request #3789 from esl/hooks/mod_global_distrib_bounce
NelsonVides Oct 4, 2022
6748ca4
Merge pull request #3773 from esl/document-graphql-types
chrzaszcz Oct 4, 2022
194afcc
Refactored hook handler in mod_global_distrib_disco module
pawlooss1 Oct 5, 2022
571e333
Adding use annotation to mod_http_upload and deleting if
Aug 19, 2022
cb69789
Adding tests to graphql_inbox
Aug 24, 2022
fb5454a
Adding @use annotation tests in graphql_last_SUITE
Sep 12, 2022
d1d98a7
Adding annotations and tests to muc_light
Sep 20, 2022
2268b09
Fixing graphql_muc_light_SUITE tests
Sep 22, 2022
c59707b
Fixing mongooseimctl_SUITE tests
Sep 22, 2022
769b0de
Adding @use annotations and tests in graphql_muc
Sep 26, 2022
41a5ffc
Adding @use annotation in graphql_offline
Sep 26, 2022
244f6f7
Adding @use directive and new tests in mod_private
Sep 27, 2022
78f130e
Adding @use directive and tests in mod_auth_token
Sep 28, 2022
953fe99
Adding @use directive to vcard schemas and tests to graphlq_vcard
Sep 30, 2022
1aa0d8d
Adding comments to schemas
Sep 30, 2022
655ac91
Fixing mod_last tests
Sep 30, 2022
650da9f
Merge pull request #3792 from esl/hooks/mod_global_distrib_disco
NelsonVides Oct 5, 2022
50a99aa
Make it possible to use more defaults in mongooseim.toml
chrzaszcz Oct 5, 2022
d609dde
Reorganize overlay vars to avoid overriding
chrzaszcz Oct 5, 2022
64ade6c
Reference the new vars for prod
chrzaszcz Oct 5, 2022
9530b2a
Update node name in big tests
chrzaszcz Oct 5, 2022
180c86d
Deleting unnecessary code from init_per_suite
Oct 5, 2022
ab65045
Merge pull request #3794 from esl/vars-without-overriding
NelsonVides Oct 7, 2022
5b3e266
Merge pull request #3767 from esl/graphql-use-annotation
chrzaszcz Oct 7, 2022
01bc480
Merge branch 'master' into c2s/merge_master
NelsonVides Oct 7, 2022
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
6 changes: 1 addition & 5 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ clean:
-rm -rf asngen
-rm configure.out
-rm rel/configure.vars.config
-rm rel/vars-toml.config

# REBAR_CT_EXTRA_ARGS comes from a test runner
ct:
Expand All @@ -27,7 +26,7 @@ ct:
eunit:
@$(RUN) $(REBAR) eunit

rel: certs configure.out rel/vars-toml.config
rel: certs configure.out rel/configure.vars.config
. ./configure.out && $(REBAR) as prod release

shell: certs etc/mongooseim.cfg
Expand All @@ -40,9 +39,6 @@ rock:
elif [ "$(BRANCH)" ]; then tools/rock_changed.sh $(BRANCH); \
else tools/rock_changed.sh; fi

rel/vars-toml.config: rel/vars-toml.config.in rel/configure.vars.config
cat $^ > $@

## Don't allow these files to go out of sync!
configure.out rel/configure.vars.config:
./tools/configure with-all without-jingle-sip
Expand Down
2 changes: 1 addition & 1 deletion big_tests/default.spec
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@
{suites, "tests", graphql_mnesia_SUITE}.
{suites, "tests", graphql_vcard_SUITE}.
{suites, "tests", graphql_http_upload_SUITE}.
{suites, "tests", graphql_server_SUITE}.
{suites, "tests", graphql_metric_SUITE}.
{suites, "tests", inbox_SUITE}.
{suites, "tests", inbox_extensions_SUITE}.
Expand Down Expand Up @@ -103,7 +104,6 @@
% {suites, "tests", sic_SUITE}.
{suites, "tests", smart_markers_SUITE}.
% {suites, "tests", sm_SUITE}.
{suites, "tests", users_api_SUITE}.
{suites, "tests", vcard_SUITE}.
{suites, "tests", vcard_simple_SUITE}.
{suites, "tests", websockets_SUITE}.
Expand Down
2 changes: 1 addition & 1 deletion big_tests/dynamic_domains.config
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
{hidden_service_port, 8189},
{gd_endpoint_port, 5555},
{http_notifications_port, 8000}]},
{mim2, [{node, ejabberd2@localhost},
{mim2, [{node, mongooseim2@localhost},
{domain, <<"domain.example.com">>},
{host_type, <<"test type">>},
{dynamic_domains, [{<<"test type">>, [<<"domain.example.com">>]}]},
Expand Down
2 changes: 1 addition & 1 deletion big_tests/dynamic_domains.spec
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@
{suites, "tests", graphql_token_SUITE}.
{suites, "tests", graphql_mnesia_SUITE}.
{suites, "tests", graphql_http_upload_SUITE}.
{suites, "tests", graphql_server_SUITE}.
{suites, "tests", graphql_metric_SUITE}.

{suites, "tests", inbox_SUITE}.
Expand Down Expand Up @@ -150,7 +151,6 @@

{suites, "tests", smart_markers_SUITE}.
% {suites, "tests", sm_SUITE}.
{suites, "tests", users_api_SUITE}.
{suites, "tests", vcard_SUITE}.
{suites, "tests", vcard_simple_SUITE}.
{suites, "tests", websockets_SUITE}.
Expand Down
25 changes: 16 additions & 9 deletions big_tests/run_common_test.erl
Original file line number Diff line number Diff line change
Expand Up @@ -278,22 +278,20 @@ is_test_host_enabled(HostName) ->
enable_preset_on_node(Node, PresetVars, HostVarsFilePrefix) ->
{ok, Cwd} = call(Node, file, get_cwd, []),
TemplatePath = filename:join([repo_dir(), "rel", "files", "mongooseim.toml"]),
DefaultVarsPath = filename:join([repo_dir(), "rel", "vars-toml.config"]),
NodeVarsPath = filename:join([repo_dir(), "rel", HostVarsFilePrefix ++ ".vars-toml.config"]),

{ok, Template} = handle_file_error(TemplatePath, file:read_file(TemplatePath)),
{ok, DefaultVars} = handle_file_error(DefaultVarsPath, file:consult(DefaultVarsPath)),
{ok, NodeVars} = handle_file_error(NodeVarsPath, file:consult(NodeVarsPath)),
NodeVars = read_vars(NodeVarsPath),

TemplatedConfig = template_config(Template, [DefaultVars, NodeVars, PresetVars]),
TemplatedConfig = template_config(Template, NodeVars ++ PresetVars),
CfgPath = filename:join([Cwd, "etc", "mongooseim.toml"]),
ok = call(Node, file, write_file, [CfgPath, TemplatedConfig]),
call(Node, application, stop, [mongooseim]),
call(Node, application, start, [mongooseim]),
ok.

template_config(Template, Vars) ->
MergedVars = ensure_binary_strings(merge_vars(Vars)),
template_config(Template, RawVars) ->
MergedVars = ensure_binary_strings(maps:from_list(RawVars)),
%% Render twice to replace variables in variables
Tmp = bbmustache:render(Template, MergedVars, [{key_type, atom}]),
bbmustache:render(Tmp, MergedVars, [{key_type, atom}]).
Expand All @@ -305,11 +303,20 @@ merge_vars([Vars1, Vars2|Rest]) ->
merge_vars([Vars|Rest]);
merge_vars([Vars]) -> Vars.

read_vars(File) ->
{ok, Terms} = handle_file_error(File, file:consult(File)),
lists:flatmap(fun({Key, Val}) ->
[{Key, Val}];
(IncludedFile) when is_list(IncludedFile) ->
Path = filename:join(filename:dirname(File), IncludedFile),
read_vars(Path)
end, Terms).

%% bbmustache tries to iterate over lists, so we need to make them binaries
ensure_binary_strings(Vars) ->
lists:map(fun({dbs, V}) -> {dbs, V};
({K, V}) when is_list(V) -> {K, list_to_binary(V)};
({K, V}) -> {K, V}
maps:map(fun(dbs, V) -> V;
(_K, V) when is_list(V) -> list_to_binary(V);
(_K, V) -> V
end, Vars).

call(Node, M, F, A) ->
Expand Down
6 changes: 2 additions & 4 deletions big_tests/test.config
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
%% See s2s_SUITE for example on using `hosts` to RPC into nodes (uses CT "require").
%% the Erlang node name of tested ejabberd/MongooseIM
{ejabberd_node, 'mongooseim@localhost'}.
{ejabberd2_node, 'ejabberd2@localhost'}.
{ejabberd2_node, 'mongooseim2@localhost'}.
{ejabberd_cookie, ejabberd}.
{ejabberd_string_format, bin}.

Expand All @@ -30,7 +30,6 @@
{muc_light_service_pattern, <<"muclight.@HOST@">>},
{s2s_port, 5269},
{incoming_s2s_port, 5269},
{metrics_rest_port, 5288},
{c2s_port, 5222},
{c2s_tls_port, 5223},
{cowboy_port, 5280},
Expand All @@ -41,13 +40,12 @@
{hidden_service_port, 8189},
{gd_endpoint_port, 5555},
{http_notifications_port, 8000}]},
{mim2, [{node, ejabberd2@localhost},
{mim2, [{node, mongooseim2@localhost},
{domain, <<"localhost">>},
{host_type, <<"localhost">>},
{vars, "mim2"},
{cluster, mim},
{c2s_tls_port, 5233},
{metrics_rest_port, 5289},
{gd_endpoint_port, 6666},
{service_port, 8899}]},
{mim3, [{node, mongooseim3@localhost},
Expand Down
6 changes: 3 additions & 3 deletions big_tests/tests/cluster_commands_SUITE.erl
Original file line number Diff line number Diff line change
Expand Up @@ -332,7 +332,7 @@ leave_using_rpc(Config) ->
add_node_to_cluster(Node2, Config),
%% when
Result = distributed_helper:rpc(Node1#{timeout => timer:seconds(30)},
ejabberd_admin, leave_cluster, []),
mongoose_server_api, leave_cluster, []),
ct:pal("leave_using_rpc result ~p~n", [Result]),
%% then
distributed_helper:verify_result(Node2, remove),
Expand Down Expand Up @@ -395,7 +395,7 @@ remove_dead_from_cluster(Config) ->
ok = rpc(Node2#{timeout => Timeout}, mongoose_cluster, join, [Node1Nodename]),
ok = rpc(Node3#{timeout => Timeout}, mongoose_cluster, join, [Node1Nodename]),
%% when
distributed_helper:stop_node(Node3, Config),
distributed_helper:stop_node(Node3Nodename, Config),
{_, OpCode1} = mongooseimctl_interactive(Node1, "remove_from_cluster",
[atom_to_list(Node3Nodename)], "yes\n", Config),
%% then
Expand All @@ -405,7 +405,7 @@ remove_dead_from_cluster(Config) ->
have_node_in_mnesia(Node1, Node3, false),
have_node_in_mnesia(Node2, Node3, false),
% after node awakening nodes are clustered again
distributed_helper:start_node(Node3, Config),
distributed_helper:start_node(Node3Nodename, Config),
have_node_in_mnesia(Node1, Node3, true),
have_node_in_mnesia(Node2, Node3, true).

Expand Down
2 changes: 0 additions & 2 deletions big_tests/tests/distributed_helper.erl
Original file line number Diff line number Diff line change
Expand Up @@ -168,8 +168,6 @@ get_or_fail(Key) ->

start_node(Node, Config) ->
{_, 0} = mongooseimctl_helper:mongooseimctl(Node, "start", [], Config),
{_, 0} = mongooseimctl_helper:mongooseimctl(Node, "started", [], Config),
%% TODO Looks like "started" run by mongooseimctl fun is not really synchronous
timer:sleep(3000).

stop_node(Node, Config) ->
Expand Down
18 changes: 1 addition & 17 deletions big_tests/tests/domain_helper.erl
Original file line number Diff line number Diff line change
@@ -1,22 +1,6 @@
-module(domain_helper).

-export([insert_configured_domains/0,
delete_configured_domains/0,
insert_domain/3,
delete_domain/2,
set_domain_password/3,
delete_domain_password/2,
make_metrics_prefix/1,
host_types/0,
host_types/1,
host_type/0,
host_type/1,
domain_to_host_type/2,
domain/0,
secondary_domain/0,
domain/1,
secondary_host_type/0,
secondary_host_type/1]).
-compile([export_all, nowarn_export_all]).

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

Expand Down
77 changes: 64 additions & 13 deletions big_tests/tests/domain_removal_SUITE.erl
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ all() ->
{group, auth_removal},
{group, cache_removal},
{group, mam_removal},
{group, mam_removal_incremental},
{group, inbox_removal},
{group, muc_light_removal},
{group, muc_removal},
Expand All @@ -25,7 +26,8 @@ all() ->
{group, offline_removal},
{group, markers_removal},
{group, vcard_removal},
{group, last_removal}
{group, last_removal},
{group, removal_failures}
].

groups() ->
Expand All @@ -34,6 +36,8 @@ groups() ->
{cache_removal, [], [cache_removal]},
{mam_removal, [], [mam_pm_removal,
mam_muc_removal]},
{mam_removal_incremental, [], [mam_pm_removal,
mam_muc_removal]},
{inbox_removal, [], [inbox_removal]},
{muc_light_removal, [], [muc_light_removal,
muc_light_blocking_removal]},
Expand All @@ -43,7 +47,8 @@ groups() ->
{offline_removal, [], [offline_removal]},
{markers_removal, [], [markers_removal]},
{vcard_removal, [], [vcard_removal]},
{last_removal, [], [last_removal]}
{last_removal, [], [last_removal]},
{removal_failures, [], [removal_stops_if_handler_fails]}
].

%%%===================================================================
Expand Down Expand Up @@ -80,6 +85,8 @@ end_per_group(_Groupname, Config) ->
end,
ok.

group_to_modules(removal_failures) ->
group_to_modules(mam_removal);
group_to_modules(auth_removal) ->
[];
group_to_modules(cache_removal) ->
Expand All @@ -89,6 +96,10 @@ group_to_modules(mam_removal) ->
MucHost = subhost_pattern(muc_light_helper:muc_host_pattern()),
[{mod_mam, mam_helper:config_opts(#{pm => #{}, muc => #{host => MucHost}})},
{mod_muc_light, mod_config(mod_muc_light, #{backend => rdbms})}];
group_to_modules(mam_removal_incremental) ->
MucHost = subhost_pattern(muc_light_helper:muc_host_pattern()),
[{mod_mam, mam_helper:config_opts(#{delete_domain_limit => 1, 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})}];
group_to_modules(muc_removal) ->
Expand Down Expand Up @@ -166,10 +177,11 @@ cache_removal(Config) ->

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),
N = 3,
[ escalus:send(Alice, escalus_stanza:chat_to(Bob, <<"OH, HAI!">>)) || _ <- lists:seq(1, N) ],
escalus:wait_for_stanzas(Bob, N),
mam_helper:wait_for_archive_size(Alice, N),
mam_helper:wait_for_archive_size(Bob, N),
run_remove_domain(),
mam_helper:wait_for_archive_size(Alice, 0),
mam_helper:wait_for_archive_size(Bob, 0)
Expand All @@ -178,14 +190,15 @@ mam_pm_removal(Config) ->

mam_muc_removal(Config0) ->
F = fun(Config, Alice) ->
N = 3,
Room = muc_helper:fresh_room_name(),
MucHost = muc_light_helper:muc_host(),
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),
mam_helper:wait_for_room_archive_size(MucHost, Room, 1),
[ escalus:send(Alice, escalus_stanza:groupchat_to(RoomAddr, <<"text">>)) || _ <- lists:seq(1, N) ],
escalus:wait_for_stanzas(Alice, N),
mam_helper:wait_for_room_archive_size(MucHost, Room, N),
run_remove_domain(),
mam_helper:wait_for_room_archive_size(MucHost, Room, 0)
end,
Expand Down Expand Up @@ -394,25 +407,63 @@ last_removal(Config0) ->

PresUn = escalus_client:wait_for_stanza(Alice),
escalus:assert(is_presence_with_type, [<<"unavailable">>], PresUn),

%% Alice asks for Bob's last availability
BobShortJID = escalus_client:short_jid(Bob),
GetLast = escalus_stanza:last_activity(BobShortJID),
Stanza = escalus_client:send_iq_and_wait_for_result(Alice, GetLast),

%% Alice receives Bob's status and last online time > 0
escalus:assert(is_last_result, Stanza),
true = (1 =< get_last_activity(Stanza)),
<<"I am a banana!">> = get_last_status(Stanza),
run_remove_domain(),

run_remove_domain(),
escalus_client:send(Alice, GetLast),
Error = escalus_client:wait_for_stanza(Alice),
escalus:assert(is_error, [<<"auth">>, <<"forbidden">>], Error)
end,
escalus:fresh_story_with_config(Config0, [{alice, 1}, {bob, 1}], F).

removal_stops_if_handler_fails(Config0) ->
mongoose_helper:inject_module(?MODULE),
F = fun(Config, Alice) ->
start_domain_removal_hook(),
Room = muc_helper:fresh_room_name(),
MucHost = muc_light_helper:muc_host(),
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),
mam_helper:wait_for_room_archive_size(MucHost, Room, 1),
run_remove_domain(),
mam_helper:wait_for_room_archive_size(MucHost, Room, 1),
stop_domain_removal_hook(),
run_remove_domain(),
mam_helper:wait_for_room_archive_size(MucHost, Room, 0)
end,
escalus_fresh:story_with_config(Config0, [{alice, 1}], F).

%% Helpers
start_domain_removal_hook() ->
rpc(mim(), ?MODULE, rpc_start_domain_removal_hook, [host_type()]).

stop_domain_removal_hook() ->
rpc(mim(), ?MODULE, rpc_stop_domain_removal_hook, [host_type()]).

rpc_start_domain_removal_hook(HostType) ->
gen_hook:add_handler(remove_domain, HostType,
fun ?MODULE:domain_removal_hook_fn/3,
#{}, 30). %% Priority is so that it comes before muclight and mam

rpc_stop_domain_removal_hook(HostType) ->
gen_hook:delete_handler(remove_domain, HostType,
fun ?MODULE:domain_removal_hook_fn/3,
#{}, 30).

domain_removal_hook_fn(Acc, _Params, _Extra) ->
F = fun() -> throw(first_time_needs_to_fail) end,
mongoose_domain_api:remove_domain_wrapper(Acc, F, ?MODULE).

connect_and_disconnect(Spec) ->
{ok, Client, _} = escalus_connection:start(Spec),
Expand Down
Loading