From 4d9e217a047b180d79ad9d8385ee2b398184803b Mon Sep 17 00:00:00 2001 From: Nelson Vides Date: Wed, 28 Dec 2022 16:33:14 +0100 Subject: [PATCH 1/8] Ensure mod_presence is enabled by default for more host types --- big_tests/default.spec | 4 +--- big_tests/dynamic_domains.spec | 4 +--- big_tests/tests/mim_c2s_SUITE.erl | 1 + rel/mim1.vars-toml.config | 2 +- rel/mim2.vars-toml.config | 4 ++-- 5 files changed, 6 insertions(+), 9 deletions(-) diff --git a/big_tests/default.spec b/big_tests/default.spec index 913ce2699d8..35908f1adab 100644 --- a/big_tests/default.spec +++ b/big_tests/default.spec @@ -110,11 +110,9 @@ {suites, "tests", websockets_SUITE}. {suites, "tests", xep_0352_csi_SUITE}. {suites, "tests", service_domain_db_SUITE}. -{skip_cases, "tests", service_domain_db_SUITE, - [rest_delete_domain_cleans_data_from_mam], "this test tries to use presences"}. {suites, "tests", domain_isolation_SUITE}. {suites, "tests", domain_removal_SUITE}. -% {suites, "tests", dynamic_domains_SUITE}. +{suites, "tests", dynamic_domains_SUITE}. {suites, "tests", local_iq_SUITE}. % {suites, "tests", tcp_listener_SUITE}. diff --git a/big_tests/dynamic_domains.spec b/big_tests/dynamic_domains.spec index 6885936895e..e6f5e4e140e 100644 --- a/big_tests/dynamic_domains.spec +++ b/big_tests/dynamic_domains.spec @@ -35,7 +35,7 @@ {suites, "tests", domain_isolation_SUITE}. -% {suites, "tests", dynamic_domains_SUITE}. +{suites, "tests", dynamic_domains_SUITE}. {suites, "tests", extdisco_SUITE}. @@ -140,8 +140,6 @@ {suites, "tests", sasl_external_SUITE}. {suites, "tests", service_domain_db_SUITE}. -{skip_cases, "tests", service_domain_db_SUITE, - [rest_delete_domain_cleans_data_from_mam], "this test tries to use presences"}. {suites, "tests", service_mongoose_system_metrics_SUITE}. {skip_cases, "tests", service_mongoose_system_metrics_SUITE, diff --git a/big_tests/tests/mim_c2s_SUITE.erl b/big_tests/tests/mim_c2s_SUITE.erl index 59a0b1e7f91..a178b88e6b9 100644 --- a/big_tests/tests/mim_c2s_SUITE.erl +++ b/big_tests/tests/mim_c2s_SUITE.erl @@ -35,6 +35,7 @@ init_per_suite(Config) -> {start_ready_clients, fun ?MODULE:escalus_start/2}], Config1 = save_c2s_listener(Config), Config2 = dynamic_modules:save_modules(HostType, Config1), + dynamic_modules:ensure_stopped(HostType, [mod_presence]), Config3 = escalus_users:update_userspec(Config2, alice, connection_steps, Steps), Config4 = escalus_users:update_userspec(Config3, bob, connection_steps, Steps), configure_c2s_listener(Config4, #{backwards_compatible_session => false, max_stanza_size => 1024}), diff --git a/rel/mim1.vars-toml.config b/rel/mim1.vars-toml.config index 2997302994b..9ba18323bda 100644 --- a/rel/mim1.vars-toml.config +++ b/rel/mim1.vars-toml.config @@ -40,7 +40,7 @@ [[host_config]] host_type = \"dummy auth\" - modules = { } + [host_config.modules.mod_presence] [host_config.auth.dummy] base_time = 1 diff --git a/rel/mim2.vars-toml.config b/rel/mim2.vars-toml.config index 4815311afa6..2581a209a45 100644 --- a/rel/mim2.vars-toml.config +++ b/rel/mim2.vars-toml.config @@ -53,8 +53,8 @@ {host_config, "[[host_config]] host_type = \"dummy auth\" - modules = { } - auth.dummy = { }"}. + [host_config.modules.mod_presence] + [host_config.auth.dummy]"}. %% Include common vars shared by all profiles "./vars-toml.config". From d47b073a79ad854e96a1c946f3b770d03311fd65 Mon Sep 17 00:00:00 2001 From: Nelson Vides Date: Tue, 3 Jan 2023 15:13:03 +0100 Subject: [PATCH 2/8] Fix removing roster rpc from presence_SUITE --- big_tests/tests/presence_SUITE.erl | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/big_tests/tests/presence_SUITE.erl b/big_tests/tests/presence_SUITE.erl index e9b196c8bdc..30cd92cb5ed 100644 --- a/big_tests/tests/presence_SUITE.erl +++ b/big_tests/tests/presence_SUITE.erl @@ -729,7 +729,9 @@ remove_roster(Config, UserSpec) -> case lists:member(mod_roster, Mods) of true -> Acc = mongoose_helper:new_mongoose_acc(Server), - rpc(mim(), mod_roster, remove_user, [Acc, Username, Server]); + Extra = #{host_type => host_type()}, + Params = #{jid => jid:make_bare(Username, Server)}, + rpc(mim(), mod_roster, remove_user, [Acc, Params, Extra]); false -> case lists:member(mod_roster_rdbms, Mods) of true -> From 0508509cf88237aa105f71d1ee85826ab9845fda Mon Sep 17 00:00:00 2001 From: Nelson Vides Date: Wed, 28 Dec 2022 16:31:33 +0100 Subject: [PATCH 3/8] Enable anonymous_SUITE --- big_tests/default.spec | 2 +- big_tests/dynamic_domains.spec | 2 +- rel/mim1.vars-toml.config | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/big_tests/default.spec b/big_tests/default.spec index 35908f1adab..82482be24b3 100644 --- a/big_tests/default.spec +++ b/big_tests/default.spec @@ -18,7 +18,7 @@ {suites, "tests", accounts_SUITE}. {suites, "tests", adhoc_SUITE}. {suites, "tests", amp_big_SUITE}. -% {suites, "tests", anonymous_SUITE}. +{suites, "tests", anonymous_SUITE}. {suites, "tests", auth_methods_for_c2s_SUITE}. {suites, "tests", bosh_SUITE}. {suites, "tests", carboncopy_SUITE}. diff --git a/big_tests/dynamic_domains.spec b/big_tests/dynamic_domains.spec index e6f5e4e140e..544bfe2e612 100644 --- a/big_tests/dynamic_domains.spec +++ b/big_tests/dynamic_domains.spec @@ -19,7 +19,7 @@ {suites, "tests", amp_big_SUITE}. -% {suites, "tests", anonymous_SUITE}. +{suites, "tests", anonymous_SUITE}. {suites, "tests", auth_methods_for_c2s_SUITE}. diff --git a/rel/mim1.vars-toml.config b/rel/mim1.vars-toml.config index 9ba18323bda..5fcea75ba4c 100644 --- a/rel/mim1.vars-toml.config +++ b/rel/mim1.vars-toml.config @@ -32,7 +32,7 @@ [[host_config]] host_type = \"anonymous\" - modules = { } + [host_config.modules.mod_presence] [host_config.auth.anonymous] allow_multiple_connections = true From 3529482f6a9b59f24b9be68ff51762168cb2f0d3 Mon Sep 17 00:00:00 2001 From: Nelson Vides Date: Wed, 28 Dec 2022 16:31:54 +0100 Subject: [PATCH 4/8] Enable sic_SUITE --- big_tests/default.spec | 2 +- big_tests/dynamic_domains.spec | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/big_tests/default.spec b/big_tests/default.spec index 82482be24b3..73d31e86d46 100644 --- a/big_tests/default.spec +++ b/big_tests/default.spec @@ -102,7 +102,7 @@ {suites, "tests", sasl_external_SUITE}. {suites, "tests", service_mongoose_system_metrics_SUITE}. % {suites, "tests", shared_roster_SUITE}. -% {suites, "tests", sic_SUITE}. +{suites, "tests", sic_SUITE}. {suites, "tests", smart_markers_SUITE}. {suites, "tests", sm_SUITE}. {suites, "tests", vcard_SUITE}. diff --git a/big_tests/dynamic_domains.spec b/big_tests/dynamic_domains.spec index 544bfe2e612..1600f19fbb7 100644 --- a/big_tests/dynamic_domains.spec +++ b/big_tests/dynamic_domains.spec @@ -146,7 +146,7 @@ [xmpp_components_are_reported], "at the moment external components doesn't support dynamic domains"}. -% {suites, "tests", sic_SUITE}. +{suites, "tests", sic_SUITE}. {suites, "tests", smart_markers_SUITE}. {suites, "tests", sm_SUITE}. From 9daa2538510bcf214ef73d6851c86734213b8481 Mon Sep 17 00:00:00 2001 From: Nelson Vides Date: Wed, 4 Jan 2023 18:04:25 +0100 Subject: [PATCH 5/8] Enable shared_roster_SUITE --- big_tests/default.spec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/big_tests/default.spec b/big_tests/default.spec index 73d31e86d46..fc286cb1bcf 100644 --- a/big_tests/default.spec +++ b/big_tests/default.spec @@ -101,7 +101,7 @@ {suites, "tests", sasl_SUITE}. {suites, "tests", sasl_external_SUITE}. {suites, "tests", service_mongoose_system_metrics_SUITE}. -% {suites, "tests", shared_roster_SUITE}. +{suites, "tests", shared_roster_SUITE}. {suites, "tests", sic_SUITE}. {suites, "tests", smart_markers_SUITE}. {suites, "tests", sm_SUITE}. From e1cc877223ebfab2f2a622572d44cd445b586c7f Mon Sep 17 00:00:00 2001 From: Nelson Vides Date: Wed, 28 Dec 2022 11:58:40 +0100 Subject: [PATCH 6/8] Enable global_distrib and fix stream_mgmt timeouts Note that for `gen_statem`, timeouts of the type `{timeout, Time, Msg}` are considered event timeouts, and are canceled upon any event delivered before them, so they can get lost for example upon the process receiving any other routed message. So we need to name them, `{{timeout, ?MODULE}, Time, Msg}`. --- big_tests/default.spec | 2 +- big_tests/tests/mod_global_distrib_SUITE.erl | 1 - src/global_distrib/mod_global_distrib_receiver.erl | 4 +++- src/stream_management/mod_stream_management.erl | 8 ++++---- 4 files changed, 8 insertions(+), 7 deletions(-) diff --git a/big_tests/default.spec b/big_tests/default.spec index fc286cb1bcf..1e72e4f24a4 100644 --- a/big_tests/default.spec +++ b/big_tests/default.spec @@ -66,7 +66,7 @@ {suites, "tests", mod_event_pusher_http_SUITE}. {suites, "tests", mod_event_pusher_rabbit_SUITE}. {suites, "tests", mod_event_pusher_sns_SUITE}. -% {suites, "tests", mod_global_distrib_SUITE}. +{suites, "tests", mod_global_distrib_SUITE}. {suites, "tests", mod_http_upload_SUITE}. {suites, "tests", mod_ping_SUITE}. {suites, "tests", mod_time_SUITE}. diff --git a/big_tests/tests/mod_global_distrib_SUITE.erl b/big_tests/tests/mod_global_distrib_SUITE.erl index f86dd923dc9..c492ac67ea9 100644 --- a/big_tests/tests/mod_global_distrib_SUITE.erl +++ b/big_tests/tests/mod_global_distrib_SUITE.erl @@ -749,7 +749,6 @@ do_test_pm_with_ungraceful_reconnection_to_different_server(Config0, BeforeResum %% Trigger rerouting ok = rpc(asia_node, sys, resume, [C2sPid]), - C2sPid ! resume_timeout, %% Let C2sPid to process the message and reroute (and die finally, poor little thing) mongoose_helper:wait_for_pid_to_die(C2sPid), diff --git a/src/global_distrib/mod_global_distrib_receiver.erl b/src/global_distrib/mod_global_distrib_receiver.erl index a56d62ed5c6..fad44382587 100644 --- a/src/global_distrib/mod_global_distrib_receiver.erl +++ b/src/global_distrib/mod_global_distrib_receiver.erl @@ -204,7 +204,9 @@ start_listeners() -> RetriesLeft :: non_neg_integer()) -> any(). start_listener({Addr, Port} = Ref, RetriesLeft) -> ?LOG_INFO(#{what => gd_start_listener, address => Addr, port => Port}), - case ranch:start_listener(Ref, ranch_tcp, #{num_acceptors => 10, ip => Addr, port => Port}, ?MODULE, []) of + SocketOpts = [{ip, Addr}, {port, Port}], + RanchOpts = #{max_connections => infinity, num_acceptors => 10, socket_opts => SocketOpts}, + case ranch:start_listener(Ref, ranch_tcp, RanchOpts, ?MODULE, []) of {ok, _} -> ok; {error, eaddrinuse} when RetriesLeft > 0 -> ?LOG_ERROR(#{what => gd_start_listener_failed, address => Addr, port => Port, diff --git a/src/stream_management/mod_stream_management.erl b/src/stream_management/mod_stream_management.erl index adfe7e3d4d8..4ea1cda4678 100644 --- a/src/stream_management/mod_stream_management.erl +++ b/src/stream_management/mod_stream_management.erl @@ -226,7 +226,7 @@ handle_buffer_and_ack(Acc, C2SState, Jid, #sm_state{buffer = Buffer, buffer_max NewBufferSize = BufferSize + 1, MaybeActions = case is_buffer_full(NewBufferSize, BufferMax) of true -> - {timeout, ?CONSTRAINT_CHECK_TIMEOUT, check_buffer_full}; + {{timeout, ?MODULE}, ?CONSTRAINT_CHECK_TIMEOUT, check_buffer_full}; false -> [] end, @@ -290,7 +290,7 @@ foreign_event(Acc, #{c2s_data := StateData, error -> {stop, mongoose_c2s_acc:to_acc(Acc, hard_stop, bad_stream_management_request)} end; -foreign_event(Acc, #{c2s_data := StateData, event_type := timeout, event_content := check_buffer_full}, _Extra) -> +foreign_event(Acc, #{c2s_data := StateData, event_type := {timeout, ?MODULE}, event_content := check_buffer_full}, _Extra) -> #sm_state{buffer_size = BufferSize, buffer_max = BufferMax} = get_mod_state(StateData), case is_buffer_full(BufferSize, BufferMax) of true -> @@ -316,7 +316,7 @@ handle_user_stopping(Acc, #{c2s_data := StateData}, #{host_type := HostType}) -> SmState -> Timeout = get_resume_timeout(HostType), NewSmState = notify_unacknowledged_messages(Acc, StateData, SmState), - Actions = [{push_callback_module, ?MODULE}, {timeout, Timeout, resume_timeout}, hibernate], + Actions = [{push_callback_module, ?MODULE}, {{timeout, ?MODULE}, Timeout, resume_timeout}, hibernate], ToAcc = [{c2s_state, ?EXT_C2S_STATE(resume_session)}, {actions, Actions}, {state_mod, {?MODULE, NewSmState}}], {stop, mongoose_c2s_acc:to_acc_many(Acc, ToAcc)} end. @@ -767,7 +767,7 @@ handle_event({call, From}, {stream_mgmt_resume, H}, ?EXT_C2S_STATE(resume_sessio error -> {stop, {shutdown, resumed}} end; -handle_event(timeout, resume_timeout, ?EXT_C2S_STATE(resume_session), StateData) -> +handle_event({timeout, ?MODULE}, resume_timeout, ?EXT_C2S_STATE(resume_session), StateData) -> {stop, {shutdown, ?MODULE}, StateData}; handle_event(EventType, EventContent, C2SState, StateData) -> mongoose_c2s:handle_event(EventType, EventContent, C2SState, StateData). From 99649b57ebb03234cc75721548beea06f1a5b6d6 Mon Sep 17 00:00:00 2001 From: Nelson Vides Date: Tue, 3 Jan 2023 15:52:30 +0100 Subject: [PATCH 7/8] Enable muc_SUITE --- big_tests/default.spec | 2 +- big_tests/dynamic_domains.spec | 10 +++++----- src/mod_presence.erl | 2 +- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/big_tests/default.spec b/big_tests/default.spec index 1e72e4f24a4..dfe929d1c58 100644 --- a/big_tests/default.spec +++ b/big_tests/default.spec @@ -74,7 +74,7 @@ {suites, "tests", mongoose_cassandra_SUITE}. {suites, "tests", mongoose_elasticsearch_SUITE}. {suites, "tests", mongooseimctl_SUITE}. -% {suites, "tests", muc_SUITE}. +{suites, "tests", muc_SUITE}. {suites, "tests", muc_http_api_SUITE}. {suites, "tests", muc_light_SUITE}. {suites, "tests", muc_light_http_api_SUITE}. diff --git a/big_tests/dynamic_domains.spec b/big_tests/dynamic_domains.spec index 1600f19fbb7..513d721bcb5 100644 --- a/big_tests/dynamic_domains.spec +++ b/big_tests/dynamic_domains.spec @@ -100,11 +100,11 @@ {suites, "tests", mongooseimctl_SUITE}. -% {suites, "tests", muc_SUITE}. -% {skip_groups, "tests", muc_SUITE, -% [register_over_s2s], -% "at the moment S2S doesn't support dynamic domains " -% "(requires mod_register creating CT users)"}. +{suites, "tests", muc_SUITE}. +{skip_groups, "tests", muc_SUITE, + [register_over_s2s], + "at the moment S2S doesn't support dynamic domains " + "(requires mod_register creating CT users)"}. {suites, "tests", muc_http_api_SUITE}. diff --git a/src/mod_presence.erl b/src/mod_presence.erl index 43b02f5461a..bdce08bac34 100644 --- a/src/mod_presence.erl +++ b/src/mod_presence.erl @@ -433,7 +433,7 @@ presence_track(Acc, FromJid, ToJid, Packet, _, <<"unsubscribe">>) -> presence_track(Acc, FromJid, ToJid, Packet, _, <<"unsubscribed">>) -> process_presence_track_subscription_and_route(Acc, FromJid, ToJid, Packet, unsubscribed); presence_track(Acc, FromJid, ToJid, Packet, _, <<"error">>) -> - ejabberd_router:route(ToJid, FromJid, Acc, Packet), + ejabberd_router:route(FromJid, ToJid, Acc, Packet), Acc; presence_track(Acc, FromJid, ToJid, Packet, _, <<"probe">>) -> ejabberd_router:route(ToJid, FromJid, Acc, Packet), From 4351e4aaa6629fc9e10c7f2c443cf8ecc96a149b Mon Sep 17 00:00:00 2001 From: Nelson Vides Date: Mon, 9 Jan 2023 16:55:44 +0100 Subject: [PATCH 8/8] Fix reversing the route on presence probes --- src/mod_presence.erl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/mod_presence.erl b/src/mod_presence.erl index bdce08bac34..615f43a7385 100644 --- a/src/mod_presence.erl +++ b/src/mod_presence.erl @@ -436,7 +436,7 @@ presence_track(Acc, FromJid, ToJid, Packet, _, <<"error">>) -> ejabberd_router:route(FromJid, ToJid, Acc, Packet), Acc; presence_track(Acc, FromJid, ToJid, Packet, _, <<"probe">>) -> - ejabberd_router:route(ToJid, FromJid, Acc, Packet), + ejabberd_router:route(FromJid, ToJid, Acc, Packet), Acc. process_presence_track_available(Acc, FromJid, ToJid, Packet, Presences) ->