summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMark Felder <feld@feld.me>2024-01-20 19:10:57 -0500
committerMark Felder <feld@feld.me>2024-01-20 19:10:57 -0500
commit23301003717a5e154f54c14a5b8cb10ea2033e1a (patch)
tree9f2614015ca5ae21fd2e4508bd40b17b53b6cc1d
parent17877f612e6c655290c5dc8bdb82f4b34e8b5b9f (diff)
downloadpleroma-23301003717a5e154f54c14a5b8cb10ea2033e1a.tar.gz
pleroma-23301003717a5e154f54c14a5b8cb10ea2033e1a.zip
Use config to control starting all HTTP pools in test env
-rw-r--r--config/test.exs3
-rw-r--r--lib/pleroma/application.ex21
2 files changed, 15 insertions, 9 deletions
diff --git a/config/test.exs b/config/test.exs
index afdb71d1d..28d0364c6 100644
--- a/config/test.exs
+++ b/config/test.exs
@@ -167,7 +167,8 @@ config :pleroma, Pleroma.Application,
internal_fetch: false,
load_custom_modules: false,
max_restarts: 100,
- streamer_registry: false
+ streamer_registry: false,
+ test_http_pools: true
if File.exists?("./config/test.secret.exs") do
import_config "test.secret.exs"
diff --git a/lib/pleroma/application.ex b/lib/pleroma/application.ex
index 272529972..c0bfb898d 100644
--- a/lib/pleroma/application.ex
+++ b/lib/pleroma/application.ex
@@ -14,7 +14,6 @@ defmodule Pleroma.Application do
@name Mix.Project.config()[:name]
@version Mix.Project.config()[:version]
@repository Mix.Project.config()[:source_url]
- @mix_env Mix.env()
def name, do: @name
def version, do: @version
@@ -98,7 +97,7 @@ defmodule Pleroma.Application do
{Task.Supervisor, name: Pleroma.TaskSupervisor}
] ++
cachex_children() ++
- http_children(adapter, @mix_env) ++
+ http_children(adapter) ++
[
Pleroma.Stats,
Pleroma.JobQueueMonitor,
@@ -268,11 +267,19 @@ defmodule Pleroma.Application do
end
# start hackney and gun pools in tests
- defp http_children(_, :test) do
- http_children(Tesla.Adapter.Hackney, nil) ++ http_children(Tesla.Adapter.Gun, nil)
+ defp http_children(adapter) do
+ 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
- defp http_children(Tesla.Adapter.Hackney, _) do
+ defp http_children_hackney() do
pools = [:federation, :media]
pools =
@@ -288,13 +295,11 @@ defmodule Pleroma.Application do
end
end
- defp http_children(Tesla.Adapter.Gun, _) do
+ defp http_children_gun() do
Pleroma.Gun.ConnectionPool.children() ++
[{Task, &Pleroma.HTTP.AdapterHelper.Gun.limiter_setup/0}]
end
- defp http_children(_, _), do: []
-
@spec limiters_setup() :: :ok
def limiters_setup do
config = Config.get(ConcurrentLimiter, [])