|
@@ -173,6 +173,16 @@ end_per_group(_GroupName, _Config) ->
|
|
{routine, _} | _]
|
|
{routine, _} | _]
|
|
}}).
|
|
}}).
|
|
|
|
|
|
|
|
+-define(QUERY_CANCELED, {error, #error{
|
|
|
|
+ severity = error,
|
|
|
|
+ code = <<"57014">>,
|
|
|
|
+ codename = query_canceled,
|
|
|
|
+ message = <<"canceling statement due to user request">>,
|
|
|
|
+ extra = [{file, <<"postgres.c">>},
|
|
|
|
+ {line, _},
|
|
|
|
+ {routine, _} | _]
|
|
|
|
+ }}).
|
|
|
|
+
|
|
%% From uuid.erl in http://gitorious.org/avtobiff/erlang-uuid
|
|
%% From uuid.erl in http://gitorious.org/avtobiff/erlang-uuid
|
|
uuid_to_bin_string(<<U0:32, U1:16, U2:16, U3:16, U4:48>>) ->
|
|
uuid_to_bin_string(<<U0:32, U1:16, U2:16, U3:16, U4:48>>) ->
|
|
iolist_to_binary(io_lib:format(
|
|
iolist_to_binary(io_lib:format(
|
|
@@ -290,15 +300,17 @@ cancel_query_for_connection_with_ssl(Config) ->
|
|
Module = ?config(module, Config),
|
|
Module = ?config(module, Config),
|
|
{Host, Port} = epgsql_ct:connection_data(Config),
|
|
{Host, Port} = epgsql_ct:connection_data(Config),
|
|
Module = ?config(module, Config),
|
|
Module = ?config(module, Config),
|
|
- Args2 = [{port, Port}, {database, "epgsql_test_db1"} | [ {ssl, true}, {timeout, 1000} ]],
|
|
|
|
|
|
+ Args2 = [ {port, Port}, {database, "epgsql_test_db1"}
|
|
|
|
+ | [ {ssl, true}
|
|
|
|
+ , {timeout, 1000} ]
|
|
|
|
+ ],
|
|
{ok, C} = Module:connect(Host, "epgsql_test", Args2),
|
|
{ok, C} = Module:connect(Host, "epgsql_test", Args2),
|
|
?assertMatch({ok, _Cols, [{true}]},
|
|
?assertMatch({ok, _Cols, [{true}]},
|
|
Module:equery(C, "select ssl_is_used()")),
|
|
Module:equery(C, "select ssl_is_used()")),
|
|
process_flag(trap_exit, true),
|
|
process_flag(trap_exit, true),
|
|
Self = self(),
|
|
Self = self(),
|
|
spawn_link(fun() ->
|
|
spawn_link(fun() ->
|
|
- ?assertMatch({error, #error{codename = query_canceled}},
|
|
|
|
- Module:equery(C, "SELECT pg_sleep(5)")),
|
|
|
|
|
|
+ ?assertMatch(?QUERY_CANCELED, Module:equery(C, "SELECT pg_sleep(5)")),
|
|
Self ! done
|
|
Self ! done
|
|
end),
|
|
end),
|
|
%% this will never match but introduces 1 second latency needed
|
|
%% this will never match but introduces 1 second latency needed
|
|
@@ -313,20 +325,21 @@ cancel_query_for_connection_with_ssl(Config) ->
|
|
epgsql:close(C),
|
|
epgsql:close(C),
|
|
?assert(false)
|
|
?assert(false)
|
|
end
|
|
end
|
|
- end.
|
|
|
|
|
|
+ end,
|
|
|
|
+ epgsql_ct:flush().
|
|
|
|
|
|
cancel_query_for_connection_with_gen_tcp(Config) ->
|
|
cancel_query_for_connection_with_gen_tcp(Config) ->
|
|
Module = ?config(module, Config),
|
|
Module = ?config(module, Config),
|
|
{Host, Port} = epgsql_ct:connection_data(Config),
|
|
{Host, Port} = epgsql_ct:connection_data(Config),
|
|
Module = ?config(module, Config),
|
|
Module = ?config(module, Config),
|
|
- Args2 = [{port, Port}, {database, "epgsql_test_db1"} | [ {timeout, 1000} ]],
|
|
|
|
|
|
+ Args2 = [ {port, Port}, {database, "epgsql_test_db1"}
|
|
|
|
+ | [ {timeout, 1000} ]
|
|
|
|
+ ],
|
|
{ok, C} = Module:connect(Host, "epgsql_test", Args2),
|
|
{ok, C} = Module:connect(Host, "epgsql_test", Args2),
|
|
-
|
|
|
|
process_flag(trap_exit, true),
|
|
process_flag(trap_exit, true),
|
|
Self = self(),
|
|
Self = self(),
|
|
spawn_link(fun() ->
|
|
spawn_link(fun() ->
|
|
- ?assertMatch({error, #error{codename = query_canceled}},
|
|
|
|
- Module:equery(C, "SELECT pg_sleep(5)")),
|
|
|
|
|
|
+ ?assertMatch(?QUERY_CANCELED, Module:equery(C, "SELECT pg_sleep(5)")),
|
|
Self ! done
|
|
Self ! done
|
|
end),
|
|
end),
|
|
%% this is will never match but it introduces the 1 second latency needed
|
|
%% this is will never match but it introduces the 1 second latency needed
|
|
@@ -341,7 +354,8 @@ cancel_query_for_connection_with_gen_tcp(Config) ->
|
|
epgsql:close(C),
|
|
epgsql:close(C),
|
|
?assert(false)
|
|
?assert(false)
|
|
end
|
|
end
|
|
- end.
|
|
|
|
|
|
+ end,
|
|
|
|
+ epgsql_ct:flush().
|
|
|
|
|
|
connect_with_client_cert(Config) ->
|
|
connect_with_client_cert(Config) ->
|
|
Module = ?config(module, Config),
|
|
Module = ?config(module, Config),
|