From 50d16a9e27189800f69901c4e90aa6f41bdf3193 Mon Sep 17 00:00:00 2001 From: lain Date: Tue, 8 Dec 2020 17:30:10 +0100 Subject: [PATCH] ApplicationRequirements: Add test, more text for pool size. --- lib/pleroma/application_requirements.ex | 10 ++++++++-- test/pleroma/application_requirements_test.exs | 19 +++++++++++++++++++ 2 files changed, 27 insertions(+), 2 deletions(-) diff --git a/lib/pleroma/application_requirements.ex b/lib/pleroma/application_requirements.ex index 2c1864ef1..e61576644 100644 --- a/lib/pleroma/application_requirements.ex +++ b/lib/pleroma/application_requirements.ex @@ -194,9 +194,15 @@ defmodule Pleroma.ApplicationRequirements do not Pleroma.Config.get([:dangerzone, :override_repo_pool_size], false) do Logger.error(""" !!!CONFIG WARNING!!! - The database pool size has been altered from the recommended value of 10.\n - Please revert or ensure your database is tuned appropriately and then set\n + + The database pool size has been altered from the recommended value of 10. + + Please revert or ensure your database is tuned appropriately and then set `config :pleroma, :dangerzone, override_repo_pool_size: true`. + + If you are experiencing database timeouts, please check the "Optimizing + your PostgreSQL performance" section in the documentation. If you still + encounter issues after that, please open an issue on the tracker. """) {:error, "Repo.pool_size different than recommended value."} diff --git a/test/pleroma/application_requirements_test.exs b/test/pleroma/application_requirements_test.exs index c505ae229..b432dbc37 100644 --- a/test/pleroma/application_requirements_test.exs +++ b/test/pleroma/application_requirements_test.exs @@ -12,6 +12,25 @@ defmodule Pleroma.ApplicationRequirementsTest do alias Pleroma.Config alias Pleroma.Repo + describe "check_repo_pool_size!/1" do + test "raises if the pool size is unexpected" do + clear_config([Pleroma.Repo, :pool_size], 11) + + assert_raise Pleroma.ApplicationRequirements.VerifyError, + "Repo.pool_size different than recommended value.", + fn -> + capture_log(&Pleroma.ApplicationRequirements.verify!/0) + end + end + + test "doesn't raise if the pool size is unexpected but the respective flag is set" do + clear_config([Pleroma.Repo, :pool_size], 11) + clear_config([:dangerzone, :override_repo_pool_size], true) + + assert Pleroma.ApplicationRequirements.verify!() == :ok + end + end + describe "check_welcome_message_config!/1" do setup do: clear_config([:welcome]) setup do: clear_config([Pleroma.Emails.Mailer])