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 7628efc
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 14 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
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 7628efc

Please sign in to comment.