From 3e907e13c2c9b76633a2f07cb000069a8018badc Mon Sep 17 00:00:00 2001 From: Nelson Vides Date: Fri, 20 Dec 2024 18:19:14 +0100 Subject: [PATCH 1/4] Rework components tests to introduce independence and parallelism --- big_tests/tests/component_SUITE.erl | 225 +++++++++--------- big_tests/tests/component_helper.erl | 65 +++-- big_tests/tests/mod_global_distrib_SUITE.erl | 2 +- .../service_mongoose_system_metrics_SUITE.erl | 19 +- .../mongoose_component_connection.erl | 10 +- 5 files changed, 155 insertions(+), 166 deletions(-) diff --git a/big_tests/tests/component_SUITE.erl b/big_tests/tests/component_SUITE.erl index f1789582c6..69e9640131 100644 --- a/big_tests/tests/component_SUITE.erl +++ b/big_tests/tests/component_SUITE.erl @@ -36,7 +36,7 @@ all() -> ]. groups() -> - [{xep0114, [], xep0114_tests()}, + [{xep0114, [parallel], xep0114_tests()}, {subdomain, [], [register_subdomain]}, {hidden_components, [], [disco_with_hidden_component]}, {distributed, [], [register_in_cluster, @@ -72,33 +72,23 @@ end_per_suite(Config) -> init_per_group(xep0114, Config) -> instrument_helper:start(events()), - Config1 = component_helper:get_components(Config), - escalus:create_users(Config1, escalus:get_users([alice, bob])); + Config; init_per_group(subdomain, Config) -> - Config1 = component_helper:get_components(Config), - add_domain(Config1), - escalus:create_users(Config1, escalus:get_users([alice, astrid])); -init_per_group(hidden_components, Config) -> - Config1 = component_helper:get_components(Config), - escalus:create_users(Config1, escalus:get_users([alice, bob])); + add_domain(Config), + Config; init_per_group(distributed, Config) -> - Config1 = component_helper:get_components(Config), - Config2 = distributed_helper:add_node_to_cluster(Config1), - escalus:create_users(Config2, escalus:get_users([alice, clusterguy])); + distributed_helper:add_node_to_cluster(Config); init_per_group(_GroupName, Config) -> - escalus:create_users(Config, escalus:get_users([alice, bob])). + Config. -end_per_group(xep0114, Config) -> - escalus:delete_users(Config, escalus:get_users([alice, bob])), +end_per_group(xep0114, _Config) -> instrument_helper:stop(); end_per_group(subdomain, Config) -> - escalus:delete_users(Config, escalus:get_users([alice, astrid])), restore_domain(Config); end_per_group(distributed, Config) -> - escalus:delete_users(Config, escalus:get_users([alice, clusterguy])), distributed_helper:remove_node_from_cluster(Config); -end_per_group(_GroupName, Config) -> - escalus:delete_users(Config, escalus:get_users([alice, bob])). +end_per_group(_GroupName, _Config) -> + ok. init_per_testcase(CaseName, Config) -> escalus:init_per_testcase(CaseName, Config). @@ -110,74 +100,60 @@ end_per_testcase(CaseName, Config) -> %%-------------------------------------------------------------------- %% Tests %%-------------------------------------------------------------------- -dirty_disconnect(Config) -> - %% Given one connected component, kill the connection and reconnect - CompOpts = ?config(component1, Config), - {Component, Addr, _} = component_helper:connect_component(CompOpts), - component_helper:disconnect_component(Component, Addr), - {Component1, Addr, _} = component_helper:connect_component(CompOpts), - component_helper:disconnect_component(Component1, Addr). - register_one_component(Config) -> TS = instrument_helper:timestamp(), %% Given one connected component - CompOpts = ?config(component1, Config), - {Component, ComponentAddr, _} = component_helper:connect_component(CompOpts), + CompSpec = component_helper:spec(component1), + {Component, ComponentAddr, _} = component_helper:connect_component(CompSpec), + FullCheckF = fun(#{byte_size := S, lserver := LServer}) -> + S > 0 andalso LServer =:= ComponentAddr + end, + CheckBytes = fun(#{byte_size := S}) -> S > 0 end, + CheckServer = fun(#{lserver := S}) -> S =:= ComponentAddr end, % start stream reply - instrument_helper:assert(component_xmpp_element_size_out, #{}, fun(#{byte_size := S}) -> S > 0 end, + instrument_helper:assert(component_xmpp_element_size_out, #{}, FullCheckF, #{expected_count => 2, min_timestamp => TS}), % 1. start stream, 2. component handshake - instrument_helper:assert(component_xmpp_element_size_in, #{}, fun(#{byte_size := S}) -> S > 0 end, - #{expected_count => 2, min_timestamp => TS}), - instrument_helper:assert(component_tcp_data_in, #{}, fun(#{byte_size := S}) -> S > 0 end, - #{expected_count => 2, min_timestamp => TS}), - instrument_helper:assert(component_auth_failed, #{}, fun(#{byte_size := S}) -> S > 0 end, + instrument_helper:assert(component_auth_failed, #{}, FullCheckF, #{expected_count => 0, min_timestamp => TS}), + instrument_helper:assert(component_xmpp_element_size_in, #{}, FullCheckF, + #{expected_count => 1, min_timestamp => TS}), + instrument_helper:assert(component_tcp_data_in, #{}, CheckBytes, + #{min_timestamp => TS}), % 1. start stream reply, 2. handshake reply - instrument_helper:assert(component_tcp_data_out, #{}, fun(#{byte_size := S}) -> S > 0 end, - #{expected_count => 2, min_timestamp => TS}), + instrument_helper:assert(component_tcp_data_out, #{}, CheckBytes, + #{min_timestamp => TS}), TS1 = instrument_helper:timestamp(), verify_component(Config, Component, ComponentAddr), % Message from Alice - instrument_helper:assert(component_xmpp_element_size_out, #{}, fun(#{byte_size := S}) -> S > 0 end, + instrument_helper:assert(component_xmpp_element_size_out, #{}, FullCheckF, #{expected_count => 1, min_timestamp => TS1}), % Reply to Alice - instrument_helper:assert(component_xmpp_element_size_in, #{}, fun(#{byte_size := S}) -> S > 0 end, + instrument_helper:assert(component_xmpp_element_size_in, #{}, FullCheckF, #{expected_count => 1, min_timestamp => TS1}), - instrument_helper:assert(component_element_in, #{}, fun(_) -> true end, + instrument_helper:assert(component_element_in, #{}, CheckServer, #{expected_count => 1, min_timestamp => TS1}), - instrument_helper:assert(component_element_out, #{}, fun(_) -> true end, + instrument_helper:assert(component_element_out, #{}, CheckServer, #{expected_count => 1, min_timestamp => TS1}), component_helper:disconnect_component(Component, ComponentAddr). -verify_component(Config, Component, ComponentAddr) -> - escalus:story(Config, [{alice, 1}], fun(Alice) -> - %% When Alice sends a message to the component - Msg1 = escalus_stanza:chat_to(ComponentAddr, <<"Hi!">>), - escalus:send(Alice, Msg1), - %% Then component receives it - Reply1 = escalus:wait_for_stanza(Component), - escalus:assert(is_chat_message, [<<"Hi!">>], Reply1), - - %% When component sends a reply - Msg2 = escalus_stanza:chat_to(Alice, <<"Oh hi!">>), - escalus:send(Component, escalus_stanza:from(Msg2, ComponentAddr)), - - %% Then Alice receives it - Reply2 = escalus:wait_for_stanza(Alice), - escalus:assert(is_chat_message, [<<"Oh hi!">>], Reply2), - escalus:assert(is_stanza_from, [ComponentAddr], Reply2) - end). +dirty_disconnect(Config) -> + %% Given one connected component, kill the connection and reconnect + CompSpec = component_helper:spec(component1), + {Component, Addr, _} = component_helper:connect_component(CompSpec), + component_helper:disconnect_component(Component, Addr), + {Component1, Addr, _} = component_helper:connect_component(CompSpec), + component_helper:disconnect_component(Component1, Addr). intercomponent_communication(Config) -> %% Given two connected components - CompOpts1 = ?config(component1, Config), - CompOpts2 = ?config(component2, Config), - {Comp1, CompAddr1, _} = component_helper:connect_component(CompOpts1), - {Comp2, CompAddr2, _} = component_helper:connect_component(CompOpts2), + CompSpec1 = component_helper:spec(component1), + CompSpec2 = component_helper:spec(component2), + {Comp1, CompAddr1, _} = component_helper:connect_component(CompSpec1), + {Comp2, CompAddr2, _} = component_helper:connect_component(CompSpec2), TS = instrument_helper:timestamp(), %% When the first component sends a message the second component @@ -187,9 +163,12 @@ intercomponent_communication(Config) -> Reply0 = escalus:wait_for_stanza(Comp2), escalus:assert(is_chat_message, [<<"intercomponent msg">>], Reply0), - instrument_helper:assert(component_xmpp_element_size_out, #{}, fun(#{byte_size := S}) -> S > 0 end, + FullCheckF = fun(#{byte_size := S, lserver := LServer}) -> + S > 0 andalso LServer =:= CompAddr1 orelse LServer =:= CompAddr2 + end, + instrument_helper:assert(component_xmpp_element_size_out, #{}, FullCheckF, #{expected_count => 1, min_timestamp => TS}), - instrument_helper:assert(component_xmpp_element_size_in, #{}, fun(#{byte_size := S}) -> S > 0 end, + instrument_helper:assert(component_xmpp_element_size_in, #{}, FullCheckF, #{expected_count => 1, min_timestamp => TS}), component_helper:disconnect_component(Comp1, CompAddr1), @@ -198,13 +177,13 @@ intercomponent_communication(Config) -> register_two_components(Config) -> %% Given two connected components - CompOpts1 = ?config(component1, Config), - CompOpts2 = ?config(component2, Config), - {Comp1, CompAddr1, _} = component_helper:connect_component(CompOpts1), - {Comp2, CompAddr2, _} = component_helper:connect_component(CompOpts2), + CompSpec1 = component_helper:spec(component1), + CompSpec2 = component_helper:spec(component2), + {Comp1, CompAddr1, _} = component_helper:connect_component(CompSpec1), + {Comp2, CompAddr2, _} = component_helper:connect_component(CompSpec2), TS = instrument_helper:timestamp(), - escalus:story(Config, + escalus:fresh_story(Config, [{alice, 1}, {bob, 1}], fun(Alice, Bob) -> %% When the first component sends a message to Alice Msg1 = escalus_stanza:chat_to(Alice, <<"Comp1-2-Alice msg">>), @@ -237,11 +216,14 @@ register_two_components(Config) -> escalus:assert(is_chat_message, [<<"Alice-2-Comp1 msg">>], Reply4) end), + FullCheckF = fun(#{byte_size := S, lserver := LServer}) -> + S > 0 andalso LServer =:= CompAddr1 orelse LServer =:= CompAddr2 + end, % Msg to Alice, msg to Bob - instrument_helper:assert(component_xmpp_element_size_in, #{}, fun(#{byte_size := S}) -> S > 0 end, + instrument_helper:assert(component_xmpp_element_size_in, #{}, FullCheckF, #{expected_count => 2, min_timestamp => TS}), % Msg from Bob, msg from Alice - instrument_helper:assert(component_xmpp_element_size_out, #{}, fun(#{byte_size := S}) -> S > 0 end, + instrument_helper:assert(component_xmpp_element_size_out, #{}, FullCheckF, #{expected_count => 2, min_timestamp => TS}), component_helper:disconnect_component(Comp1, CompAddr1), @@ -250,11 +232,11 @@ register_two_components(Config) -> try_registering_with_wrong_password(Config) -> %% Given a component with a wrong password TS = instrument_helper:timestamp(), - CompOpts1 = ?config(component1, Config), - CompOpts2 = lists:keyreplace(password, 1, CompOpts1, {password, <<"wrong_one">>}), + CompSpec1 = component_helper:spec(component1), + CompSpec2 = lists:keyreplace(password, 1, CompSpec1, {password, <<"wrong_one">>}), try %% When trying to connect it - {Comp, Addr, _} = component_helper:connect_component(CompOpts2), + {Comp, Addr, _} = component_helper:connect_component(CompSpec2), component_helper:disconnect_component(Comp, Addr), ct:fail("component connected successfully with wrong password") catch {stream_error, _E} -> @@ -266,12 +248,12 @@ try_registering_with_wrong_password(Config) -> try_registering_component_twice(Config) -> %% Given two components with the same name - CompOpts1 = ?config(component1, Config), - {Comp1, Addr, _} = component_helper:connect_component(CompOpts1), + CompSpec1 = component_helper:spec(component1), + {Comp1, Addr, _} = component_helper:connect_component(CompSpec1), try %% When trying to connect the second one - {Comp2, Addr, _} = component_helper:connect_component(CompOpts1), + {Comp2, Addr, _} = component_helper:connect_component(CompSpec1), component_helper:disconnect_component(Comp2, Addr), ct:fail("second component connected successfully") catch {stream_error, _} -> @@ -283,7 +265,7 @@ try_registering_component_twice(Config) -> try_registering_existing_host(Config) -> %% Given a external vjud component - Component = ?config(vjud_component, Config), + Component = component_helper:spec(vjud_component), try %% When trying to connect it to the server @@ -298,11 +280,11 @@ try_registering_existing_host(Config) -> %% When conflict_behaviour is kick_old, then: %% - stop old connections by sending stream:error with reason "conflict" kick_old_component_on_conflict(Config) -> - CompOpts1 = component_helper:spec(kicking_component, Config), - {Comp1, Addr, _} = component_helper:connect_component(CompOpts1), + CompSpec1 = component_helper:spec(kicking_component), + {Comp1, Addr, _} = component_helper:connect_component(CompSpec1), %% When trying to connect the second one - {Comp2, Addr, _} = component_helper:connect_component(CompOpts1), + {Comp2, Addr, _} = component_helper:connect_component(CompSpec1), %% First connection is disconnected Stanza = escalus:wait_for_stanza(Comp1), @@ -315,12 +297,12 @@ kick_old_component_on_conflict(Config) -> disco_components(Config) -> %% Given two connected components - CompOpts1 = ?config(component1, Config), - CompOpts2 = ?config(component2, Config), - {Comp1, Addr1, _} = component_helper:connect_component(CompOpts1), - {Comp2, Addr2, _} = component_helper:connect_component(CompOpts2), + CompSpec1 = component_helper:spec(component1), + CompSpec2 = component_helper:spec(component2), + {Comp1, Addr1, _} = component_helper:connect_component(CompSpec1), + {Comp2, Addr2, _} = component_helper:connect_component(CompSpec2), - escalus:story(Config, [{alice, 1}], fun(Alice) -> + escalus:fresh_story(Config, [{alice, 1}], fun(Alice) -> %% When server asked for the disco features Server = escalus_client:server(Alice), Disco = escalus_stanza:service_discovery(Server), @@ -340,12 +322,12 @@ disco_components(Config) -> %% Assumes mod_disco with `{users_can_see_hidden_services, false}` option disco_with_hidden_component(Config) -> %% Given two connected components - CompOpts1 = ?config(component1, Config), - HCompOpts = component_helper:spec(hidden_component, Config), - {Comp1, Addr1, _} = component_helper:connect_component(CompOpts1), + CompSpec1 = component_helper:spec(component1), + HCompOpts = component_helper:spec(hidden_component), + {Comp1, Addr1, _} = component_helper:connect_component(CompSpec1), {HComp, HAddr, _} = component_helper:connect_component(HCompOpts), - escalus:story(Config, [{alice, 1}], fun(Alice) -> + escalus:fresh_story(Config, [{alice, 1}], fun(Alice) -> %% When server asked for the disco features Server = escalus_client:server(Alice), Disco = escalus_stanza:service_discovery(Server), @@ -364,10 +346,10 @@ disco_with_hidden_component(Config) -> register_subdomain(Config) -> %% Given one connected component - CompOpts1 = ?config(component1, Config), - {Comp, Addr, Name} = component_helper:connect_component_subdomain(CompOpts1), + CompSpec1 = component_helper:spec(component1), + {Comp, Addr, Name} = component_helper:connect_component_subdomain(CompSpec1), - escalus:story(Config, [{alice, 1}, {astrid, 1}], fun(Alice, Astrid) -> + escalus:fresh_story(Config, [{alice, 1}, {astrid, 1}], fun(Alice, Astrid) -> %% When Alice asks for service discovery on the server Server1 = escalus_client:server(Alice), Disco1 = escalus_stanza:service_discovery(Server1), @@ -396,17 +378,17 @@ register_subdomain(Config) -> register_in_cluster(Config) -> %% Given one component connected to the cluster - CompOpts1 = ?config(component1, Config), - Component1 = component_helper:connect_component(CompOpts1), + CompSpec1 = component_helper:spec(component1), + Component1 = component_helper:connect_component(CompSpec1), {Comp1, Addr1, _} = Component1, - CompOpts2 = ?config(component2, Config), - Component2 = component_helper:connect_component(CompOpts2), + CompSpec2 = component_helper:spec(component2), + Component2 = component_helper:connect_component(CompSpec2), {Comp2, Addr2, _} = Component2, - CompOpts_on_2 = component_helper:spec(component_on_2, Config), - Component_on_2 = component_helper:connect_component(CompOpts_on_2), + CompSpec_on_2 = component_helper:spec(component_on_2), + Component_on_2 = component_helper:connect_component(CompSpec_on_2), {Comp_on_2, Addr_on_2, _} = Component_on_2, - escalus:story(Config, [{alice, 1}, {clusterguy, 1}], fun(Alice, ClusterGuy) -> + escalus:fresh_story(Config, [{alice, 1}, {clusterguy, 1}], fun(Alice, ClusterGuy) -> do_chat_with_component(Alice, ClusterGuy, Component1), do_chat_with_component(Alice, ClusterGuy, Component2), do_chat_with_component(Alice, ClusterGuy, Component_on_2) @@ -417,14 +399,14 @@ register_in_cluster(Config) -> component_helper:disconnect_component(Comp_on_2, Addr_on_2). clear_on_node_down(Config) -> - CompOpts = ?config(component1, Config), - ?assertMatch({_, _, _}, component_helper:connect_component(CompOpts)), - ?assertThrow({stream_error, _}, component_helper:connect_component(CompOpts)), + CompSpec = component_helper:spec(component1), + ?assertMatch({_, _, _}, component_helper:connect_component(CompSpec)), + ?assertThrow({stream_error, _}, component_helper:connect_component(CompSpec)), distributed_helper:stop_node(mim(), Config), distributed_helper:start_node(mim(), Config), - {Comp, Addr, _} = component_helper:connect_component(CompOpts), + {Comp, Addr, _} = component_helper:connect_component(CompSpec), component_helper:disconnect_component(Comp, Addr). do_chat_with_component(Alice, ClusterGuy, Component1) -> @@ -488,14 +470,14 @@ register_same_on_both(Config) -> %% but not on the same host %% we should be able to register %% and we get two components having the same name and address - CompOpts2 = ?config(component2, Config), - Component2 = component_helper:connect_component(CompOpts2), + CompSpec2 = component_helper:spec(component2), + Component2 = component_helper:connect_component(CompSpec2), {Comp2, Addr, Name} = Component2, - CompOpts_d = component_helper:spec(component_duplicate, Config), - Component_d = component_helper:connect_component(CompOpts_d), + CompSpec_d = component_helper:second_port(CompSpec2), + Component_d = component_helper:connect_component(CompSpec_d), {Comp_d, Addr, Name} = Component_d, - escalus:story(Config, [{alice, 1}, {clusterguy, 1}], fun(Alice, ClusterGuy) -> + escalus:fresh_story(Config, [{alice, 1}, {clusterguy, 1}], fun(Alice, ClusterGuy) -> %% When Alice sends a message to the component Msg1 = escalus_stanza:chat_to(Addr, <<"Hi!">>), escalus:send(Alice, Msg1), @@ -554,6 +536,25 @@ register_same_on_both(Config) -> %%-------------------------------------------------------------------- %% Helpers %%-------------------------------------------------------------------- +verify_component(Config, Component, ComponentAddr) -> + escalus:fresh_story(Config, [{alice, 1}], fun(Alice) -> + %% When Alice sends a message to the component + Msg1 = escalus_stanza:chat_to(ComponentAddr, <<"Hi!">>), + escalus:send(Alice, Msg1), + %% Then component receives it + Reply1 = escalus:wait_for_stanza(Component), + escalus:assert(is_chat_message, [<<"Hi!">>], Reply1), + + %% When component sends a reply + Msg2 = escalus_stanza:chat_to(Alice, <<"Oh hi!">>), + escalus:send(Component, escalus_stanza:from(Msg2, ComponentAddr)), + + %% Then Alice receives it + Reply2 = escalus:wait_for_stanza(Alice), + escalus:assert(is_chat_message, [<<"Oh hi!">>], Reply2), + escalus:assert(is_stanza_from, [ComponentAddr], Reply2) + end). + add_domain(Config) -> Hosts = {hosts, "\"localhost\", \"sogndal\""}, ejabberd_node_utils:backup_config_file(Config), @@ -576,3 +577,7 @@ events() -> cluster_users() -> AllUsers = ct:get_config(escalus_users), [proplists:lookup(alice, AllUsers), proplists:lookup(clusterguy, AllUsers)]. + +-spec domain() -> binary(). +domain() -> + ct:get_config({hosts, mim, domain}). diff --git a/big_tests/tests/component_helper.erl b/big_tests/tests/component_helper.erl index 04661de42c..ed4e8178f3 100644 --- a/big_tests/tests/component_helper.erl +++ b/big_tests/tests/component_helper.erl @@ -6,11 +6,10 @@ disconnect_component/2, disconnect_components/2, connect_component_subdomain/1, - get_components/1, get_components/2, get_components/3, - spec/2, - common/1, - common/2, - name/1 + get_components/1, + second_port/1, + spec/1, + host/1 ]). -export([component_start_stream/2, @@ -128,33 +127,34 @@ component_start_stream_subdomain(Conn = #client{props = Props}, []) -> connect_component_subdomain(Component) -> connect_component(Component, component_start_stream_subdomain). -spec(component_on_2, Config) -> - [{component, <<"yet_another_service">>}] ++ common(Config, mim2_service_port()); -spec(component_duplicate, Config) -> - [{component, <<"another_service">>}] ++ common(Config, mim2_service_port()); -spec(hidden_component, Config) -> - [{component, <<"hidden_component">>}] ++ common(Config, hidden_service_port()); -spec(kicking_component, Config) -> - [{component, <<"kicking_component">>}] ++ common(Config, kicking_service_port()); -spec(Other, Config) -> - [name(Other) | proplists:get_value(Other, Config, [])]. - -common(Config) -> - common(Config, service_port()). +host(CompSpec) -> + proplists:get_value(component, CompSpec). + +second_port(Spec) -> + lists:keyreplace(port, 1, Spec, {port, mim2_service_port()}). + +spec(vjud_component) -> + [{component, <<"vjud">>} | common(mim2_service_port())]; +spec(component_on_2) -> + [{component, <<"yet_another_service">>} | common(mim2_service_port())]; +spec(component_on_2) -> + [{component, <<"yet_another_service">>} | common(mim2_service_port())]; +spec(hidden_component) -> + [{component, <<"hidden_component">>} | common(hidden_service_port())]; +spec(kicking_component) -> + [{component, <<"kicking_component">>} | common(kicking_service_port())]; +spec(Other) -> + Prefix = integer_to_binary(erlang:unique_integer([monotonic, positive])), + Name = <>, + [{component, Name} | common(service_port())]. service_port() -> ct:get_config({hosts, mim, service_port}). get_components(Config) -> - Opts = common(Config), - get_components(Opts, Config). - -get_components(Opts, Config) -> + Opts = common(service_port()), Components = [component1, component2, vjud_component], - get_components(Opts, Components, Config). - -get_components(Opts, Components, Config) -> - [ {C, Opts ++ spec(C, Config)} || C <- Components ] ++ Config. + [ {C, Opts ++ spec(C)} || C <- Components ] ++ Config. kicking_service_port() -> ct:get_config({hosts, mim, kicking_service_port}). @@ -165,17 +165,8 @@ hidden_service_port() -> mim2_service_port() -> ct:get_config({hosts, mim2, service_port}). -common(_Config, Port) -> +common(Port) -> [{server, ct:get_config({hosts, mim, domain})}, - {host, ct:get_config({hosts, mim, domain})}, + {host, <<"localhost">>}, {password, <<"secret">>}, {port, Port}]. - -name(component1) -> - {component, <<"test_service">>}; -name(component2) -> - {component, <<"another_service">>}; -name(vjud_component) -> - {component, <<"vjud">>}; -name(kicking_component) -> - {component, <<"kicking_component">>}. diff --git a/big_tests/tests/mod_global_distrib_SUITE.erl b/big_tests/tests/mod_global_distrib_SUITE.erl index 62a20cdbe7..c5aa8a6c04 100644 --- a/big_tests/tests/mod_global_distrib_SUITE.erl +++ b/big_tests/tests/mod_global_distrib_SUITE.erl @@ -644,7 +644,7 @@ test_components_in_different_regions(_Config) -> %% Ordinary user is not able to discover the hidden component from GD test_hidden_component_disco_in_different_region(Config) -> %% Hidden component from component_SUITE connects to mim1/europe_node1 - HiddenComponentConfig = component_helper:spec(hidden_component, Config), + HiddenComponentConfig = component_helper:spec(hidden_component), {_HiddenComp, HiddenAddr, _} = component_helper:connect_component(HiddenComponentConfig), escalus:fresh_story( diff --git a/big_tests/tests/service_mongoose_system_metrics_SUITE.erl b/big_tests/tests/service_mongoose_system_metrics_SUITE.erl index aa79b9dcf5..d01b8a43e4 100644 --- a/big_tests/tests/service_mongoose_system_metrics_SUITE.erl +++ b/big_tests/tests/service_mongoose_system_metrics_SUITE.erl @@ -18,13 +18,7 @@ instance_id = <<>>, app_secret = <<>>}). --import(distributed_helper, [mim/0, mim2/0, mim3/0, rpc/4, - require_rpc_nodes/1 - ]). - --import(component_helper, [connect_component/1, - disconnect_component/2, - get_components/1]). +-import(distributed_helper, [mim/0, mim2/0, mim3/0, rpc/4, require_rpc_nodes/1]). -import(domain_helper, [host_type/0]). -import(config_parser_helper, [mod_config/2, config/2]). @@ -120,9 +114,8 @@ init_per_testcase(system_metrics_are_reported_to_configurable_google_analytics, Config; init_per_testcase(xmpp_components_are_reported, Config) -> create_events_collection(), - Config1 = get_components(Config), enable_system_metrics(mim()), - Config1; + Config; init_per_testcase(xmpp_stanzas_counts_are_reported = CN, Config) -> create_events_collection(), enable_system_metrics(mim()), @@ -248,12 +241,12 @@ mongoose_version_is_reported(_Config) -> cluster_uptime_is_reported(_Config) -> wait_helper:wait_until(fun is_cluster_uptime_reported/0, true). -xmpp_components_are_reported(Config) -> - CompOpts = ?config(component1, Config), - {Component, Addr, _} = connect_component(CompOpts), +xmpp_components_are_reported(_Config) -> + CompOpts = component_helper:spec(component1), + {Component, Addr, _} = component_helper:connect_component(CompOpts), wait_helper:wait_until(fun are_xmpp_components_reported/0, true), wait_helper:wait_until(fun more_than_one_component_is_reported/0, true), - disconnect_component(Component, Addr). + component_helper:disconnect_component(Component, Addr). api_are_reported(_Config) -> wait_helper:wait_until(fun is_api_reported/0, true). diff --git a/src/component/mongoose_component_connection.erl b/src/component/mongoose_component_connection.erl index a7f0c44997..41bcedfc39 100644 --- a/src/component/mongoose_component_connection.erl +++ b/src/component/mongoose_component_connection.erl @@ -90,7 +90,6 @@ handle_event(internal, {connect, {SocketModule, SocketOpts}}, connect, {next_state, wait_for_stream, StateData1, state_timeout(LOpts)}; handle_event(internal, #xmlstreamstart{name = Name, attrs = Attrs}, wait_for_stream, StateData) -> StreamStart = #xmlel{name = Name, attrs = Attrs}, - execute_element_event(component_element_in, StreamStart, StateData), handle_stream_start(StateData, StreamStart); handle_event(internal, #xmlel{name = <<"handshake">>} = El, wait_for_handshake, StateData) -> execute_element_event(component_element_in, El, StateData), @@ -176,10 +175,10 @@ handle_socket_packet(StateData = #component_data{parser = Parser}, Packet) -> end. -spec handle_socket_elements(data(), [exml_stream:element()], non_neg_integer()) -> fsm_res(). -handle_socket_elements(StateData = #component_data{shaper = Shaper}, Elements, Size) -> +handle_socket_elements(StateData = #component_data{lserver = LServer, shaper = Shaper}, Elements, Size) -> {NewShaper, Pause} = mongoose_shaper:update(Shaper, Size), [mongoose_instrument:execute( - component_xmpp_element_size_in, #{}, #{byte_size => exml:xml_size(El)}) + component_xmpp_element_size_in, #{}, #{byte_size => exml:xml_size(El), lserver => LServer}) || El <- Elements], NewStateData = StateData#component_data{shaper = NewShaper}, MaybePauseTimeout = maybe_pause(NewStateData, Pause), @@ -212,6 +211,7 @@ handle_stream_start(S0, StreamStart) -> IsSubdomain = <<"true">> =:= exml_query:attr(StreamStart, <<"is_subdomain">>, <<>>), S1 = S0#component_data{lserver = LServer, is_subdomain = IsSubdomain}, send_header(S1), + execute_element_event(component_element_in, StreamStart, S1), {next_state, wait_for_handshake, S1, state_timeout(S1)}; {?NS_COMPONENT_ACCEPT, error} -> stream_start_error(S0, mongoose_xmpp_errors:host_unknown()); @@ -424,11 +424,11 @@ close_parser(#component_data{parser = Parser}) -> -spec send_xml(data(), exml_stream:element() | [exml_stream:element()]) -> maybe_ok(). send_xml(Data, XmlElement) when is_tuple(XmlElement) -> send_xml(Data, [XmlElement]); -send_xml(#component_data{socket = Socket} = StateData, XmlElements) when is_list(XmlElements) -> +send_xml(#component_data{lserver = LServer, socket = Socket} = StateData, XmlElements) when is_list(XmlElements) -> [ begin execute_element_event(component_element_out, El, StateData), mongoose_instrument:execute( - component_xmpp_element_size_out, #{}, #{byte_size => exml:xml_size(El)}) + component_xmpp_element_size_out, #{}, #{byte_size => exml:xml_size(El), lserver => LServer}) end || El <- XmlElements], mongoose_component_socket:send_xml(Socket, XmlElements). From 02aab44fcf02f62c032560981a9d4876e48b9c00 Mon Sep 17 00:00:00 2001 From: Nelson Vides Date: Tue, 31 Dec 2024 15:39:10 +0100 Subject: [PATCH 2/4] Update old documentation about routing tables --- doc/developers-guide/Stanza-routing.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/doc/developers-guide/Stanza-routing.md b/doc/developers-guide/Stanza-routing.md index d74182a188..b0c4bf2200 100644 --- a/doc/developers-guide/Stanza-routing.md +++ b/doc/developers-guide/Stanza-routing.md @@ -33,8 +33,8 @@ The default behaviour is the following: * `mongoose_router_global`: runs a global `filter_packet` hook. * `mongoose_router_localdomain`: if there is a local route registered for the destination domain (i.e. there is an entry in the `mongoose_router` ETS table), routes the stanza to it. When the recipient's domain is checked for the first time, the corresponding route is not registered yet, because the routes are added lazily - see `mongoose_router_dynamic_domains`. -* `mongoose_router_external_localnode`: if there is an external component registered for the destination domain on the current node, routes the stanza to it. Such components are stored in the Mnesia table `external_component`, which is not replicated in the cluster. -* `mongoose_router_external`: if there is an external component registered for the destination domain on any node in the cluster, routes the stanza to it. Such components are stored in the Mnesia table `external_component_global`, which is replicated among all cluster nodes. +* `mongoose_router_external_localnode`: if there is an external component registered for the destination domain on the current node, routes the stanza to it. +* `mongoose_router_external`: if there is an external component registered for the destination domain on any node in the cluster, routes the stanza to it. * `mongoose_router_dynamic_domains`: if the recipient's domain is hosted by the local server, a route is added for it, and the stanza is routed locally. * `ejabberd_s2s`: tries to find or establish a connection to another server and send the stanza there. From d10da98b57229da1c972b70f1c4cf26d28ad567c Mon Sep 17 00:00:00 2001 From: Nelson Vides Date: Tue, 31 Dec 2024 15:40:34 +0100 Subject: [PATCH 3/4] Support dynamic domains for components Note that components might register _any_ domain, even one not necessarily provided by a static config or a dynamically configured one. Hence it makes no sense to use the subdomains registration API as it was described in a TODO in `mod_disco:get_external_components/2`. Furthermore, when it comes to discovery, we want to leave all components as discoverable, regardless of whether the component is a subdomain of a static domain as it was previously done. The code filtering out unrelated parent domains comes from long before MongooseIM 1.0.0, as well as the option to set `extra_domains` to reenable visibility. --- big_tests/dynamic_domains.config | 5 +++ big_tests/dynamic_domains.spec | 1 + doc/listeners/listen-components.md | 8 ++-- .../mongoose_component_connection.erl | 38 +++++++++-------- src/domain/mongoose_domain_api.erl | 3 -- src/mod_disco.erl | 42 +++++-------------- 6 files changed, 42 insertions(+), 55 deletions(-) diff --git a/big_tests/dynamic_domains.config b/big_tests/dynamic_domains.config index 67c92de1be..2f704c13a8 100644 --- a/big_tests/dynamic_domains.config +++ b/big_tests/dynamic_domains.config @@ -110,6 +110,11 @@ {server, <<"domain.example.com">>}, {host, <<"localhost">>}, {password, <<"nicniema">>}]}, + {astrid, [ + {username, <<"astrid">>}, + {server, <<"sogndal">>}, + {host, <<"localhost">>}, + {password, <<"doctor">>}]}, {geralt, [ {username, <<"geralt">>}, {server, <<"domain.example.com">>}, diff --git a/big_tests/dynamic_domains.spec b/big_tests/dynamic_domains.spec index b88a9dc765..474c8fe460 100644 --- a/big_tests/dynamic_domains.spec +++ b/big_tests/dynamic_domains.spec @@ -107,6 +107,7 @@ %% to minimise impact on other tests {suites, "tests", auth_methods_for_c2s_SUITE}. {suites, "tests", cluster_commands_SUITE}. +{suites, "tests", component_SUITE}. {suites, "tests", dynamic_domains_SUITE}. {suites, "tests", graphql_server_SUITE}. {suites, "tests", last_SUITE}. diff --git a/doc/listeners/listen-components.md b/doc/listeners/listen-components.md index d319b8ec78..0792c7a76d 100644 --- a/doc/listeners/listen-components.md +++ b/doc/listeners/listen-components.md @@ -4,9 +4,11 @@ Interface for external services acting as XMPP components ([XEP-0114: Jabber Com According to [XEP-0114: Jabber Component Protocol](http://xmpp.org/extensions/xep-0114.html) the component's hostname should be given in the element. -!!! warning - This interface does not support [dynamic domains](../configuration/general.md#generalhost_types). - Do not use them both at the same time. +!!! Note + The component might register _any_ domain, which might not necessarily be a static nor a dynamic domain, nor subdomain, recognised by the MongooseIM router. For routing to work, the modules `mongoose_router_external_localnode` and `mongoose_router_external` must be enabled in the [`general.routing_modules`](../configuration/general.md#generalrouting_modules) section. + + Note the order of the routing modules: if a component is meant to supplant a domain served regularly by the MongooseIM server, the external routers should be ordered with higher priority. + ## Configuration options diff --git a/src/component/mongoose_component_connection.erl b/src/component/mongoose_component_connection.erl index 41bcedfc39..7e4d024cfe 100644 --- a/src/component/mongoose_component_connection.erl +++ b/src/component/mongoose_component_connection.erl @@ -285,24 +285,6 @@ handle_stream_established(StateData, #xmlel{name = Name} = El) -> end, keep_state_and_data. --spec register_routes(data()) -> any(). -register_routes(StateData) -> - #component_data{listener_opts = #{hidden_components := AreHidden}} = StateData, - Routes = get_routes(StateData), - Handler = mongoose_packet_handler:new(mongoose_component, #{pid => self()}), - mongoose_component:register_components(Routes, node(), Handler, AreHidden). - --spec get_routes(data()) -> [jid:lserver()]. -get_routes(#component_data{lserver = Subdomain, is_subdomain = true}) -> - Hosts = mongoose_config:get_opt(hosts), - component_routes(Subdomain, Hosts); -get_routes(#component_data{lserver = Host}) -> - [Host]. - --spec component_routes(binary(), [jid:lserver()]) -> [jid:lserver()]. -component_routes(Subdomain, Hosts) -> - [<> || Host <- Hosts]. - -spec try_register_routes(data(), retries()) -> fsm_res(). try_register_routes(StateData, Retries) -> case register_routes(StateData) of @@ -320,6 +302,26 @@ try_register_routes(StateData, Retries) -> handle_registration_conflict(ConflictBehaviour, RoutesInfo, StateData, Retries) end. +-spec register_routes(data()) -> any(). +register_routes(StateData) -> + #component_data{listener_opts = #{hidden_components := AreHidden}} = StateData, + Routes = get_routes(StateData), + Handler = mongoose_packet_handler:new(mongoose_component, #{pid => self()}), + mongoose_component:register_components(Routes, node(), Handler, AreHidden). + +-spec get_routes(data()) -> [jid:lserver()]. +get_routes(#component_data{lserver = Subdomain, is_subdomain = true}) -> + StaticDomains = mongoose_domain_api:get_all_static(), + DynamicDomains = mongoose_domain_api:get_all_dynamic(), + [ component_route(Subdomain, Domain) || {Domain, _} <- StaticDomains ] + ++ [ component_route(Subdomain, Domain) || {Domain, _} <- DynamicDomains ]; +get_routes(#component_data{lserver = Host}) -> + [Host]. + +-spec component_route(binary(), jid:lserver()) -> jid:lserver(). +component_route(Subdomain, Host) -> + <>. + handle_registration_conflict(kick_old, RoutesInfo, StateData, Retries) when Retries > 0 -> %% see lookup_routes Pids = lists:usort(routes_info_to_pids(RoutesInfo)), diff --git a/src/domain/mongoose_domain_api.erl b/src/domain/mongoose_domain_api.erl index 4582315556..39e2074f10 100644 --- a/src/domain/mongoose_domain_api.erl +++ b/src/domain/mongoose_domain_api.erl @@ -41,9 +41,6 @@ %% For testing -export([get_all_dynamic/0]). --ignore_xref([get_all_static/0]). --ignore_xref([get_all_dynamic/0]). - -type status() :: enabled | disabled | deleting. -type domain() :: jid:lserver(). -type host_type() :: mongooseim:host_type(). diff --git a/src/mod_disco.erl b/src/mod_disco.erl index af83380127..832c5de6e6 100644 --- a/src/mod_disco.erl +++ b/src/mod_disco.erl @@ -228,7 +228,7 @@ disco_sm_identity(Acc = #{to_jid := JID}, _, _) -> disco_local_items(Acc = #{host_type := HostType, from_jid := From, to_jid := To, node := <<>>}, _, _) -> ReturnHidden = should_return_hidden(HostType, From), Subdomains = get_subdomains(To#jid.lserver), - Components = get_external_components(To#jid.lserver, ReturnHidden), + Components = get_external_components(ReturnHidden), ExtraDomains = get_extra_domains(HostType), Domains = Subdomains ++ Components ++ ExtraDomains, {ok, mongoose_disco:add_items([#{jid => Domain} || Domain <- Domains], Acc)}; @@ -267,10 +267,6 @@ disco_info(Acc = #{host_type := HostType, module := Module, node := <<>>}, _, _) disco_info(Acc, _, _) -> {ok, Acc}. --spec get_extra_domains(mongooseim:host_type()) -> [jid:lserver()]. -get_extra_domains(HostType) -> - gen_mod:get_module_opt(HostType, ?MODULE, extra_domains). - %% Internal functions -spec should_return_hidden(mongooseim:host_type(), From :: jid:jid()) -> return_hidden(). @@ -284,33 +280,17 @@ should_return_hidden(HostType, _From) -> end. -spec get_subdomains(jid:lserver()) -> [jid:lserver()]. -get_subdomains(Domain) -> +get_subdomains(LServer) -> [maps:get(subdomain, SubdomainInfo) || - SubdomainInfo <- mongoose_domain_api:get_all_subdomains_for_domain(Domain)]. - -%% TODO: This code can be removed when components register subdomains in the domain API. -%% Until then, it works only for static domains. --spec get_external_components(jid:server(), return_hidden()) -> [jid:lserver()]. -get_external_components(Domain, ReturnHidden) -> - StaticDomains = lists:sort(fun(H1, H2) -> size(H1) >= size(H2) end, ?MYHOSTS), - lists:filter( - fun(Component) -> - check_if_host_is_the_shortest_suffix_for_route(Component, Domain, StaticDomains) - end, mongoose_component:dirty_get_all_components(ReturnHidden)). - --spec check_if_host_is_the_shortest_suffix_for_route( - Route :: jid:lserver(), Host :: jid:lserver(), VHosts :: [jid:lserver()]) -> boolean(). -check_if_host_is_the_shortest_suffix_for_route(Route, Host, VHosts) -> - RouteS = binary_to_list(Route), - case lists:dropwhile( - fun(VH) -> - not lists:suffix("." ++ binary_to_list(VH), RouteS) - end, VHosts) of - [] -> - false; - [VH | _] -> - VH == Host - end. + SubdomainInfo <- mongoose_domain_api:get_all_subdomains_for_domain(LServer)]. + +-spec get_external_components(return_hidden()) -> [jid:lserver()]. +get_external_components(ReturnHidden) -> + mongoose_component:dirty_get_all_components(ReturnHidden). + +-spec get_extra_domains(mongooseim:host_type()) -> [jid:lserver()]. +get_extra_domains(HostType) -> + gen_mod:get_module_opt(HostType, ?MODULE, extra_domains). %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% From 9afc32cf09005bd924fddadd6f3abb47a3f4714e Mon Sep 17 00:00:00 2001 From: Nelson Vides Date: Tue, 31 Dec 2024 15:50:02 +0100 Subject: [PATCH 4/4] Remove mod_disco extra_domains config key This option was used to make discoverable components that for a user might not have been discoverable given the domain was unrelated. This was so decided over a decade ago before MongooseIM 1.0.0, but I'd judge a better solution is to leave components as either entirely discoverable or entirely hidden by default, as components are usually dynamic and at the same time fully controllable at the deployment, and we can now have an infinite amount of domains for which a component can become a subdomain and hard-coding "extra_domains" for each static or dynamic domain is not feasible. --- big_tests/tests/disco_and_caps_SUITE.erl | 18 ++---------------- doc/modules/mod_disco.md | 9 --------- src/mod_disco.erl | 14 +++----------- test/common/config_parser_helper.erl | 6 ++---- test/config_parser_SUITE.erl | 8 -------- test/config_parser_SUITE_data/modules.toml | 1 - 6 files changed, 7 insertions(+), 49 deletions(-) diff --git a/big_tests/tests/disco_and_caps_SUITE.erl b/big_tests/tests/disco_and_caps_SUITE.erl index 1b2327726b..b95d5432d0 100644 --- a/big_tests/tests/disco_and_caps_SUITE.erl +++ b/big_tests/tests/disco_and_caps_SUITE.erl @@ -32,8 +32,7 @@ caps_test_cases() -> user_can_query_server_caps_via_disco]. extra_feature_test_cases() -> - [user_can_query_extra_domains, - user_can_query_server_info]. + [user_can_query_server_info]. init_per_suite(C) -> instrument_helper:start(instrument_helper:declared_events(mod_disco)), @@ -155,15 +154,6 @@ user_cannot_query_friend_resources_with_unknown_node(Config) -> escalus:assert(is_stanza_from, [BobJid], Stanza) end). -user_can_query_extra_domains(Config) -> - escalus:fresh_story(Config, [{alice, 1}], fun(Alice) -> - Server = escalus_client:server(Alice), - escalus:send(Alice, escalus_stanza:service_discovery(Server)), - Stanza = escalus:wait_for_stanza(Alice), - escalus:assert(has_service, [extra_domain()], Stanza), - escalus:assert(is_stanza_from, [domain()], Stanza) - end). - user_can_query_server_features(Config) -> escalus:fresh_story(Config, [{alice, 1}], fun(Alice) -> Server = escalus_client:server(Alice), @@ -209,8 +199,7 @@ required_modules(disco_with_extra_features) -> [{mod_disco, mod_config(mod_disco, extra_disco_opts())}]. extra_disco_opts() -> - #{extra_domains => [extra_domain()], - server_info => [server_info(abuse, #{}), + #{server_info => [server_info(abuse, #{}), server_info(admin, #{modules => [mod_disco]}), server_info(sales, #{modules => [mod_pubsub]})]}. @@ -219,9 +208,6 @@ get_form_fields(Stanza) -> {element_with_ns, <<"x">>, ?NS_DATA_FORMS}, {element, <<"field">>}]). -extra_domain() -> - <<"eXtra.example.com">>. - server_info(Type, Extra) -> maps:merge(#{name => name(Type), urls => urls(Type)}, Extra). diff --git a/doc/modules/mod_disco.md b/doc/modules/mod_disco.md index 3a7f21b09e..4e59af0802 100644 --- a/doc/modules/mod_disco.md +++ b/doc/modules/mod_disco.md @@ -10,14 +10,6 @@ Implements [XEP-0030: Service Discovery](http://xmpp.org/extensions/xep-0030.htm Strategy to handle incoming stanzas. For details, please refer to [IQ processing policies](../configuration/Modules.md#iq-processing-policies). -### `modules.mod_disco.extra_domains` -* **Syntax:** array of strings, valid domain names -* **Default:** no extra domains -* **Example:** `extra_domains = ["custom_domain"]` - -Adds domains that are not registered with other means to a local item announcement (response to `http://jabber.org/protocol/disco#items` IQ get). -Please note that `mod_disco` doesn't verify these domains, so if no handlers are registered later for them, a client will receive a `service-unavailable` error for every stanza sent to one of these hosts. - ### `modules.mod_disco.server_info` * **Syntax:** array of tables described below * **Default:** no additional server info @@ -50,7 +42,6 @@ will still receive full disco results. ```toml [modules.mod_disco] iqdisc.type = "one_queue" - extra_domains = ["some_domain", "another_domain"] server_info = [ {name = "abuse-address", urls = ["admin@example.com"]}, {name = "friendly-spirits", urls = ["spirit1@localhost", "spirit2@localhost"], modules = ["mod_muc", "mod_disco"]} diff --git a/src/mod_disco.erl b/src/mod_disco.erl index 832c5de6e6..77d592a5b2 100644 --- a/src/mod_disco.erl +++ b/src/mod_disco.erl @@ -91,14 +91,11 @@ iq_handlers() -> -spec config_spec() -> mongoose_config_spec:config_section(). config_spec() -> #section{ - items = #{<<"extra_domains">> => #list{items = #option{type = binary, - validate = domain}}, - <<"server_info">> => #list{items = server_info_spec()}, + items = #{<<"server_info">> => #list{items = server_info_spec()}, <<"users_can_see_hidden_services">> => #option{type = boolean}, <<"iqdisc">> => mongoose_config_spec:iqdisc() }, - defaults = #{<<"extra_domains">> => [], - <<"server_info">> => [], + defaults = #{<<"server_info">> => [], <<"users_can_see_hidden_services">> => true, <<"iqdisc">> => one_queue} }. @@ -229,8 +226,7 @@ disco_local_items(Acc = #{host_type := HostType, from_jid := From, to_jid := To, ReturnHidden = should_return_hidden(HostType, From), Subdomains = get_subdomains(To#jid.lserver), Components = get_external_components(ReturnHidden), - ExtraDomains = get_extra_domains(HostType), - Domains = Subdomains ++ Components ++ ExtraDomains, + Domains = Subdomains ++ Components, {ok, mongoose_disco:add_items([#{jid => Domain} || Domain <- Domains], Acc)}; disco_local_items(Acc, _, _) -> {ok, Acc}. @@ -288,10 +284,6 @@ get_subdomains(LServer) -> get_external_components(ReturnHidden) -> mongoose_component:dirty_get_all_components(ReturnHidden). --spec get_extra_domains(mongooseim:host_type()) -> [jid:lserver()]. -get_extra_domains(HostType) -> - gen_mod:get_module_opt(HostType, ?MODULE, extra_domains). - %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -spec is_presence_subscribed(jid:jid(), jid:jid()) -> boolean(). diff --git a/test/common/config_parser_helper.erl b/test/common/config_parser_helper.erl index 7bb9545810..a9bbbacf13 100644 --- a/test/common/config_parser_helper.erl +++ b/test/common/config_parser_helper.erl @@ -501,8 +501,7 @@ all_modules() -> no_stanzaid_element => true}), mod_disco => mod_config(mod_disco, - #{extra_domains => [<<"some_domain">>, <<"another_domain">>], - server_info => + #{server_info => [#{name => <<"abuse-address">>, urls => [<<"admin@example.com">>]}, #{name => <<"friendly-spirits">>, @@ -885,8 +884,7 @@ default_mod_config(mod_csi) -> default_mod_config(mod_carboncopy) -> #{iqdisc => no_queue}; default_mod_config(mod_disco) -> - #{extra_domains => [], server_info => [], - users_can_see_hidden_services => true, iqdisc => one_queue}; + #{server_info => [], users_can_see_hidden_services => true, iqdisc => one_queue}; default_mod_config(mod_extdisco) -> #{iqdisc => no_queue, service => []}; default_mod_config(mod_global_distrib) -> diff --git a/test/config_parser_SUITE.erl b/test/config_parser_SUITE.erl index 469be40ce7..84308c07ac 100644 --- a/test/config_parser_SUITE.erl +++ b/test/config_parser_SUITE.erl @@ -1565,11 +1565,6 @@ mod_disco(_Config) -> T(<<"users_can_see_hidden_services">>, true)), ?cfgh(P ++ [users_can_see_hidden_services], false, T(<<"users_can_see_hidden_services">>, false)), - %% extra_domains are binaries - ?cfgh(P ++ [extra_domains], [<<"localhost">>, <<"erlang-solutions.com">>], - T(<<"extra_domains">>, [<<"localhost">>, <<"erlang-solutions.com">>])), - ?cfgh(P ++ [extra_domains], [], - T(<<"extra_domains">>, [])), Info = #{<<"name">> => <<"abuse-address">>, <<"urls">> => [<<"admin@example.com">>]}, SpiritUrls = [<<"spirit1@localhost">>, <<"spirit2@localhost">>], @@ -1581,9 +1576,6 @@ mod_disco(_Config) -> <<"modules">> => [<<"mod_muc">>, <<"mod_disco">>]}])), ?errh(T(<<"users_can_see_hidden_services">>, 1)), ?errh(T(<<"users_can_see_hidden_services">>, <<"true">>)), - ?errh(T(<<"extra_domains">>, [<<"user@localhost">>])), - ?errh(T(<<"extra_domains">>, [1])), - ?errh(T(<<"extra_domains">>, <<"domains domains domains">>)), ?errh(T(<<"server_info">>, [Info#{<<"name">> => 1}])), ?errh(T(<<"server_info">>, [Info#{<<"name">> => <<"">>}])), ?errh(T(<<"server_info">>, [Info#{<<"modules">> => <<"roll">>}])), diff --git a/test/config_parser_SUITE_data/modules.toml b/test/config_parser_SUITE_data/modules.toml index 25a572467a..2a7c63e4b8 100644 --- a/test/config_parser_SUITE_data/modules.toml +++ b/test/config_parser_SUITE_data/modules.toml @@ -34,7 +34,6 @@ [modules.mod_disco] iqdisc.type = "one_queue" - extra_domains = ["some_domain", "another_domain"] server_info = [ {name = "abuse-address", urls = ["admin@example.com"]}, {name = "friendly-spirits", urls = ["spirit1@localhost", "spirit2@localhost"], modules = ["mod_muc", "mod_disco"]}