I’m just started with Elixir and fall in love with it. I like Phoenix, mix, exUnit and the only thing bothering me are millions mesages during testing like:
[error] Postgrex.Protocol (#PID<0.422.0>) disconnected: ** (DBConnection.ConnectionError) owner #PID<0.1213.0> exited
Client #PID<0.1215.0> is still using a connection from owner at location
or
%DBConnection.OwnershipError{
message: "cannot find ownership process for #PID<0.1105.0>
My deps:
[
{:phoenix, "~> 1.7.6"},
{:phoenix_ecto, "~> 4.4"},
{:ecto_sql, "~> 3.10"},
{:postgrex, ">= 0.0.0"},
{:swoosh, "~> 1.3"},
{:finch, "~> 0.13"},
{:telemetry_metrics, "~> 0.6"},
{:telemetry_poller, "~> 1.0"},
{:jason, "~> 1.2"},
{:plug_cowboy, "~> 2.5"},
{:pbkdf2_elixir, "~> 2.0"},
{:excoveralls, "~> 0.16", only: :test},
{:gen_rmq, "~> 4.0"}
]
here is test_helper.xs
ExUnit.start()
Ecto.Adapters.SQL.Sandbox.mode(Chat.Repo, :manual)
here is part of data_case.ex
def setup_sandbox(tags) do
pid = Ecto.Adapters.SQL.Sandbox.start_owner!(Chat.Repo, shared: not tags[:async])
on_exit(fn -> Ecto.Adapters.SQL.Sandbox.stop_owner(pid) end)
end
I use channels, sockets, rabbitmq, so a lots of things happen in different processes. I tried everything I could fin in internet:
- try to add in every test module
setup do
:ok = Ecto.Adapters.SQL.Sandbox.checkout(Repo)
end
- try do use everythere async: false or delete any mentions about async
- explicit add to every test
allow = Process.whereis(EventConsumer)
Ecto.Adapters.SQL.Sandbox.allow(Repo, self(), allow)
- try to add at begining at every module
setup do
:ok = Ecto.Adapters.SQL.Sandbox.checkout(Repo)
Ecto.Adapters.SQL.Sandbox.mode(Repo, {:shared, self()})
end
- in config set ownership_timeout: 6000
Nothing helps, tests are all green (sic!) but all console full of errors about ownership
Please help! may be I could somehow said to Ecto -ignore ownership and timings, just test it =)