mirror of
https://git.pleroma.social/pleroma/pleroma.git
synced 2024-12-23 00:26:30 +00:00
Use config to control starting all HTTP pools in test env
This commit is contained in:
parent
17877f612e
commit
2330100371
2 changed files with 15 additions and 9 deletions
|
@ -167,7 +167,8 @@ config :pleroma, Pleroma.Application,
|
||||||
internal_fetch: false,
|
internal_fetch: false,
|
||||||
load_custom_modules: false,
|
load_custom_modules: false,
|
||||||
max_restarts: 100,
|
max_restarts: 100,
|
||||||
streamer_registry: false
|
streamer_registry: false,
|
||||||
|
test_http_pools: true
|
||||||
|
|
||||||
if File.exists?("./config/test.secret.exs") do
|
if File.exists?("./config/test.secret.exs") do
|
||||||
import_config "test.secret.exs"
|
import_config "test.secret.exs"
|
||||||
|
|
|
@ -14,7 +14,6 @@ defmodule Pleroma.Application do
|
||||||
@name Mix.Project.config()[:name]
|
@name Mix.Project.config()[:name]
|
||||||
@version Mix.Project.config()[:version]
|
@version Mix.Project.config()[:version]
|
||||||
@repository Mix.Project.config()[:source_url]
|
@repository Mix.Project.config()[:source_url]
|
||||||
@mix_env Mix.env()
|
|
||||||
|
|
||||||
def name, do: @name
|
def name, do: @name
|
||||||
def version, do: @version
|
def version, do: @version
|
||||||
|
@ -98,7 +97,7 @@ defmodule Pleroma.Application do
|
||||||
{Task.Supervisor, name: Pleroma.TaskSupervisor}
|
{Task.Supervisor, name: Pleroma.TaskSupervisor}
|
||||||
] ++
|
] ++
|
||||||
cachex_children() ++
|
cachex_children() ++
|
||||||
http_children(adapter, @mix_env) ++
|
http_children(adapter) ++
|
||||||
[
|
[
|
||||||
Pleroma.Stats,
|
Pleroma.Stats,
|
||||||
Pleroma.JobQueueMonitor,
|
Pleroma.JobQueueMonitor,
|
||||||
|
@ -268,11 +267,19 @@ defmodule Pleroma.Application do
|
||||||
end
|
end
|
||||||
|
|
||||||
# start hackney and gun pools in tests
|
# start hackney and gun pools in tests
|
||||||
defp http_children(_, :test) do
|
defp http_children(adapter) do
|
||||||
http_children(Tesla.Adapter.Hackney, nil) ++ http_children(Tesla.Adapter.Gun, nil)
|
if Application.get_env(:pleroma, __MODULE__)[:test_http_pools] do
|
||||||
|
http_children_hackney() ++ http_children_gun()
|
||||||
|
else
|
||||||
|
cond do
|
||||||
|
match?(Tesla.Adapter.Hackney, adapter) -> http_children_hackney()
|
||||||
|
match?(Tesla.Adapter.Gun, adapter) -> http_children_gun()
|
||||||
|
true -> []
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
defp http_children(Tesla.Adapter.Hackney, _) do
|
defp http_children_hackney() do
|
||||||
pools = [:federation, :media]
|
pools = [:federation, :media]
|
||||||
|
|
||||||
pools =
|
pools =
|
||||||
|
@ -288,13 +295,11 @@ defmodule Pleroma.Application do
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
defp http_children(Tesla.Adapter.Gun, _) do
|
defp http_children_gun() do
|
||||||
Pleroma.Gun.ConnectionPool.children() ++
|
Pleroma.Gun.ConnectionPool.children() ++
|
||||||
[{Task, &Pleroma.HTTP.AdapterHelper.Gun.limiter_setup/0}]
|
[{Task, &Pleroma.HTTP.AdapterHelper.Gun.limiter_setup/0}]
|
||||||
end
|
end
|
||||||
|
|
||||||
defp http_children(_, _), do: []
|
|
||||||
|
|
||||||
@spec limiters_setup() :: :ok
|
@spec limiters_setup() :: :ok
|
||||||
def limiters_setup do
|
def limiters_setup do
|
||||||
config = Config.get(ConcurrentLimiter, [])
|
config = Config.get(ConcurrentLimiter, [])
|
||||||
|
|
Loading…
Reference in a new issue