Skip to content

Commit

Permalink
fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
Paweł Chrząszcz committed May 11, 2022
1 parent 7f26d7c commit f1a209c
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 24 deletions.
4 changes: 2 additions & 2 deletions big_tests/tests/mod_event_pusher_http_SUITE.erl
Original file line number Diff line number Diff line change
Expand Up @@ -171,10 +171,10 @@ start_pool() ->
PoolOpts = #{strategy => available_worker, workers => 5},
ConnOpts = #{host => http_notifications_host(), request_timeout => 2000},
Pool = config([outgoing_pools, http, http_pool], #{opts => PoolOpts, conn_opts => ConnOpts}),
ejabberd_node_utils:call_fun(mongoose_wpool, start_configured_pools, [[Pool]]).
[{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
14 changes: 4 additions & 10 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 @@ -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
2 changes: 1 addition & 1 deletion big_tests/tests/muc_SUITE.erl
Original file line number Diff line number Diff line change
Expand Up @@ -376,7 +376,7 @@ init_per_group(G, Config) when G =:= http_auth_no_server;
request_timeout => 2000},
Pool = config([outgoing_pools, http, muc_http_auth_test],
#{opts => PoolOpts, conn_opts => ConnOpts}),
[{ok, _}] = ejabberd_node_utils:call_fun(mongoose_wpool, start_configured_pools, [[Pool]]),
[{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
14 changes: 7 additions & 7 deletions src/rdbms/mongoose_rdbms_mysql.erl
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,8 @@ unescape_binary(Bin) when is_binary(Bin) ->

-spec connect(options(), QueryTimeout :: non_neg_integer()) ->
{ok, Connection :: term()} | {error, Reason :: any()}.
connect(Settings, QueryTimeout) ->
case mysql:start_link([{query_timeout, QueryTimeout} | db_opts(Settings)]) of
connect(Options, QueryTimeout) ->
case mysql:start_link([{query_timeout, QueryTimeout} | db_opts(Options)]) of
{ok, Ref} ->
mysql:query(Ref, <<"set names 'utf8mb4';">>),
mysql:query(Ref, <<"SET SESSION query_cache_type=1;">>),
Expand Down Expand Up @@ -75,12 +75,12 @@ execute(Connection, StatementRef, Params, _Timeout) ->

-spec db_opts(options()) -> [mysql:option()].
db_opts(Options) ->
[{found_rows, true} | lists:flatmap(fun process_opt/1, maps:to_list(Options))].
FilteredOpts = maps:with([host, port, database, username, password, tls], Options),
[{found_rows, true} | lists:map(fun process_opt/1, maps:to_list(FilteredOpts))].

process_opt({tls, TLSOpts}) -> [{ssl, TLSOpts}];
process_opt({username, UserName}) -> [{user, UserName}];
process_opt({K, V}) when K =:= host; K =:= port; K =:= password, K =:= database -> [{K, V}];
process_opt(_) -> [].
process_opt({tls, TLSOpts}) -> {ssl, TLSOpts};
process_opt({username, UserName}) -> {user, UserName};
process_opt(Opt) -> Opt.

%% @doc Convert MySQL query result to Erlang RDBMS result formalism
-spec mysql_to_rdbms(mysql:query_result(), Conn :: term()) -> mongoose_rdbms:query_result().
Expand Down
4 changes: 0 additions & 4 deletions test/config_parser_SUITE.erl
Original file line number Diff line number Diff line change
Expand Up @@ -3156,10 +3156,6 @@ compare_nodes([outgoing_pools] = P, V1, V2) ->
compare_nodes([outgoing_pools, I, conn_opts, K], V1, V2)
when is_integer(I), K =:= http_opts orelse K =:= tls ->
compare_unordered_lists(V1, V2);
compare_nodes([{auth_method, _}], V1, V2) when is_atom(V1) ->
?eq([V1], V2);
compare_nodes([{s2s_addr, _}], {_, _, _, _} = IP1, IP2) ->
?eq(inet:ntoa(IP1), IP2);
compare_nodes(Node, V1, V2) when is_map(V1), is_map(V2) ->
compare_maps(V1, V2, fun({K1, MV1}, {K2, MV2}) ->
?eq(K1, K2),
Expand Down

0 comments on commit f1a209c

Please sign in to comment.