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

Add OTP-26 to CI #284

Merged
merged 3 commits into from
May 17, 2023
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Make it compatible with OTP-26
* Don't call `prim_inet` port directly
* Add `verify=verify_none` option in SSL tests
  • Loading branch information
seriyps committed May 17, 2023
commit 71a6b904398b26c37021f79a4f793643f323121c
15 changes: 12 additions & 3 deletions src/epgsql_sock.erl
Original file line number Diff line number Diff line change
@@ -488,6 +488,15 @@ send_multi(#state{mod = Mod, sock = Sock}, List) ->
end, List)).

do_send(gen_tcp, Sock, Bin) ->
gen_tcp_send(Sock, Bin);
do_send(ssl, Sock, Bin) ->
ssl:send(Sock, Bin).

-if(?OTP_RELEASE >= 26).
gen_tcp_send(Sock, Bin) ->
gen_tcp:send(Sock, Bin).
-else.
gen_tcp_send(Sock, Bin) ->
%% Why not gen_tcp:send/2?
%% See https://github.com/rabbitmq/rabbitmq-common/blob/v3.7.4/src/rabbit_writer.erl#L367-L384
%% Since `epgsql' uses `{active, true}' socket option by-default, it may potentially quickly
@@ -496,15 +505,15 @@ do_send(gen_tcp, Sock, Bin) ->
%% `{active, true}' is still the default.
%%
%% Because we use `inet' driver directly, we also have `handle_info({inet_reply, ...`
%% This `gen_tcp:send/2' problem have been solved in OTP-26, so this hack is no longer needed.
try erlang:port_command(Sock, Bin) of
true ->
ok
catch
error:_Error ->
{error, einval}
end;
do_send(ssl, Sock, Bin) ->
ssl:send(Sock, Bin).
end.
-endif.

loop(#state{data = Data, handler = Handler, subproto_state = Repl} = State) ->
case epgsql_wire:decode_message(Data) of
9 changes: 6 additions & 3 deletions test/epgsql_SUITE.erl
Original file line number Diff line number Diff line change
@@ -306,14 +306,15 @@ connect_with_ssl(Config) ->
{ok, _Cols, [{true}]} = Module:equery(C, "select ssl_is_used()")
end,
"epgsql_test",
[{ssl, true}]).
[{ssl, true}, {ssl_opts, [{verify, verify_none}]}]).

cancel_query_for_connection_with_ssl(Config) ->
Module = ?config(module, Config),
{Host, Port} = epgsql_ct:connection_data(Config),
Module = ?config(module, Config),
Args2 = [ {port, Port}, {database, "epgsql_test_db1"}
| [ {ssl, true}
, {ssl_opts, [{verify, verify_none}]}
, {timeout, 1000} ]
],
{ok, C} = Module:connect(Host, "epgsql_test", Args2),
@@ -377,7 +378,8 @@ connect_with_client_cert(Config) ->
end,
"epgsql_test_cert",
[{ssl, true}, {ssl_opts, [{keyfile, File("client.key")},
{certfile, File("client.crt")}]}]).
{certfile, File("client.crt")},
{verify, verify_none}]}]).

connect_with_invalid_client_cert(Config) ->
{Host, Port} = epgsql_ct:connection_data(Config),
@@ -407,6 +409,7 @@ connect_with_invalid_client_cert(Config) ->
ssl_opts =>
[{keyfile, File("bad-client.key")},
{certfile, File("bad-client.crt")},
{verify, verify_none},
%% TLS-1.3 seems to connect fine, but then sends alert asynchronously
{versions, ['tlsv1.2']}
]}
@@ -1649,7 +1652,7 @@ incremental_sock_active_n_ssl(Config) ->
?assertEqual(10241, length(Rows))
end,
"epgsql_test",
[{ssl, true}, {socket_active, 2}]).
[{ssl, true}, {ssl_opts, [{verify, verify_none}]}, {socket_active, 2}]).
-else.
%% {active, N} for SSL is only supported on OTP-21+
incremental_sock_active_n_ssl(_Config) ->
4 changes: 3 additions & 1 deletion test/epgsql_replication_SUITE.erl
Original file line number Diff line number Diff line change
@@ -72,7 +72,9 @@ replication_sync_active_n_socket(Config) ->

-ifdef(OTP_RELEASE).
replication_async_active_n_ssl(Config) ->
replication_test_run(Config, self(), [{socket_active, 1}, {ssl, require}]).
replication_test_run(Config, self(), [{socket_active, 1},
{ssl, require},
{ssl_opts, [{verify, verify_none}]}]).
-else.
%% {active, N} for SSL is only supported on OTP-21+
replication_async_active_n_ssl(Config) ->