From 16b7a9287bc18f31529ffb1b965e1d7604c140c8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pawe=C5=82=20Chrz=C4=85szcz?= Date: Fri, 19 Nov 2021 16:04:31 +0100 Subject: [PATCH 1/5] Support defaults in TOML sections Default values should be valid and in the already processed form, so only the 'format' step is performed for them. This allows specifying defaults for subsections without having to put them in the raw TOML format. --- include/mongoose_config_spec.hrl | 4 +++- src/config/mongoose_config_parser_toml.erl | 27 +++++++++++++++------- 2 files changed, 22 insertions(+), 9 deletions(-) diff --git a/include/mongoose_config_spec.hrl b/include/mongoose_config_spec.hrl index 0eed1d1127..e948c9276d 100644 --- a/include/mongoose_config_spec.hrl +++ b/include/mongoose_config_spec.hrl @@ -7,7 +7,9 @@ required = [] :: [mongoose_config_parser_toml:toml_key()] | all, validate = any :: mongoose_config_validator:section_validator(), process :: undefined | mongoose_config_parser_toml:list_processor(), - format = default :: mongoose_config_spec:format()}). + format = default :: mongoose_config_spec:format(), + defaults = #{} :: #{mongoose_config_parser_toml:toml_key() => + mongoose_config_parser_toml:config_part()}}). -record(list, {items :: mongoose_config_spec:config_node(), validate = any :: mongoose_config_validator:list_validator(), diff --git a/src/config/mongoose_config_parser_toml.erl b/src/config/mongoose_config_parser_toml.erl index 85e9affcc6..3fc8069c8c 100644 --- a/src/config/mongoose_config_parser_toml.erl +++ b/src/config/mongoose_config_parser_toml.erl @@ -98,10 +98,13 @@ ensure_keys(Keys, Section) -> -spec parse_section(path(), toml_section(), mongoose_config_spec:config_section()) -> [config_part()]. -parse_section(Path, M, #section{items = Items}) -> - lists:flatmap(fun({K, V}) -> - handle([K|Path], V, get_spec_for_key(K, Items)) - end, lists:sort(maps:to_list(M))). +parse_section(Path, M, #section{items = Items, defaults = Defaults}) -> + FilteredDefaults = maps:filter(fun(K, _V) -> not maps:is_key(K, M) end, Defaults), + ProcessedConfig = maps:map(fun(K, V) -> handle([K|Path], V, get_spec_for_key(K, Items)) end, M), + ProcessedDefaults = maps:map(fun(K, V) -> handle_default([K|Path], V, maps:get(K, Items)) end, + FilteredDefaults), + lists:flatmap(fun({_K, ConfigParts}) -> ConfigParts end, + lists:keysort(1, maps:to_list(maps:merge(ProcessedDefaults, ProcessedConfig)))). -spec get_spec_for_key(toml_key(), map()) -> mongoose_config_spec:config_node(). get_spec_for_key(Key, Items) -> @@ -122,19 +125,27 @@ parse_list(Path, L, #list{items = ItemSpec}) -> handle([Key|Path], Elem, ItemSpec) end, L). --spec handle(path(), toml_value(), mongoose_config_spec:config_node()) -> config_part(). +-spec handle(path(), toml_value(), mongoose_config_spec:config_node()) -> [config_part()]. handle(Path, Value, Spec) -> + handle(Path, Value, Spec, [parse, validate, process, format]). + +-spec handle_default(path(), toml_value(), mongoose_config_spec:config_node()) -> [config_part()]. +handle_default(Path, Value, Spec) -> + handle(Path, Value, Spec, [format]). + +-spec handle(path(), toml_value(), mongoose_config_spec:config_node(), [step()]) -> [config_part()]. +handle(Path, Value, Spec, Steps) -> lists:foldl(fun(_, [#{what := _, class := error}] = Error) -> Error; (Step, Acc) -> try_step(Step, Path, Value, Acc, Spec) - end, Value, [parse, validate, process, format]). + end, Value, Steps). -spec handle_step(step(), path(), toml_value(), mongoose_config_spec:config_node()) -> config_part(). handle_step(parse, Path, Value, Spec) -> ParsedValue = case Spec of - #section{} = Spec when is_map(Value) -> + #section{} when is_map(Value) -> check_required_keys(Spec, Value), validate_keys(Spec, Value), parse_section(Path, Value, Spec); @@ -204,7 +215,7 @@ format_spec(#section{format = Format}) -> Format; format_spec(#list{format = Format}) -> Format; format_spec(#option{format = Format}) -> Format. --spec format(path(), config_part(), mongoose_config_spec:format()) -> config_part(). +-spec format(path(), config_part(), mongoose_config_spec:format()) -> [config_part()]. format(Path, KVs, {foreach, Format}) when is_atom(Format) -> Keys = lists:map(fun({K, _}) -> K end, KVs), mongoose_config_validator:validate_list(Keys, unique), From 0cead82915e7d0854539bef88cecaada51453eac Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pawe=C5=82=20Chrz=C4=85szcz?= Date: Fri, 19 Nov 2021 16:08:31 +0100 Subject: [PATCH 2/5] Specify defaults for the 'general' section rdbms_server_type had conflicting defaults, now it is 'generic'; this option needs to be removed anyway. --- include/mongoose.hrl | 6 +++--- src/config/mongoose_config_spec.erl | 17 ++++++++++++++++- src/domain/mongoose_domain_api.erl | 4 ++-- src/ejabberd_app.erl | 2 +- src/ejabberd_c2s.erl | 5 +---- src/ejabberd_ctl.erl | 2 +- src/ejabberd_router.erl | 5 +++-- src/ejabberd_service.erl | 2 +- src/ejabberd_sm.erl | 2 +- src/metrics/mongoose_metrics.erl | 4 ++-- src/mod_register.erl | 2 +- src/rdbms/mongoose_rdbms.erl | 2 +- src/rdbms/mongoose_rdbms_odbc.erl | 2 +- 13 files changed, 34 insertions(+), 21 deletions(-) diff --git a/include/mongoose.hrl b/include/mongoose.hrl index 9a9e09be3c..e255023324 100644 --- a/include/mongoose.hrl +++ b/include/mongoose.hrl @@ -22,10 +22,10 @@ %% If the ejabberd application description isn't loaded, returns atom: undefined -define(MONGOOSE_VERSION, element(2, application:get_key(mongooseim,vsn))). --define(MYHOSTS, mongoose_config:get_opt(hosts, [])). --define(ALL_HOST_TYPES, mongoose_config:get_opt(hosts, []) ++ mongoose_config:get_opt(host_types, [])). +-define(MYHOSTS, mongoose_config:get_opt(hosts)). +-define(ALL_HOST_TYPES, mongoose_config:get_opt(hosts) ++ mongoose_config:get_opt(host_types)). -define(MYNAME, mongoose_config:get_opt(default_server_domain)). --define(MYLANG, mongoose_config:get_opt(language, <<"en">>)). +-define(MYLANG, mongoose_config:get_opt(language)). -define(CONFIG_PATH, "etc/mongooseim.toml"). diff --git a/src/config/mongoose_config_spec.erl b/src/config/mongoose_config_spec.erl index 75e9bdcb55..3665c57b8a 100644 --- a/src/config/mongoose_config_spec.erl +++ b/src/config/mongoose_config_spec.erl @@ -115,7 +115,8 @@ root() -> General = general(), #section{ items = #{<<"general">> => General#section{required = [<<"default_server_domain">>], - process = fun ?MODULE:process_general/1}, + process = fun ?MODULE:process_general/1, + defaults = general_defaults()}, <<"listen">> => listen(), <<"auth">> => auth(), <<"outgoing_pools">> => outgoing_pools(), @@ -226,6 +227,20 @@ general() -> format = none }. +general_defaults() -> + #{<<"loglevel">> => warning, + <<"hosts">> => [], + <<"host_types">> => [], + <<"registration_timeout">> => 600, + <<"language">> => <<"en">>, + <<"all_metrics_are_global">> => false, + <<"sm_backend">> => {mnesia, []}, + <<"rdbms_server_type">> => generic, + <<"mongooseimctl_access_commands">> => [], + <<"routing_modules">> => ejabberd_router:default_routing_modules(), + <<"replaced_wait_timeout">> => 2000, + <<"hide_service_name">> => false}. + ctl_access_rule() -> #section{ items = #{<<"commands">> => #list{items = #option{type = string}}, diff --git a/src/domain/mongoose_domain_api.erl b/src/domain/mongoose_domain_api.erl index e728ff7ceb..d20ae8a833 100644 --- a/src/domain/mongoose_domain_api.erl +++ b/src/domain/mongoose_domain_api.erl @@ -34,7 +34,7 @@ -spec init() -> ok | {error, term()}. init() -> Pairs = get_static_pairs(), - AllowedHostTypes = mongoose_config:get_opt(host_types, []), + AllowedHostTypes = mongoose_config:get_opt(host_types), mongoose_domain_core:start(Pairs, AllowedHostTypes), mongoose_subdomain_core:start(), mongoose_lazy_routing:start(). @@ -177,7 +177,7 @@ check_domain(Domain, HostType) -> %% Domains should be nameprepped using `jid:nameprep' -spec get_static_pairs() -> [pair()]. get_static_pairs() -> - [{H, H} || H <- mongoose_config:get_opt(hosts, [])]. + [{H, H} || H <- mongoose_config:get_opt(hosts)]. -spec register_subdomain(host_type(), subdomain_pattern(), mongoose_packet_handler:t()) -> diff --git a/src/ejabberd_app.erl b/src/ejabberd_app.erl index 56785025de..e0afc767b0 100644 --- a/src/ejabberd_app.erl +++ b/src/ejabberd_app.erl @@ -54,7 +54,7 @@ start(normal, _Args) -> mongoose_service:start(), gen_mod:start(), mongoose_config:start(), - mongoose_logs:set_global_loglevel(mongoose_config:get_opt(loglevel, warning)), + mongoose_logs:set_global_loglevel(mongoose_config:get_opt(loglevel)), mongoose_deprecations:start(), {ok, _} = Sup = ejabberd_sup:start_link(), mongoose_domain_api:init(), diff --git a/src/ejabberd_c2s.erl b/src/ejabberd_c2s.erl index 340b1c4fdb..f439fee24b 100644 --- a/src/ejabberd_c2s.erl +++ b/src/ejabberd_c2s.erl @@ -806,10 +806,7 @@ do_open_session_common(Acc, JID, #state{host_type = HostType, {established, Acc1, NewStateData}. get_replaced_wait_timeout(HostType) -> - mongoose_config:get_opt({replaced_wait_timeout, HostType}, default_replaced_wait_timeout()). - -default_replaced_wait_timeout() -> - 2000. + mongoose_config:get_opt({replaced_wait_timeout, HostType}). -spec session_established(Item :: ejabberd:xml_stream_item(), State :: state()) -> fsm_return(). diff --git a/src/ejabberd_ctl.erl b/src/ejabberd_ctl.erl index 311b646576..6946163cf5 100644 --- a/src/ejabberd_ctl.erl +++ b/src/ejabberd_ctl.erl @@ -247,7 +247,7 @@ process2(Args, Auth, AccessCommands) -> -spec get_accesscommands() -> [char() | tuple()]. get_accesscommands() -> - mongoose_config:get_opt(mongooseimctl_access_commands, []). + mongoose_config:get_opt(mongooseimctl_access_commands). %%----------------------------- diff --git a/src/ejabberd_router.erl b/src/ejabberd_router.erl index 82f8919a7e..cbeb943778 100644 --- a/src/ejabberd_router.erl +++ b/src/ejabberd_router.erl @@ -52,7 +52,8 @@ unregister_component/1, unregister_component/2, unregister_components/1, - unregister_components/2 + unregister_components/2, + default_routing_modules/0 ]). -export([start_link/0]). @@ -509,7 +510,7 @@ code_change(_OldVsn, State, _Extra) -> %%-------------------------------------------------------------------- routing_modules_list() -> - mongoose_config:get_opt(routing_modules, default_routing_modules()). + mongoose_config:get_opt(routing_modules). default_routing_modules() -> [mongoose_router_global, diff --git a/src/ejabberd_service.erl b/src/ejabberd_service.erl index 73e27858e6..c4c209b0f7 100644 --- a/src/ejabberd_service.erl +++ b/src/ejabberd_service.erl @@ -521,7 +521,7 @@ unregister_routes(StateData) -> ejabberd_router:unregister_components(Routes). get_routes(#state{host=Subdomain, is_subdomain=true}) -> - Hosts = mongoose_config:get_opt(hosts, []), + Hosts = mongoose_config:get_opt(hosts), component_routes(Subdomain, Hosts); get_routes(#state{host=Host}) -> [Host]. diff --git a/src/ejabberd_sm.erl b/src/ejabberd_sm.erl index a55eec6165..d7df968dcf 100644 --- a/src/ejabberd_sm.erl +++ b/src/ejabberd_sm.erl @@ -492,7 +492,7 @@ node_cleanup(Acc, Node) -> %%-------------------------------------------------------------------- -spec init(_) -> {ok, state()}. init([]) -> - {Backend, Opts} = mongoose_config:get_opt(sm_backend, {mnesia, []}), + {Backend, Opts} = mongoose_config:get_opt(sm_backend), ejabberd_sm_backend:init([{backend, Backend}|Opts]), ets:new(sm_iqtable, [named_table, protected, {read_concurrency, true}]), diff --git a/src/metrics/mongoose_metrics.erl b/src/metrics/mongoose_metrics.erl index 638d19cf5e..43f29a87ce 100644 --- a/src/metrics/mongoose_metrics.erl +++ b/src/metrics/mongoose_metrics.erl @@ -189,12 +189,12 @@ remove_all_metrics() -> -spec all_metrics_are_global() -> boolean(). all_metrics_are_global() -> - mongoose_config:get_opt(all_metrics_are_global, false). + mongoose_config:get_opt(all_metrics_are_global). pick_by_all_metrics_are_global(WhenGlobal, WhenNot) -> case all_metrics_are_global() of true -> WhenGlobal; - _ -> WhenNot + false -> WhenNot end. -spec name_by_all_metrics_are_global(HostType :: mongooseim:host_type() | global, diff --git a/src/mod_register.erl b/src/mod_register.erl index a6c95e51e8..b76eb4728e 100644 --- a/src/mod_register.erl +++ b/src/mod_register.erl @@ -412,7 +412,7 @@ send_registration_notification(JIDBin, Domain, Body) -> check_timeout(undefined) -> true; check_timeout(Source) -> - Timeout = mongoose_config:get_opt(registration_timeout, 600), + Timeout = mongoose_config:get_opt(registration_timeout), case is_integer(Timeout) of true -> Priority = -(erlang:system_time(second)), diff --git a/src/rdbms/mongoose_rdbms.erl b/src/rdbms/mongoose_rdbms.erl index d243d3aadf..34481fcb17 100644 --- a/src/rdbms/mongoose_rdbms.erl +++ b/src/rdbms/mongoose_rdbms.erl @@ -744,7 +744,7 @@ db_engine(_HostType) -> %% Also, this parameter should not be global, but pool-name parameterized -spec db_type() -> mssql | generic. db_type() -> - case mongoose_config:get_opt(rdbms_server_type, undefined) of + case mongoose_config:get_opt(rdbms_server_type) of mssql -> mssql; _ -> generic end. diff --git a/src/rdbms/mongoose_rdbms_odbc.erl b/src/rdbms/mongoose_rdbms_odbc.erl index 3daf3c10d8..308454a362 100644 --- a/src/rdbms/mongoose_rdbms_odbc.erl +++ b/src/rdbms/mongoose_rdbms_odbc.erl @@ -239,7 +239,7 @@ map_param(Param, Mapper) -> -spec server_type() -> atom(). server_type() -> - mongoose_config:get_opt(rdbms_server_type, generic). + mongoose_config:get_opt(rdbms_server_type). -spec escape_binary(ServerType :: atom(), binary()) -> iodata(). escape_binary(pgsql, Bin) -> From 87a3e45ad917a3ceea85163ebe35efe0ca40c2d8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pawe=C5=82=20Chrz=C4=85szcz?= Date: Mon, 22 Nov 2021 09:53:54 +0100 Subject: [PATCH 3/5] Set default options required by small tests Setting them explicitly makes it clear which ones are required, even though it is a bit more verbose. --- test/component_reg_SUITE.erl | 8 ++++++-- test/ejabberd_c2s_SUITE_mocks.erl | 3 ++- test/ejabberd_hooks_SUITE.erl | 4 +++- test/ejabberd_sm_SUITE.erl | 18 +++++++++++------- test/gen_hook_SUITE.erl | 2 ++ test/mongoose_cleanup_SUITE.erl | 7 +++++++ test/mongoose_config_SUITE.erl | 26 +++++++++++++++++++++----- test/mongoose_deprecations_SUITE.erl | 2 +- test/mongoose_rdbms_SUITE.erl | 8 ++++++-- test/mongoose_wpool_SUITE.erl | 10 +++++++--- test/mongooseim_metrics_SUITE.erl | 1 + test/muc_light_SUITE.erl | 3 ++- test/privacy_SUITE.erl | 3 ++- test/roster_SUITE.erl | 8 ++++++-- test/translate_SUITE.erl | 10 ---------- 15 files changed, 77 insertions(+), 36 deletions(-) diff --git a/test/component_reg_SUITE.erl b/test/component_reg_SUITE.erl index 0d97e2fe51..c8ead535ee 100644 --- a/test/component_reg_SUITE.erl +++ b/test/component_reg_SUITE.erl @@ -13,7 +13,7 @@ init_per_suite(C) -> {ok, _} = application:ensure_all_started(jid), ok = mnesia:create_schema([node()]), ok = mnesia:start(), - mongoose_config:set_opt(routing_modules, [xmpp_router_a, xmpp_router_b, xmpp_router_c]), + [mongoose_config:set_opt(Key, Value) || {Key, Value} <- opts()], meck:new(mongoose_domain_api, [no_link]), meck:expect(mongoose_domain_api, get_host_type, fun(_) -> {error, not_found} end), @@ -30,9 +30,13 @@ end_per_suite(_C) -> mnesia:stop(), mnesia:delete_schema([node()]), meck:unload(), - mongoose_config:unset_opt(routing_modules), + [mongoose_config:unset_opt(Key) || {Key, _Value} <- opts()], ok. +opts() -> + [{all_metrics_are_global, false}, + {routing_modules, [xmpp_router_a, xmpp_router_b, xmpp_router_c]}]. + registering(_C) -> Dom = <<"aaa.bbb.com">>, ejabberd_router:register_component(Dom, mongoose_packet_handler:new(?MODULE)), diff --git a/test/ejabberd_c2s_SUITE_mocks.erl b/test/ejabberd_c2s_SUITE_mocks.erl index 30b915533e..2785859c44 100644 --- a/test/ejabberd_c2s_SUITE_mocks.erl +++ b/test/ejabberd_c2s_SUITE_mocks.erl @@ -61,7 +61,8 @@ teardown() -> opts() -> [{max_fsm_queue, 100}, - {default_server_domain, <<"localhost">>}]. + {default_server_domain, <<"localhost">>}, + {language, <<"en">>}]. mcred_get(dummy_creds, username) -> <<"cosmic_hippo">>; mcred_get(dummy_creds, auth_module) -> auuuthmodule. diff --git a/test/ejabberd_hooks_SUITE.erl b/test/ejabberd_hooks_SUITE.erl index 641c03e729..dc19574b28 100644 --- a/test/ejabberd_hooks_SUITE.erl +++ b/test/ejabberd_hooks_SUITE.erl @@ -25,10 +25,12 @@ all() -> ]. init_per_suite(C) -> - Res = application:ensure_all_started(exometer_core), + application:ensure_all_started(exometer_core), + mongoose_config:set_opt(all_metrics_are_global, false), C. end_per_suite(_C) -> + mongoose_config:unset_opt(all_metrics_are_global), application:stop(exometer_core). a_module_fun_can_be_added(_) -> diff --git a/test/ejabberd_sm_SUITE.erl b/test/ejabberd_sm_SUITE.erl index 5ef8e25def..6a6f084f44 100644 --- a/test/ejabberd_sm_SUITE.erl +++ b/test/ejabberd_sm_SUITE.erl @@ -107,7 +107,7 @@ end_per_testcase(_, Config) -> clean_sessions(Config), terminate_sm(), unload_meck(), - unset_opts(). + unset_opts(Config). open_session(C) -> {Sid, USR} = generate_random_user(<<"localhost">>), @@ -596,8 +596,16 @@ terminate_sm() -> gen_server:stop(ejabberd_sm). set_opts(Config) -> - mongoose_config:set_opt(hosts, [<<"localhost">>]), - mongoose_config:set_opt(sm_backend, sm_backend(?config(backend, Config))). + [mongoose_config:set_opt(Key, Value) || {Key, Value} <- opts(Config)]. + +unset_opts(Config) -> + [mongoose_config:unset_opt(Key) || {Key, _Value} <- opts(Config)]. + +opts(Config) -> + [{hosts, [<<"localhost">>]}, + {host_types, []}, + {all_metrics_are_global, false}, + {sm_backend, sm_backend(?config(backend, Config))}]. sm_backend(ejabberd_sm_redis) -> {redis, [{pool_size, 3}, {worker_config, [{host, "localhost"}, {port, 6379}]}]}; @@ -610,7 +618,3 @@ set_meck() -> meck:expect(ejabberd_commands, register_commands, fun(_) -> ok end), meck:expect(ejabberd_commands, unregister_commands, fun(_) -> ok end), ok. - -unset_opts() -> - mongoose_config:unset_opt(hosts), - mongoose_config:unset_opt(sm_backend). diff --git a/test/gen_hook_SUITE.erl b/test/gen_hook_SUITE.erl index f69bac6871..54b210ddea 100644 --- a/test/gen_hook_SUITE.erl +++ b/test/gen_hook_SUITE.erl @@ -24,9 +24,11 @@ all() -> init_per_suite(Config) -> application:ensure_all_started(exometer_core), + mongoose_config:set_opt(all_metrics_are_global, false), Config. end_per_suite(Config) -> + mongoose_config:unset_opt(all_metrics_are_global), application:stop(exometer_core), Config. diff --git a/test/mongoose_cleanup_SUITE.erl b/test/mongoose_cleanup_SUITE.erl index 6706582b45..022edd1db3 100644 --- a/test/mongoose_cleanup_SUITE.erl +++ b/test/mongoose_cleanup_SUITE.erl @@ -37,13 +37,20 @@ init_per_suite(Config) -> {ok, _} = application:ensure_all_started(jid), ok = mnesia:create_schema([node()]), ok = mnesia:start(), + [mongoose_config:set_opt(Key, Value) || {Key, Value} <- opts()], Config. end_per_suite(Config) -> + [mongoose_config:unset_opt(Key) || {Key, _Value} <- opts()], mnesia:stop(), mnesia:delete_schema([node()]), Config. +opts() -> + [{hosts, []}, + {host_types, []}, + {all_metrics_are_global, false}]. + init_per_testcase(T, Config) -> {ok, _HooksServer} = gen_hook:start_link(), ok = mongoose_lazy_routing:start(), diff --git a/test/mongoose_config_SUITE.erl b/test/mongoose_config_SUITE.erl index 27aff5db41..3f557904c7 100644 --- a/test/mongoose_config_SUITE.erl +++ b/test/mongoose_config_SUITE.erl @@ -107,17 +107,33 @@ cluster_load_from_file(Config) -> check_loaded_config(State) -> Opts = lists:sort(mongoose_config_parser:state_to_opts(State)), ExpectedOpts = minimal_config_opts(), - ?assertEqual(ExpectedOpts, Opts), - [?assertEqual(Val, mongoose_config:get_opt(Key)) || {{_, Key}, Val} <- ExpectedOpts]. + ?assertEqual([{local_config, Key, Val} || {Key, Val} <- ExpectedOpts], Opts), + [?assertEqual(Val, mongoose_config:get_opt(Key)) || {Key, Val} <- ExpectedOpts]. check_removed_config() -> Opts = minimal_config_opts(), ?assertError(badarg, mongoose_config:config_state()), - [?assertError(badarg, mongoose_config:get_opt(Key)) || {{_, Key}, _} <- Opts]. + [?assertError(badarg, mongoose_config:get_opt(Key)) || {Key, _} <- Opts]. minimal_config_opts() -> - [{local_config, default_server_domain, <<"localhost">>}, - {local_config, hosts, [<<"localhost">>]}]. + [{all_metrics_are_global, false}, + {default_server_domain, <<"localhost">>}, + {hide_service_name, false}, + {host_types, []}, + {hosts, [<<"localhost">>]}, + {language, <<"en">>}, + {loglevel, warning}, + {mongooseimctl_access_commands, []}, + {rdbms_server_type, generic}, + {registration_timeout, 600}, + {routing_modules, [mongoose_router_global, + mongoose_router_localdomain, + mongoose_router_external_localnode, + mongoose_router_external, + mongoose_router_dynamic_domains, + ejabberd_s2s]}, + {sm_backend, {mnesia, []}}, + {{replaced_wait_timeout, <<"localhost">>}, 2000}]. start_slave_node(Config) -> SlaveNode = do_start_slave_node(), diff --git a/test/mongoose_deprecations_SUITE.erl b/test/mongoose_deprecations_SUITE.erl index 8af6cd72b2..2acc2d1862 100644 --- a/test/mongoose_deprecations_SUITE.erl +++ b/test/mongoose_deprecations_SUITE.erl @@ -21,7 +21,7 @@ all() -> init_per_suite(C) -> C. - + end_per_suite(C) -> C. diff --git a/test/mongoose_rdbms_SUITE.erl b/test/mongoose_rdbms_SUITE.erl index 6b24ba6388..c875bffdc0 100644 --- a/test/mongoose_rdbms_SUITE.erl +++ b/test/mongoose_rdbms_SUITE.erl @@ -133,10 +133,14 @@ meck_unload_rand() -> meck:unload(rand). set_opts() -> - mongoose_config:set_opt(max_fsm_queue, 1024). + [mongoose_config:set_opt(Key, Value) || {Key, Value} <- opts()]. unset_opts() -> - mongoose_config:unset_opt(max_fsm_queue). + [mongoose_config:unset_opt(Key) || {Key, _Value} <- opts()]. + +opts() -> + [{all_metrics_are_global, false}, + {max_fsm_queue, 1024}]. meck_db(odbc) -> meck:new(eodbc, [no_link]), diff --git a/test/mongoose_wpool_SUITE.erl b/test/mongoose_wpool_SUITE.erl index e3538af935..0530c7de60 100644 --- a/test/mongoose_wpool_SUITE.erl +++ b/test/mongoose_wpool_SUITE.erl @@ -48,7 +48,7 @@ all() -> init_per_suite(Config) -> ok = meck:new(wpool, [no_link, passthrough]), ok = meck:new(mongoose_wpool, [no_link, passthrough]), - mongoose_config:set_opt(hosts, [<<"a.com">>, <<"b.com">>, <<"c.eu">>]), + [mongoose_config:set_opt(Key, Value) || {Key, Value} <- opts()], Self = self(), spawn(fun() -> register(test_helper, self()), @@ -62,9 +62,13 @@ init_per_suite(Config) -> end_per_suite(Config) -> meck:unload(wpool), whereis(test_helper) ! stop, - mongoose_config:unset_opt(hosts), + [mongoose_config:unset_opt(Key) || {Key, _Value} <- opts()], Config. +opts() -> + [{hosts, [<<"a.com">>, <<"b.com">>, <<"c.eu">>]}, + {host_types, []}]. + init_per_testcase(_Case, Config) -> cleanup_pools(), Config. @@ -171,7 +175,7 @@ global_pool_is_used_by_default(_C) -> Pools = [{generic, global, default, [], []}, {generic, <<"a.com">>, default, [], []}], StartRes = mongoose_wpool:start_configured_pools(Pools), - + ?assertMatch([_, _], StartRes), meck:expect(wpool, call, fun(Name, _Req, _Strat, _Timeout) -> Name end), ?assertEqual(mongoose_wpool:make_pool_name(generic, <<"a.com">>, default), mongoose_wpool:call(generic, <<"a.com">>, default, request)), diff --git a/test/mongooseim_metrics_SUITE.erl b/test/mongooseim_metrics_SUITE.erl index 100815044d..e4c35c425c 100644 --- a/test/mongooseim_metrics_SUITE.erl +++ b/test/mongooseim_metrics_SUITE.erl @@ -159,6 +159,7 @@ wait_for_update({ok, [{count,0}]}, N) -> opts(Group) -> [{hosts, [<<"localhost">>]}, + {host_types, []}, {all_metrics_are_global, Group =:= all_metrics_are_global}]. get_reporters_cfg(Port) -> diff --git a/test/muc_light_SUITE.erl b/test/muc_light_SUITE.erl index 7dc9ee2cad..5fc7ba8e73 100644 --- a/test/muc_light_SUITE.erl +++ b/test/muc_light_SUITE.erl @@ -54,8 +54,8 @@ init_per_testcase(codec_calls, Config) -> meck_mongoose_subdomain_core(), ok = mnesia:create_schema([node()]), ok = mnesia:start(), + mongoose_config:set_opt(all_metrics_are_global, false), {ok, _} = application:ensure_all_started(exometer_core), - ets:new(local_config, [named_table]), gen_hook:start_link(), ejabberd_router:start_link(), mim_ct_sup:start_link(ejabberd_sup), @@ -70,6 +70,7 @@ init_per_testcase(_, Config) -> end_per_testcase(codec_calls, Config) -> mod_muc_light:stop(?DOMAIN), + mongoose_config:unset_opt(all_metrics_are_global), mnesia:stop(), mnesia:delete_schema([node()]), application:stop(exometer_core), diff --git a/test/privacy_SUITE.erl b/test/privacy_SUITE.erl index f49dc7916f..4ade256fa3 100644 --- a/test/privacy_SUITE.erl +++ b/test/privacy_SUITE.erl @@ -37,15 +37,16 @@ init_per_suite(C) -> ok = mnesia:create_schema([node()]), ok = mnesia:start(), {ok, _} = application:ensure_all_started(exometer_core), + mongoose_config:set_opt(all_metrics_are_global, false), C. init_per_testcase(_, C) -> - catch ets:new(local_config, [named_table]), gen_hook:start_link(), mod_privacy:start(<<"localhost">>, []), C. end_per_suite(_C) -> + mongoose_config:unset_opt(all_metrics_are_global), mnesia:stop(), mnesia:delete_schema([node()]), application:stop(exometer_core), diff --git a/test/roster_SUITE.erl b/test/roster_SUITE.erl index 6e61f419f0..be7205183a 100644 --- a/test/roster_SUITE.erl +++ b/test/roster_SUITE.erl @@ -45,14 +45,20 @@ init_per_suite(C) -> meck:expect(gen_iq_handler, remove_iq_handler_for_domain, fun(_, _, _) -> ok end), meck:new(mongoose_domain_api, [no_link]), meck:expect(mongoose_domain_api, get_domain_host_type, fun(_) -> {ok, host_type()} end), + [mongoose_config:set_opt(Key, Value) || {Key, Value} <- opts()], C. end_per_suite(C) -> + [mongoose_config:unset_opt(Key) || {Key, _Value} <- opts()], meck:unload(), mnesia:stop(), mnesia:delete_schema([node()]), C. +opts() -> + [{hosts, []}, + {all_metrics_are_global, false}]. + init_per_testcase(_TC, C) -> init_ets(), gen_hook:start_link(), @@ -158,12 +164,10 @@ assert_state_old(Subscription, Ask) -> ?assertEqual(Ask, Rentry#roster.ask). init_ets() -> - catch ets:new(local_config, [named_table]), catch ets:new(mongoose_services, [named_table]), ok. delete_ets() -> - catch ets:delete(local_config), catch ets:delete(mongoose_services), ok. diff --git a/test/translate_SUITE.erl b/test/translate_SUITE.erl index 7351d7940f..cdd15e7ab6 100644 --- a/test/translate_SUITE.erl +++ b/test/translate_SUITE.erl @@ -4,7 +4,6 @@ all() -> [ - test_undefined_translation, test_english_translation, test_polish_translation, test_portuguese_translation @@ -15,15 +14,6 @@ end_per_testcase(_, C) -> mongoose_config:unset_opt(language), C. -test_undefined_translation(_Config) -> - %% given - no language set, defaults to English - given_loaded_translations(), - %% then - ?assertEqual(<<"undef">>, translate:translate(<<"en">>, <<"undef">>)), - ?assertEqual(<<"undef2">>, translate:translate(<<"klingon">>, <<"undef2">>)), - - ok. - test_english_translation(_Config) -> %% given given_default_language(<<"en">>), From a2a2fcbabf5cbbdc095845137f9da0bbcd6b9b28 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pawe=C5=82=20Chrz=C4=85szcz?= Date: Fri, 19 Nov 2021 16:10:31 +0100 Subject: [PATCH 4/5] Add tests for defaults in the 'general' section To make it easier, the 'parse' function was extended with the 'without' option, that prevents 'hosts' and 'default_server_domain' from being inserted automatically. --- test/config_parser_SUITE.erl | 76 +++++++++++++++++++----------------- 1 file changed, 40 insertions(+), 36 deletions(-) diff --git a/test/config_parser_SUITE.erl b/test/config_parser_SUITE.erl index 2a7b6b6ced..cfe02dbe75 100644 --- a/test/config_parser_SUITE.erl +++ b/test/config_parser_SUITE.erl @@ -343,36 +343,33 @@ host_types_unsupported_auth_methods_and_modules(Config) -> %% tests: general loglevel(_Config) -> + ?cfg(loglevel, warning, #{}), % default ?cfg(loglevel, debug, #{<<"general">> => #{<<"loglevel">> => <<"debug">>}}), ?err(#{<<"general">> => #{<<"loglevel">> => <<"bebug">>}}), %% make sure non-host options are not accepted in host_config ?err(host_config(#{<<"general">> => #{<<"loglevel">> => <<"debug">>}})). hosts(_Config) -> - ?cfg(hosts, [<<"host1">>], #{<<"general">> => #{<<"hosts">> => [<<"host1">>]}}), - GenM = #{<<"default_server_domain">> => <<"some.host">>}, - M = GenM#{<<"hosts">> => [<<"host1">>, <<"host2">>], - <<"host_types">> => []}, - assert_options([{hosts, [<<"host1">>, <<"host2">>]}, - {host_types, []}, - {default_server_domain, <<"some.host">>}], - mongoose_config_parser_toml:parse(#{<<"general">> => M})), + ?cfg(hosts, [], % default + #{<<"general">> => #{<<"host_types">> => [<<"type1">>]}, without => [<<"hosts">>]}), + ?cfg(hosts, [<<"host1">>], + #{<<"general">> => #{<<"hosts">> => [<<"host1">>]}}), + ?cfg(hosts, [<<"host1">>, <<"host2">>], + #{<<"general">> => #{<<"hosts">> => [<<"host1">>, <<"host2">>]}}), ?err(#{<<"general">> => #{<<"hosts">> => [<<"what is this?">>]}}), ?err(#{<<"general">> => #{<<"hosts">> => [<<>>]}}), ?err(#{<<"general">> => #{<<"hosts">> => [<<"host1">>, <<"host1">>]}}), - %% either hosts or host_types must be provided - assert_error(mongoose_config_parser_toml:parse(#{<<"general">> => #{}})), - assert_error(mongoose_config_parser_toml:parse(#{<<"general">> => GenM})), - assert_error(mongoose_config_parser_toml:parse(#{<<"general">> => - GenM#{<<"host">> => [], - <<"host_types">> => []}})), - assert_error(mongoose_config_parser_toml:parse(#{<<"general">> => - GenM#{<<"host">> => []}})), - assert_error(mongoose_config_parser_toml:parse(#{<<"general">> => - GenM#{<<"host_types">> => []}})). + %% at least one host or host_type must be provided + ?err(#{<<"general">> => #{}, without => [<<"hosts">>]}), + ?err(#{<<"general">> => #{<<"hosts">> => []}}), + ?err(#{<<"general">> => #{<<"host_types">> => []}, without => [<<"hosts">>]}), + ?err(#{<<"general">> => #{<<"hosts">> => [], <<"host_types">> => []}}). host_types(_Config) -> - ?cfg(host_types, [<<"type 1">>], #{<<"general">> => #{<<"host_types">> => [<<"type 1">>]}}), + ?cfg(host_types, [], #{}), % default + ?cfg([{host_types, [<<"type 1">>]}, + {hosts, []}], + #{<<"general">> => #{<<"host_types">> => [<<"type 1">>]}, without => [<<"hosts">>]}), ?cfg([{host_types, [<<"type 1">>, <<"type 2">>]}, {hosts, []}], #{<<"general">> => #{<<"host_types">> => [<<"type 1">>, <<"type 2">>], @@ -386,17 +383,13 @@ host_types(_Config) -> default_server_domain(_Config) -> ?cfg(default_server_domain, <<"host1">>, #{<<"general">> => #{<<"default_server_domain">> => <<"host1">>}}), - GenM = #{<<"hosts">> => [<<"host1">>, <<"host2">>]}, - M = GenM#{<<"default_server_domain">> => <<"some.host">>}, - assert_options([{hosts, [<<"host1">>, <<"host2">>]}, - {default_server_domain, <<"some.host">>}], - mongoose_config_parser_toml:parse(#{<<"general">> => M})), ?err(#{<<"general">> => #{<<"default_server_domain">> => <<"what is this?">>}}), ?err(#{<<"general">> => #{<<"default_server_domain">> => <<>>}}), %% default_server_domain must be provided - assert_error(mongoose_config_parser_toml:parse(#{<<"general">> => GenM})). + ?err(#{without => [<<"default_server_domain">>]}). registration_timeout(_Config) -> + ?cfg(registration_timeout, 600, #{}), % default ?cfg(registration_timeout, infinity, #{<<"general">> => #{<<"registration_timeout">> => <<"infinity">>}}), ?cfg(registration_timeout, 300, @@ -404,14 +397,17 @@ registration_timeout(_Config) -> ?err(#{<<"general">> => #{<<"registration_timeout">> => 0}}). language(_Config) -> - ?cfg(language, <<"en">>, #{<<"general">> => #{<<"language">> => <<"en">>}}), + ?cfg(language, <<"en">>, #{}), % default + ?cfg(language, <<"pl">>, #{<<"general">> => #{<<"language">> => <<"pl">>}}), ?err(#{<<"general">> => #{<<"language">> => <<>>}}). all_metrics_are_global(_Config) -> + ?cfg(all_metrics_are_global, false, #{}), % default ?cfg(all_metrics_are_global, true, #{<<"general">> => #{<<"all_metrics_are_global">> => true}}), ?err(#{<<"general">> => #{<<"all_metrics_are_global">> => <<"true">>}}). sm_backend(_Config) -> + ?cfg(sm_backend, {mnesia, []}, #{}), % default ?cfg(sm_backend, {mnesia, []}, #{<<"general">> => #{<<"sm_backend">> => <<"mnesia">>}}), ?cfg(sm_backend, {redis, []}, #{<<"general">> => #{<<"sm_backend">> => <<"redis">>}}), ?err(#{<<"general">> => #{<<"sm_backend">> => <<"amnesia">>}}). @@ -426,6 +422,7 @@ http_server_name(_Config) -> ?err(#{<<"general">> => #{<<"http_server_name">> => #{}}}). rdbms_server_type(_Config) -> + ?cfg(rdbms_server_type, generic, #{}), % default ?cfg(rdbms_server_type, mssql, #{<<"general">> => #{<<"rdbms_server_type">> => <<"mssql">>}}), ?cfg(rdbms_server_type, pgsql, #{<<"general">> => #{<<"rdbms_server_type">> => <<"pgsql">>}}), ?err(#{<<"general">> => #{<<"rdbms_server_type">> => <<"nosql">>}}). @@ -435,6 +432,7 @@ route_subdomains(_Config) -> ?errh(#{<<"general">> => #{<<"route_subdomains">> => <<"c2s">>}}). mongooseimctl_access_commands(_Config) -> + ?cfg(mongooseimctl_access_commands, [], #{}), % default AccessRule = #{<<"commands">> => [<<"join_cluster">>], <<"argument_restrictions">> => #{<<"node">> => <<"mim1@host1">>}}, ?cfg(mongooseimctl_access_commands, [{local, ["join_cluster"], [{node, "mim1@host1"}]}], @@ -456,17 +454,20 @@ mongooseimctl_access_commands(_Config) -> [<<"none">>]}}}}). routing_modules(_Config) -> + ?cfg(routing_modules, ejabberd_router:default_routing_modules(), #{}), % default ?cfg(routing_modules, [mongoose_router_global, mongoose_router_localdomain], #{<<"general">> => #{<<"routing_modules">> => [<<"mongoose_router_global">>, <<"mongoose_router_localdomain">>]}}), ?err(#{<<"general">> => #{<<"routing_modules">> => [<<"moongoose_router_global">>]}}). replaced_wait_timeout(_Config) -> + ?cfg({replaced_wait_timeout, global}, 2000, #{}), % global default ?cfgh(replaced_wait_timeout, 1000, #{<<"general">> => #{<<"replaced_wait_timeout">> => 1000}}), ?errh(#{<<"general">> => #{<<"replaced_wait_timeout">> => 0}}). hide_service_name(_Config) -> - ?cfg(hide_service_name, false, #{<<"general">> => #{<<"hide_service_name">> => false}}), + ?cfg(hide_service_name, false, #{}), % default + ?cfg(hide_service_name, true, #{<<"general">> => #{<<"hide_service_name">> => true}}), ?err(#{<<"general">> => #{<<"hide_service_name">> => []}}). %% tests: listen @@ -3024,13 +3025,12 @@ assert_error_host_or_global(RawConfig) -> host_config(Config) -> #{<<"host_config">> => [Config#{<<"host_type">> => ?HOST_TYPE}]}. --spec parse(mongoose_config_parser_toml:toml_section()) -> [mongoose_config_parser_toml:config()]. +-spec parse(map()) -> [mongoose_config_parser_toml:config()]. parse(M0) -> - %% 'hosts' (or 'host_types') and `default_server_domain` options are mandatory. - %% this function does the following things: - %% 1) plugs that mandatory options with dummy values (if required). - %% 2) executes parsing. - %% DummyDomainName value must be unique to avoid accidental config keys removal. + %% As 'hosts' (or 'host_types') and 'default_server_domain' options are mandatory, + %% this function inserts them with dummy values if they are missing. + %% To prevent the insertion, add a 'without' option to the map, e.g. without => [<<"hosts">>] + %% The resulting map is then passed to the TOML config parser. DummyDomainName = <<"dummy.domain.name">>, M = maybe_insert_dummy_domain(M0, DummyDomainName), mongoose_config_parser_toml:parse(M). @@ -3038,9 +3038,13 @@ parse(M0) -> maybe_insert_dummy_domain(M, DomainName) -> DummyGenM = #{<<"default_server_domain">> => DomainName, <<"hosts">> => [DomainName]}, - OldGenM = maps:get(<<"general">>, M, #{}), - NewGenM = maps:merge(DummyGenM, OldGenM), - M#{<<"general">> => NewGenM}. + {FilteredGenM, RawConfig} = case maps:take(without, M) of + {Keys, Cfg} -> {maps:without(Keys, DummyGenM), Cfg}; + error -> {DummyGenM, M} + end, + OldGenM = maps:get(<<"general">>, RawConfig, #{}), + NewGenM = maps:merge(FilteredGenM, OldGenM), + RawConfig#{<<"general">> => NewGenM}. %% helpers for testing individual options From c75b417c761f96292a8bde5d8cc492eb8c977ffd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pawe=C5=82=20Chrz=C4=85szcz?= Date: Fri, 19 Nov 2021 16:11:24 +0100 Subject: [PATCH 5/5] Update expected TOML options with defaults --- .../host_types.options | 21 +++++- .../miscellaneous.options | 10 ++- test/config_parser_SUITE_data/modules.options | 23 ++++-- .../mongooseim-pgsql.options | 71 +++++++++++-------- .../outgoing_pools.options | 19 ++++- .../config_parser_SUITE_data/s2s_only.options | 17 ++++- 6 files changed, 123 insertions(+), 38 deletions(-) diff --git a/test/config_parser_SUITE_data/host_types.options b/test/config_parser_SUITE_data/host_types.options index 90f58fb82e..ad4bf81cee 100644 --- a/test/config_parser_SUITE_data/host_types.options +++ b/test/config_parser_SUITE_data/host_types.options @@ -1,8 +1,20 @@ +{local_config,all_metrics_are_global,false}. {local_config,default_server_domain,<<"localhost">>}. +{local_config,hide_service_name,false}. {local_config,host_types, - [<<"this is host type">>,<<"some host type">>,<<"another host type">>, - <<"yet another host type">>]}. + [<<"this is host type">>,<<"some host type">>, + <<"another host type">>,<<"yet another host type">>]}. {local_config,hosts,[<<"localhost">>]}. +{local_config,language,<<"en">>}. +{local_config,loglevel,warning}. +{local_config,mongooseimctl_access_commands,[]}. +{local_config,rdbms_server_type,generic}. +{local_config,registration_timeout,600}. +{local_config,routing_modules, + [mongoose_router_global,mongoose_router_localdomain, + mongoose_router_external_localnode,mongoose_router_external, + mongoose_router_dynamic_domains,ejabberd_s2s]}. +{local_config,sm_backend,{mnesia,[]}}. {local_config,{auth_method,<<"another host type">>},[]}. {local_config,{auth_method,<<"localhost">>},[test3]}. {local_config,{auth_method,<<"some host type">>},[test2]}. @@ -18,3 +30,8 @@ {local_config,{modules,<<"some host type">>},[]}. {local_config,{modules,<<"this is host type">>},[]}. {local_config,{modules,<<"yet another host type">>},[{test_mim_module1,[]}]}. +{local_config,{replaced_wait_timeout,<<"another host type">>},2000}. +{local_config,{replaced_wait_timeout,<<"localhost">>},2000}. +{local_config,{replaced_wait_timeout,<<"some host type">>},2000}. +{local_config,{replaced_wait_timeout,<<"this is host type">>},2000}. +{local_config,{replaced_wait_timeout,<<"yet another host type">>},2000}. diff --git a/test/config_parser_SUITE_data/miscellaneous.options b/test/config_parser_SUITE_data/miscellaneous.options index 42da767c85..03c8473e35 100644 --- a/test/config_parser_SUITE_data/miscellaneous.options +++ b/test/config_parser_SUITE_data/miscellaneous.options @@ -1,7 +1,10 @@ -{local_config,default_server_domain,<<"localhost">>}. -{local_config,hosts,[<<"localhost">>,<<"anonymous.localhost">>]}. +{local_config,all_metrics_are_global,false}. {local_config,cowboy_server_name,"Apache"}. +{local_config,default_server_domain,<<"localhost">>}. {local_config,hide_service_name,true}. +{local_config,host_types,[]}. +{local_config,hosts,[<<"localhost">>,<<"anonymous.localhost">>]}. +{local_config,language,<<"en">>}. {local_config,listen, [{{5280,{0,0,0,0},tcp}, ejabberd_cowboy, @@ -13,9 +16,11 @@ {password,"secret"}, {shaper_rule,fast}]}]}]}, {transport_options,[{max_connections,1024},{num_acceptors,10}]}]}]}. +{local_config,loglevel,warning}. {local_config,mongooseimctl_access_commands, [{local,["join_cluster"],[{node,"mongooseim@prime"}]}]}. {local_config,rdbms_server_type,mssql}. +{local_config,registration_timeout,600}. {local_config,routing_modules, [mongoose_router_global,mongoose_router_localdomain]}. {local_config,services, @@ -24,6 +29,7 @@ {periodic_report,10800000}, report, {tracking_id,"UA-123456789"}]}]}. +{local_config,sm_backend,{mnesia,[]}}. {local_config,{allow_multiple_connections,<<"anonymous.localhost">>},true}. {local_config,{allow_multiple_connections,<<"localhost">>},true}. {local_config,{anonymous_protocol,<<"anonymous.localhost">>},sasl_anon}. diff --git a/test/config_parser_SUITE_data/modules.options b/test/config_parser_SUITE_data/modules.options index d2b81d0e66..9176f4a33b 100644 --- a/test/config_parser_SUITE_data/modules.options +++ b/test/config_parser_SUITE_data/modules.options @@ -1,5 +1,18 @@ +{local_config,all_metrics_are_global,false}. {local_config,default_server_domain,<<"localhost">>}. +{local_config,hide_service_name,false}. +{local_config,host_types,[]}. {local_config,hosts,[<<"localhost">>,<<"dummy_host">>]}. +{local_config,language,<<"en">>}. +{local_config,loglevel,warning}. +{local_config,mongooseimctl_access_commands,[]}. +{local_config,rdbms_server_type,generic}. +{local_config,registration_timeout,600}. +{local_config,routing_modules, + [mongoose_router_global,mongoose_router_localdomain, + mongoose_router_external_localnode,mongoose_router_external, + mongoose_router_dynamic_domains,ejabberd_s2s]}. +{local_config,sm_backend,{mnesia,[]}}. {local_config, {modules,<<"dummy_host">>}, [{mod_jingle_sip, @@ -197,8 +210,8 @@ {host,{fqdn,<<"muclight.example.com">>}}, {equal_occupants,true}, {config_schema, - [{<<"roomname">>,<<"The Room">>,roomname,binary}, - {<<"display-lines">>,30,display_lines,integer}]}, + [{<<"display-lines">>,30,display_lines,integer}, + {<<"roomname">>,<<"The Room">>,roomname,binary}]}, {blocking,false}, {all_can_invite,true}, {all_can_configure,true}]}, @@ -461,8 +474,8 @@ {host,{fqdn,<<"muclight.example.com">>}}, {equal_occupants,true}, {config_schema, - [{<<"roomname">>,<<"The Room">>,roomname,binary}, - {<<"display-lines">>,30,display_lines,integer}]}, + [{<<"display-lines">>,30,display_lines,integer}, + {<<"roomname">>,<<"The Room">>,roomname,binary}]}, {blocking,false}, {all_can_invite,true}, {all_can_configure,true}]}, @@ -528,3 +541,5 @@ {sns_host,"sns.eu-west-1.amazonaws.com"}]}]}]}, {mod_carboncopy,[{iqdisc,no_queue}]}, {mod_version,[{os_info,true}]}]}. +{local_config,{replaced_wait_timeout,<<"dummy_host">>},2000}. +{local_config,{replaced_wait_timeout,<<"localhost">>},2000}. diff --git a/test/config_parser_SUITE_data/mongooseim-pgsql.options b/test/config_parser_SUITE_data/mongooseim-pgsql.options index 88fed90b1b..7273a2ca4a 100644 --- a/test/config_parser_SUITE_data/mongooseim-pgsql.options +++ b/test/config_parser_SUITE_data/mongooseim-pgsql.options @@ -1,33 +1,10 @@ -{local_config,{acl,local,global},[{user_regexp,<<>>}]}. +{local_config,all_metrics_are_global,false}. {local_config,default_server_domain,<<"localhost">>}. -{local_config,hosts,[<<"localhost">>,<<"anonymous.localhost">>,<<"localhost.bis">>]}. +{local_config,hide_service_name,false}. +{local_config,host_types,[]}. +{local_config,hosts, + [<<"localhost">>,<<"anonymous.localhost">>,<<"localhost.bis">>]}. {local_config,language,<<"en">>}. -{local_config,sm_backend,{mnesia,[]}}. -{local_config,{access,c2s,global},[{deny,blocked},{allow,all}]}. -{local_config,{access,c2s_shaper,global},[{none,admin},{normal,all}]}. -{local_config,{access,local,global},[{allow,local}]}. -{local_config,{access,mam_get_prefs,global},[{default,all}]}. -{local_config,{access,mam_get_prefs_global_shaper,global},[{mam_global_shaper,all}]}. -{local_config,{access,mam_get_prefs_shaper,global},[{mam_shaper,all}]}. -{local_config,{access,mam_lookup_messages,global},[{default,all}]}. -{local_config,{access,mam_lookup_messages_global_shaper,global}, - [{mam_global_shaper,all}]}. -{local_config,{access,mam_lookup_messages_shaper,global},[{mam_shaper,all}]}. -{local_config,{access,mam_set_prefs,global},[{default,all}]}. -{local_config,{access,mam_set_prefs_global_shaper,global},[{mam_global_shaper,all}]}. -{local_config,{access,mam_set_prefs_shaper,global},[{mam_shaper,all}]}. -{local_config,{access,max_user_offline_messages,global},[{5000,admin},{100,all}]}. -{local_config,{access,max_user_sessions,global},[{10,all}]}. -{local_config,{access,muc,global},[{allow,all}]}. -{local_config,{access,muc_admin,global},[{allow,admin}]}. -{local_config,{access,muc_create,global},[{allow,local}]}. -{local_config,{access,register,global},[{allow,all}]}. -{local_config,{access,s2s_shaper,global},[{fast,all}]}. -{local_config,{shaper,fast,global},{maxrate,50000}}. -{local_config,{shaper,mam_global_shaper,global},{maxrate,1000}}. -{local_config,{shaper,mam_shaper,global},{maxrate,1}}. -{local_config,{shaper,normal,global},{maxrate,1000}}. -{local_config,all_metrics_are_global,false}. {local_config,listen, [{{5222,{0,0,0,0},tcp}, ejabberd_c2s, @@ -119,6 +96,7 @@ {shaper_rule,fast}]}]}. {local_config,loglevel,warning}. {local_config,max_fsm_queue,1000}. +{local_config,mongooseimctl_access_commands,[]}. {local_config,outgoing_pools, [{rdbms,global,default, [{workers,5}], @@ -131,7 +109,12 @@ {verify,verify_peer}]}]}}]}, {redis,<<"localhost">>,global_distrib,[{workers,10}],[]}]}. {local_config,outgoing_s2s_port,5299}. +{local_config,rdbms_server_type,generic}. {local_config,registration_timeout,infinity}. +{local_config,routing_modules, + [mongoose_router_global,mongoose_router_localdomain, + mongoose_router_external_localnode,mongoose_router_external, + mongoose_router_dynamic_domains,ejabberd_s2s]}. {local_config,s2s_certfile,"tools/ssl/mongooseim/server.pem"}. {local_config,s2s_use_starttls,optional}. {local_config,services, @@ -141,6 +124,7 @@ stanza,stats]}]}, {service_mongoose_system_metrics, [{initial_report,300000},{periodic_report,10800000}]}]}. +{local_config,sm_backend,{mnesia,[]}}. {local_config,{allow_multiple_connections,<<"anonymous.localhost">>},true}. {local_config,{anonymous_protocol,<<"anonymous.localhost">>},both}. {local_config,{auth_method,<<"anonymous.localhost">>},[anonymous]}. @@ -224,7 +208,38 @@ {mod_muc_commands,[]}, {mod_stream_management,[]}, {mod_carboncopy,[]}]}. +{local_config,{replaced_wait_timeout,<<"anonymous.localhost">>},2000}. +{local_config,{replaced_wait_timeout,<<"localhost">>},2000}. +{local_config,{replaced_wait_timeout,<<"localhost.bis">>},2000}. {local_config,{s2s_addr,<<"fed1">>},"127.0.0.1"}. {local_config,{s2s_default_policy,<<"anonymous.localhost">>},allow}. {local_config,{s2s_default_policy,<<"localhost">>},allow}. {local_config,{s2s_default_policy,<<"localhost.bis">>},allow}. +{local_config,{access,c2s,global},[{deny,blocked},{allow,all}]}. +{local_config,{access,c2s_shaper,global},[{none,admin},{normal,all}]}. +{local_config,{access,local,global},[{allow,local}]}. +{local_config,{access,mam_get_prefs,global},[{default,all}]}. +{local_config,{access,mam_get_prefs_global_shaper,global}, + [{mam_global_shaper,all}]}. +{local_config,{access,mam_get_prefs_shaper,global},[{mam_shaper,all}]}. +{local_config,{access,mam_lookup_messages,global},[{default,all}]}. +{local_config,{access,mam_lookup_messages_global_shaper,global}, + [{mam_global_shaper,all}]}. +{local_config,{access,mam_lookup_messages_shaper,global},[{mam_shaper,all}]}. +{local_config,{access,mam_set_prefs,global},[{default,all}]}. +{local_config,{access,mam_set_prefs_global_shaper,global}, + [{mam_global_shaper,all}]}. +{local_config,{access,mam_set_prefs_shaper,global},[{mam_shaper,all}]}. +{local_config,{access,max_user_offline_messages,global}, + [{5000,admin},{100,all}]}. +{local_config,{access,max_user_sessions,global},[{10,all}]}. +{local_config,{access,muc,global},[{allow,all}]}. +{local_config,{access,muc_admin,global},[{allow,admin}]}. +{local_config,{access,muc_create,global},[{allow,local}]}. +{local_config,{access,register,global},[{allow,all}]}. +{local_config,{access,s2s_shaper,global},[{fast,all}]}. +{local_config,{acl,local,global},[{user_regexp,<<>>}]}. +{local_config,{shaper,fast,global},{maxrate,50000}}. +{local_config,{shaper,mam_global_shaper,global},{maxrate,1000}}. +{local_config,{shaper,mam_shaper,global},{maxrate,1}}. +{local_config,{shaper,normal,global},{maxrate,1000}}. diff --git a/test/config_parser_SUITE_data/outgoing_pools.options b/test/config_parser_SUITE_data/outgoing_pools.options index fb5e074fed..1f6cc64b7e 100644 --- a/test/config_parser_SUITE_data/outgoing_pools.options +++ b/test/config_parser_SUITE_data/outgoing_pools.options @@ -1,5 +1,12 @@ +{local_config,all_metrics_are_global,false}. {local_config,default_server_domain,<<"localhost">>}. -{local_config,hosts,[<<"localhost">>,<<"anonymous.localhost">>,<<"localhost.bis">>]}. +{local_config,hide_service_name,false}. +{local_config,host_types,[]}. +{local_config,hosts, + [<<"localhost">>,<<"anonymous.localhost">>,<<"localhost.bis">>]}. +{local_config,language,<<"en">>}. +{local_config,loglevel,warning}. +{local_config,mongooseimctl_access_commands,[]}. {local_config,outgoing_pools, [{cassandra,global,default,[], [{keyspace,"big_mongooseim"}, @@ -46,3 +53,13 @@ {keyfile,"path/to/key.pem"}, {verify,verify_peer}]}, {cacertfile,"path/to/cacert.pem"}]}]}. +{local_config,rdbms_server_type,generic}. +{local_config,registration_timeout,600}. +{local_config,routing_modules, + [mongoose_router_global,mongoose_router_localdomain, + mongoose_router_external_localnode,mongoose_router_external, + mongoose_router_dynamic_domains,ejabberd_s2s]}. +{local_config,sm_backend,{mnesia,[]}}. +{local_config,{replaced_wait_timeout,<<"anonymous.localhost">>},2000}. +{local_config,{replaced_wait_timeout,<<"localhost">>},2000}. +{local_config,{replaced_wait_timeout,<<"localhost.bis">>},2000}. diff --git a/test/config_parser_SUITE_data/s2s_only.options b/test/config_parser_SUITE_data/s2s_only.options index 0b0d515f5f..fa7eea771e 100644 --- a/test/config_parser_SUITE_data/s2s_only.options +++ b/test/config_parser_SUITE_data/s2s_only.options @@ -1,16 +1,31 @@ +{local_config,all_metrics_are_global,false}. {local_config,default_server_domain,<<"localhost">>}. +{local_config,hide_service_name,false}. +{local_config,host_types,[]}. {local_config,hosts,[<<"localhost">>,<<"dummy_host">>]}. +{local_config,language,<<"en">>}. +{local_config,loglevel,warning}. +{local_config,mongooseimctl_access_commands,[]}. {local_config,outgoing_s2s_families,[ipv4,ipv6]}. {local_config,outgoing_s2s_port,5299}. {local_config,outgoing_s2s_timeout,10000}. +{local_config,rdbms_server_type,generic}. +{local_config,registration_timeout,600}. +{local_config,routing_modules, + [mongoose_router_global,mongoose_router_localdomain, + mongoose_router_external_localnode,mongoose_router_external, + mongoose_router_dynamic_domains,ejabberd_s2s]}. {local_config,s2s_certfile,"tools/ssl/mongooseim/server.pem"}. {local_config,s2s_ciphers,"TLSv1.2:TLSv1.3"}. {local_config,s2s_dns_options,[{retries,1},{timeout,30}]}. {local_config,s2s_use_starttls,optional}. +{local_config,sm_backend,{mnesia,[]}}. {local_config,{domain_certfile,<<"example.com">>},"/path/to/example_com.pem"}. {local_config,{domain_certfile,<<"example.org">>},"/path/to/example_org.pem"}. +{local_config,{replaced_wait_timeout,<<"dummy_host">>},2000}. +{local_config,{replaced_wait_timeout,<<"localhost">>},2000}. {local_config,{s2s_addr,<<"fed1">>},"127.0.0.1"}. -{local_config,{s2s_addr,<<"fed2">>},{"127.0.0.1", 8765}}. +{local_config,{s2s_addr,<<"fed2">>},{"127.0.0.1",8765}}. {local_config,{s2s_default_policy,<<"dummy_host">>},allow}. {local_config,{s2s_default_policy,<<"localhost">>},allow}. {local_config,{s2s_max_retry_delay,<<"dummy_host">>},30}.