2022-10-11 22:27:27 +08:00
|
|
|
defmodule Livebook.EnterpriseIntegrationCase do
|
|
|
|
use ExUnit.CaseTemplate
|
|
|
|
|
|
|
|
alias Livebook.EnterpriseServer
|
|
|
|
|
|
|
|
using do
|
|
|
|
quote do
|
|
|
|
use LivebookWeb.ConnCase
|
|
|
|
|
|
|
|
@moduletag :enterprise_integration
|
|
|
|
|
2023-02-01 06:17:05 +08:00
|
|
|
import Livebook.EnterpriseIntegrationCase,
|
|
|
|
only: [start_new_instance: 1, stop_new_instance: 1]
|
|
|
|
|
2022-10-11 22:27:27 +08:00
|
|
|
alias Livebook.EnterpriseServer
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
setup_all do
|
2023-01-26 03:40:14 +08:00
|
|
|
case EnterpriseServer.start() do
|
|
|
|
{:ok, _} -> :ok
|
|
|
|
{:error, {:already_started, _}} -> :ok
|
|
|
|
end
|
2022-10-11 22:27:27 +08:00
|
|
|
|
2022-11-29 07:47:25 +08:00
|
|
|
{:ok,
|
2023-02-04 00:15:46 +08:00
|
|
|
url: EnterpriseServer.url(),
|
|
|
|
token: EnterpriseServer.token(),
|
|
|
|
user: EnterpriseServer.user(),
|
|
|
|
node: EnterpriseServer.get_node()}
|
2022-10-11 22:27:27 +08:00
|
|
|
end
|
2023-02-01 06:17:05 +08:00
|
|
|
|
|
|
|
def start_new_instance(name) do
|
|
|
|
suffix = Ecto.UUID.generate() |> :erlang.phash2() |> to_string()
|
|
|
|
app_port = Enum.random(1000..9000) |> to_string()
|
|
|
|
|
|
|
|
{:ok, _} =
|
|
|
|
EnterpriseServer.start(name,
|
|
|
|
env: %{
|
|
|
|
"DATABASE_URL" =>
|
|
|
|
"postgres://postgres:postgres@localhost:5432/enterprise_integration_#{suffix}"
|
|
|
|
},
|
|
|
|
app_port: app_port
|
|
|
|
)
|
|
|
|
end
|
|
|
|
|
|
|
|
def stop_new_instance(name) do
|
|
|
|
EnterpriseServer.disconnect(name)
|
|
|
|
EnterpriseServer.drop_database(name)
|
|
|
|
end
|
2022-10-11 22:27:27 +08:00
|
|
|
end
|