Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use maps for mongoose_wpool options #3645

Merged
merged 17 commits into from
May 13, 2022
6 changes: 2 additions & 4 deletions big_tests/test.config
Original file line number Diff line number Diff line change
Expand Up @@ -310,9 +310,8 @@
scope = \"global\"
workers = 5
connection.port = 3636
connection.rootdn = \"cn=admin,dc=esl,dc=com\"
connection.root_dn = \"cn=admin,dc=esl,dc=com\"
connection.password = \"mongooseim_secret\"
connection.encrypt = \"tls\"
connection.tls.versions = [\"tlsv1.2\"]
connection.tls.verify_peer = true
connection.tls.cacertfile = \"priv/ssl/cacert.pem\"
Expand All @@ -322,7 +321,6 @@
scope = \"global\"
workers = 5
connection.port = 3636
connection.encrypt = \"tls\"
connection.tls.versions = [\"tlsv1.2\"]
connection.tls.verify_peer = true
connection.tls.cacertfile = \"priv/ssl/cacert.pem\"
Expand Down Expand Up @@ -369,7 +367,7 @@
[outgoing_pools.cassandra.default]
scope = \"global\"
workers = 20
connection.servers = [{ip_address = \"localhost\", port = 9142}]
connection.servers = [{host = \"localhost\", port = 9142}]
connection.tls.cacertfile = \"priv/ssl/cacert.pem\"
connection.tls.verify_peer = true
[outgoing_pools.elastic.default]
Expand Down
13 changes: 5 additions & 8 deletions big_tests/tests/mod_event_pusher_http_SUITE.erl
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@

-compile([export_all, nowarn_export_all]).

-include_lib("escalus/include/escalus.hrl").
-include_lib("common_test/include/ct.hrl").
-include_lib("eunit/include/eunit.hrl").

-define(ETS_TABLE, mod_event_pusher_http).
Expand All @@ -24,7 +22,7 @@

-import(domain_helper, [host_type/0]).

-import(config_parser_helper, [mod_config/2, mod_event_pusher_http_handler/0]).
-import(config_parser_helper, [config/2, mod_config/2, mod_event_pusher_http_handler/0]).

%%%===================================================================
%%% Suite configuration
Expand Down Expand Up @@ -170,14 +168,13 @@ get_prefix(Config) ->
get_prefix(GroupName).

start_pool() ->
HTTPOpts = #{server => http_notifications_host(), path_prefix => "/", request_timeout => 2000},
PoolOpts = #{strategy => available_worker, workers => 5},
ejabberd_node_utils:call_fun(mongoose_wpool, start_configured_pools,
[[#{type => http, scope => global, tag => http_pool,
opts => PoolOpts, conn_opts => HTTPOpts}]]).
ConnOpts = #{host => http_notifications_host(), request_timeout => 2000},
Pool = config([outgoing_pools, http, http_pool], #{opts => PoolOpts, conn_opts => ConnOpts}),
[{ok, _Pid}] = rpc(mim(), mongoose_wpool, start_configured_pools, [[Pool]]).

stop_pool() ->
ejabberd_node_utils:call_fun(mongoose_wpool, stop, [http, global, http_pool]).
rpc(mim(), mongoose_wpool, stop, [http, global, http_pool]).

set_modules(Config0, ExtraHandlerOpts) ->
Config = dynamic_modules:save_modules(host_type(), Config0),
Expand Down
18 changes: 6 additions & 12 deletions big_tests/tests/mod_event_pusher_rabbit_SUITE.erl
Original file line number Diff line number Diff line change
Expand Up @@ -44,15 +44,8 @@
-define(CHAT_MSG_RECV_TOPIC, <<"custom_chat_msg_recv_topic">>).
-define(GROUP_CHAT_MSG_SENT_TOPIC, <<"custom_group_chat_msg_sent_topic">>).
-define(GROUP_CHAT_MSG_RECV_TOPIC, <<"custom_group_chat_msg_recv_topic">>).
-define(WPOOL_CFG, #{type => rabbit, scope => host, tag => event_pusher,
opts => #{workers => 20, strategy => best_worker, call_timeout => 5000},
conn_opts => #{confirms_enabled => false,
amqp_host => "localhost",
amqp_port => 5672,
amqp_username => "guest",
amqp_password => "guest",
max_worker_queue_len => 1000}
}).
-define(WPOOL_CFG, #{scope => host,
opts => #{workers => 20, strategy => best_worker, call_timeout => 5000}}).
-define(IF_EXCHANGE_EXISTS_RETRIES, 30).
-define(WAIT_FOR_EXCHANGE_INTERVAL, 100). % ms

Expand Down Expand Up @@ -113,10 +106,10 @@ suite() ->
%%--------------------------------------------------------------------

init_per_suite(Config) ->
start_rabbit_wpool(domain()),
{ok, _} = application:ensure_all_started(amqp_client),
case is_rabbitmq_available() of
true ->
start_rabbit_wpool(domain()),
{ok, _} = application:ensure_all_started(amqp_client),
muc_helper:load_muc(),
escalus:init_per_suite(Config);
false ->
Expand Down Expand Up @@ -621,7 +614,8 @@ start_rabbit_wpool(Host) ->

start_rabbit_wpool(Host, WpoolConfig) ->
rpc(mim(), mongoose_wpool, ensure_started, []),
rpc(mim(), mongoose_wpool, start_configured_pools, [[WpoolConfig], [Host]]).
Pool = config([outgoing_pools, rabbit, event_pusher], WpoolConfig),
[{ok, _Pid}] = rpc(mim(), mongoose_wpool, start_configured_pools, [[Pool], [Host]]).

stop_rabbit_wpool({Pool, Host, Tag}) ->
rpc(mim(), mongoose_wpool, stop, [Pool, Host, Tag]);
Expand Down
12 changes: 6 additions & 6 deletions big_tests/tests/muc_SUITE.erl
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
-module(muc_SUITE).
-compile([export_all, nowarn_export_all]).

-include_lib("escalus/include/escalus.hrl").
-include_lib("escalus/include/escalus_xmlns.hrl").
-include_lib("common_test/include/ct.hrl").
-include_lib("eunit/include/eunit.hrl").
Expand Down Expand Up @@ -55,7 +54,7 @@

-import(domain_helper, [host_type/0, domain/0]).
-import(mongoose_helper, [backup_and_set_config_option/3, restore_config_option/2]).
-import(config_parser_helper, [default_mod_config/1]).
-import(config_parser_helper, [config/2, default_mod_config/1]).

-define(PASSWORD, <<"pa5sw0rd">>).
-define(SUBJECT, <<"subject">>).
Expand Down Expand Up @@ -373,10 +372,11 @@ init_per_group(disco_rsm_with_offline, Config) ->
init_per_group(G, Config) when G =:= http_auth_no_server;
G =:= http_auth ->
PoolOpts = #{strategy => available_worker, workers => 5},
HTTPOpts = #{server => "http://localhost:8080", path_prefix => "/muc/auth/", request_timeout => 2000},
[{ok, _}] = ejabberd_node_utils:call_fun(mongoose_wpool, start_configured_pools,
[[#{type => http, scope => global, tag => muc_http_auth_test,
opts => PoolOpts, conn_opts => HTTPOpts}]]),
ConnOpts = #{host => "http://localhost:8080", path_prefix => <<"/muc/auth/">>,
request_timeout => 2000},
Pool = config([outgoing_pools, http, muc_http_auth_test],
#{opts => PoolOpts, conn_opts => ConnOpts}),
[{ok, _Pid}] = rpc(mim(), mongoose_wpool, start_configured_pools, [[Pool]]),
case G of
http_auth -> http_helper:start(8080, "/muc/auth/check_password", fun handle_http_auth/1);
_ -> ok
Expand Down
17 changes: 6 additions & 11 deletions big_tests/tests/push_http_SUITE.erl
Original file line number Diff line number Diff line change
@@ -1,17 +1,13 @@
-module(push_http_SUITE).
-compile([export_all, nowarn_export_all]).

-include_lib("exml/include/exml.hrl").
-include_lib("escalus/include/escalus.hrl").
-include_lib("common_test/include/ct.hrl").
-include_lib("eunit/include/eunit.hrl").
-include_lib("escalus/include/escalus_xmlns.hrl").

-define(ETS_TABLE, push_http).

-import(push_helper, [http_notifications_port/0, http_notifications_host/0]).
-import(domain_helper, [domain/0]).
-import(config_parser_helper, [mod_event_pusher_http_handler/0]).
-import(config_parser_helper, [config/2, mod_event_pusher_http_handler/0]).

%%--------------------------------------------------------------------
%% Suite configuration
Expand Down Expand Up @@ -173,14 +169,13 @@ check_default_format(From, To, Body, Msg) ->

start_pool() ->
PoolOpts = #{strategy => random_worker, call_timeout => 5000, workers => 10},
HTTPOpts = #{path_prefix => "/", http_opts => [], server => http_notifications_host(),
request_timeout => 5000},
Pool = #{type => http, scope => host, tag => http_pool, opts => PoolOpts, conn_opts => HTTPOpts},
ejabberd_node_utils:call_fun(mongoose_wpool, start_configured_pools,
[[Pool], [<<"localhost">>]]).
ConnOpts = #{host => http_notifications_host(), request_timeout => 5000},
Pool = config([outgoing_pools, http, http_pool],
#{scope => host, opts => PoolOpts, conn_opts => ConnOpts}),
[{ok, _Pid}] = rpc(mongoose_wpool, start_configured_pools, [[Pool], [<<"localhost">>]]).

stop_pool() ->
ejabberd_node_utils:call_fun(mongoose_wpool, stop, [http, <<"localhost">>, http_pool]).
rpc(mongoose_wpool, stop, [http, <<"localhost">>, http_pool]).

setup_modules() ->
{Mod, Code} = rpc(dynamic_compile, from_string, [custom_module_code()]),
Expand Down
10 changes: 3 additions & 7 deletions big_tests/tests/push_integration_SUITE.erl
Original file line number Diff line number Diff line change
Expand Up @@ -126,17 +126,13 @@ init_per_suite(Config) ->
catch mongoose_push_mock:stop(),
mongoose_push_mock:start(Config),
Port = mongoose_push_mock:port(),

PoolOpts = #{strategy => available_worker, workers => 20},
HTTPOpts = #{server => "https://localhost:" ++ integer_to_list(Port), path_prefix => "/",
request_timeout => 2000},
rpc(?RPC_SPEC, mongoose_wpool, start_configured_pools,
[[#{type => http, scope => global, tag => mongoose_push_http, opts => PoolOpts,
conn_opts => HTTPOpts}]]),
ConnOpts = #{host => "https://localhost:" ++ integer_to_list(Port), request_timeout => 2000},
Pool = config([outgoing_pools, http, mongoose_push_http], #{opts => PoolOpts, conn_opts => ConnOpts}),
[{ok, _Pid}] = rpc(?RPC_SPEC, mongoose_wpool, start_configured_pools, [[Pool]]),
ConfigWithModules = dynamic_modules:save_modules(domain(), Config),
escalus:init_per_suite(ConfigWithModules).


end_per_suite(Config) ->
escalus_fresh:clean(),
rpc(?RPC_SPEC, mongoose_wpool, stop, [http, global, mongoose_push_http]),
Expand Down
17 changes: 6 additions & 11 deletions big_tests/tests/push_pubsub_SUITE.erl
Original file line number Diff line number Diff line change
@@ -1,15 +1,12 @@
-module(push_pubsub_SUITE).
-compile([export_all, nowarn_export_all]).
-include_lib("escalus/include/escalus.hrl").
-include_lib("common_test/include/ct.hrl").
-include_lib("eunit/include/eunit.hrl").
-include_lib("escalus/include/escalus_xmlns.hrl").
-include_lib("exml/include/exml.hrl").
-include("push_helper.hrl").

-import(distributed_helper, [subhost_pattern/1]).

-import(domain_helper, [domain/0]).
-import(config_parser_helper, [config/2]).

%%--------------------------------------------------------------------
%% Suite configuration
Expand Down Expand Up @@ -78,16 +75,14 @@ init_per_testcase(CaseName, Config) ->
MongoosePushMockPort = setup_mock_rest(),

%% Start HTTP pool
HTTPOpts = #{server => "http://localhost:" ++ integer_to_list(MongoosePushMockPort),
path_prefix => "/",
request_timeout => 2000},
PoolOpts = #{strategy => available_worker, workers => 20},
rpc(mongoose_wpool, start_configured_pools,
[[#{type => http, scope => global, tag => mongoose_push_http,
opts => PoolOpts, conn_opts => HTTPOpts}]]),
ConnOpts = #{host => "http://localhost:" ++ integer_to_list(MongoosePushMockPort),
request_timeout => 2000},
Pool = config([outgoing_pools, http, mongoose_push_http],
#{opts => PoolOpts, conn_opts => ConnOpts}),
[{ok, _Pid}] = rpc(mongoose_wpool, start_configured_pools, [[Pool]]),
escalus:init_per_testcase(CaseName, Config).


end_per_testcase(CaseName, Config) ->
rpc(mongoose_wpool, stop, [http, global, mongoose_push_http]),
teardown_mock_rest(),
Expand Down
Loading