I have an umbrella application and am using Ecto, where one app is using GenServer processes for keeping mutable state for a queue, along with supervisors. When I run the tests for all umbrella applications together, after my first app is finished running, I receive a DBConnection.OwnershipError. This seems to be because the GenServer process loses access to its database. My application.ex looks like so:
defmodule MyProject.Application do
use Application
def start(_type, _args) do
children = [
Supervisor.child_spec({MyProject.Repo, []}, type: :supervisor),
MyProject.PgEvents.CallbackSupervisor,
]
opts = [strategy: :rest_for_one, name: MyProject.Supervisor]
IO.inspect("Application Successfully started")
{:ok, _pid} = Supervisor.start_link(children, opts)
end
def stop(_) do
IO.inspect("Application Successfully Stopped")
end
end
Interestingly, the IO.inspect output appears for start/2 but not for stop/1. This makes me think Exunit does not call stop/1 and the “CallbackSupervisor” managing the GenServers is not being stopped before the Repo supervisor is. I do not have lots of knowledge about how ExUnit runs for umbrella apps, does anyone have insight on this?