logo

pleroma

My custom branche(s) on git.pleroma.social/pleroma/pleroma git clone https://hacktivis.me/git/pleroma.git
commit: 23301003717a5e154f54c14a5b8cb10ea2033e1a
parent 17877f612e6c655290c5dc8bdb82f4b34e8b5b9f
Author: Mark Felder <feld@feld.me>
Date:   Sat, 20 Jan 2024 19:10:57 -0500

Use config to control starting all HTTP pools in test env

Diffstat:

Mconfig/test.exs3++-
Mlib/pleroma/application.ex21+++++++++++++--------
2 files changed, 15 insertions(+), 9 deletions(-)

diff --git 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 @@ -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, [])