Files
parrhesia/test/support/runtime.ex
Steffen Beyer 65b47ec191
Some checks failed
CI / Test (OTP 27.2 / Elixir 1.18.2) (push) Failing after 0s
CI / Test (OTP 28.4 / Elixir 1.19.4 + Marmot E2E) (push) Failing after 0s
fix: Subscription workers restart strategy, sandbox ownership race condition
2026-03-17 18:49:50 +01:00

36 lines
712 B
Elixir

defmodule Parrhesia.TestSupport.Runtime do
@moduledoc false
@required_processes [
Parrhesia.Supervisor,
Parrhesia.Config,
Parrhesia.Repo,
Parrhesia.Subscriptions.Supervisor,
Parrhesia.API.Stream.Supervisor,
Parrhesia.Web.Endpoint
]
def ensure_started! do
if healthy?() do
:ok
else
restart!()
end
end
defp healthy? do
Enum.all?(@required_processes, &is_pid(Process.whereis(&1)))
end
defp restart! do
case Application.stop(:parrhesia) do
:ok -> :ok
{:error, {:not_started, :parrhesia}} -> :ok
{:error, {:not_started, _app}} -> :ok
end
{:ok, _apps} = Application.ensure_all_started(:parrhesia)
:ok
end
end