mirror of
https://git.pleroma.social/pleroma/pleroma.git
synced 2026-02-15 17:16:57 +00:00
Merge branch 'less-flaky-tests' into 'develop'
Less flaky tests See merge request pleroma/pleroma!4421
This commit is contained in:
commit
c945a8a467
24 changed files with 68 additions and 43 deletions
1
changelog.d/reduce-flaky-tests.skip
Normal file
1
changelog.d/reduce-flaky-tests.skip
Normal file
|
|
@ -0,0 +1 @@
|
||||||
|
Reduce the number of flaky tests by making them sync if they affect the global state, and silence noisy test output.
|
||||||
|
|
@ -102,7 +102,6 @@ config :pleroma, :http, send_user_agent: false
|
||||||
|
|
||||||
rum_enabled = System.get_env("RUM_ENABLED") == "true"
|
rum_enabled = System.get_env("RUM_ENABLED") == "true"
|
||||||
config :pleroma, :database, rum_enabled: rum_enabled
|
config :pleroma, :database, rum_enabled: rum_enabled
|
||||||
IO.puts("RUM enabled: #{rum_enabled}")
|
|
||||||
|
|
||||||
config :joken, default_signer: "yU8uHKq+yyAkZ11Hx//jcdacWc8yQ1bxAAGrplzB0Zwwjkp35v0RK9SO8WTPr6QZ"
|
config :joken, default_signer: "yU8uHKq+yyAkZ11Hx//jcdacWc8yQ1bxAAGrplzB0Zwwjkp35v0RK9SO8WTPr6QZ"
|
||||||
|
|
||||||
|
|
@ -192,7 +191,7 @@ config :pleroma, Pleroma.Application,
|
||||||
streamer_registry: false,
|
streamer_registry: false,
|
||||||
test_http_pools: true
|
test_http_pools: true
|
||||||
|
|
||||||
config :pleroma, Pleroma.Web.Streaming, sync_streaming: true
|
config :pleroma, Pleroma.Web.Streamer, sync_streaming: true
|
||||||
|
|
||||||
config :pleroma, Pleroma.Uploaders.Uploader, timeout: 1_000
|
config :pleroma, Pleroma.Uploaders.Uploader, timeout: 1_000
|
||||||
|
|
||||||
|
|
@ -207,8 +206,9 @@ config :pleroma, Pleroma.User.Backup, tempdir: "test/tmp"
|
||||||
|
|
||||||
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"
|
||||||
else
|
|
||||||
IO.puts(
|
|
||||||
"You may want to create test.secret.exs to declare custom database connection parameters."
|
|
||||||
)
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# Avoid noisy shutdown logs from os_mon during tests.
|
||||||
|
config :os_mon,
|
||||||
|
start_cpu_sup: false,
|
||||||
|
start_memsup: false
|
||||||
|
|
|
||||||
|
|
@ -330,7 +330,13 @@ defmodule Mix.Tasks.Pleroma.Config do
|
||||||
|> Enum.each(&write_and_delete(&1, file, opts[:delete]))
|
|> Enum.each(&write_and_delete(&1, file, opts[:delete]))
|
||||||
|
|
||||||
:ok = File.close(file)
|
:ok = File.close(file)
|
||||||
System.cmd("mix", ["format", path])
|
|
||||||
|
# Ensure `mix format` runs in the same env as the current task and doesn't
|
||||||
|
# emit config-time stderr noise (e.g. dev secret warnings) into `mix test`.
|
||||||
|
System.cmd("mix", ["format", path],
|
||||||
|
env: [{"MIX_ENV", to_string(Mix.env())}],
|
||||||
|
stderr_to_stdout: true
|
||||||
|
)
|
||||||
end
|
end
|
||||||
|
|
||||||
defp config_header, do: "import Config\r\n\r\n"
|
defp config_header, do: "import Config\r\n\r\n"
|
||||||
|
|
|
||||||
|
|
@ -29,22 +29,26 @@ defmodule Pleroma.Upload.Filter.Exiftool.ReadDescription do
|
||||||
do: current_description
|
do: current_description
|
||||||
|
|
||||||
defp read_when_empty(_, file, tag) do
|
defp read_when_empty(_, file, tag) do
|
||||||
try do
|
if File.exists?(file) do
|
||||||
{tag_content, 0} =
|
try do
|
||||||
System.cmd("exiftool", ["-b", "-s3", tag, file],
|
{tag_content, 0} =
|
||||||
stderr_to_stdout: false,
|
System.cmd("exiftool", ["-m", "-b", "-s3", tag, file],
|
||||||
parallelism: true
|
stderr_to_stdout: false,
|
||||||
)
|
parallelism: true
|
||||||
|
)
|
||||||
|
|
||||||
tag_content = String.trim(tag_content)
|
tag_content = String.trim(tag_content)
|
||||||
|
|
||||||
if tag_content != "" and
|
if tag_content != "" and
|
||||||
String.length(tag_content) <=
|
String.length(tag_content) <=
|
||||||
Pleroma.Config.get([:instance, :description_limit]),
|
Pleroma.Config.get([:instance, :description_limit]),
|
||||||
do: tag_content,
|
do: tag_content,
|
||||||
else: nil
|
else: nil
|
||||||
rescue
|
rescue
|
||||||
_ in ErlangError -> nil
|
_ in ErlangError -> nil
|
||||||
|
end
|
||||||
|
else
|
||||||
|
nil
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -16,11 +16,12 @@ defmodule Pleroma.Upload.Filter.Exiftool.StripLocation do
|
||||||
|
|
||||||
def filter(%Pleroma.Upload{tempfile: file, content_type: "image" <> _}) do
|
def filter(%Pleroma.Upload{tempfile: file, content_type: "image" <> _}) do
|
||||||
try do
|
try do
|
||||||
case System.cmd("exiftool", ["-overwrite_original", "-gps:all=", "-png:all=", file],
|
case System.cmd("exiftool", ["-m", "-overwrite_original", "-gps:all=", "-png:all=", file],
|
||||||
|
stderr_to_stdout: true,
|
||||||
parallelism: true
|
parallelism: true
|
||||||
) do
|
) do
|
||||||
{_response, 0} -> {:ok, :filtered}
|
{_response, 0} -> {:ok, :filtered}
|
||||||
{error, 1} -> {:error, error}
|
{error, _} -> {:error, error}
|
||||||
end
|
end
|
||||||
rescue
|
rescue
|
||||||
e in ErlangError ->
|
e in ErlangError ->
|
||||||
|
|
|
||||||
|
|
@ -300,7 +300,7 @@ defmodule Pleroma.Web.Streamer do
|
||||||
end)
|
end)
|
||||||
end
|
end
|
||||||
|
|
||||||
defp do_stream("user", item) do
|
defp do_stream("user", %Activity{} = item) do
|
||||||
Logger.debug("Trying to push to users")
|
Logger.debug("Trying to push to users")
|
||||||
|
|
||||||
recipient_topics =
|
recipient_topics =
|
||||||
|
|
|
||||||
2
mix.exs
2
mix.exs
|
|
@ -230,7 +230,7 @@ defmodule Pleroma.Mixfile do
|
||||||
"ecto.rollback": ["pleroma.ecto.rollback"],
|
"ecto.rollback": ["pleroma.ecto.rollback"],
|
||||||
"ecto.setup": ["ecto.create", "ecto.migrate", "run priv/repo/seeds.exs"],
|
"ecto.setup": ["ecto.create", "ecto.migrate", "run priv/repo/seeds.exs"],
|
||||||
"ecto.reset": ["ecto.drop", "ecto.setup"],
|
"ecto.reset": ["ecto.drop", "ecto.setup"],
|
||||||
test: ["ecto.create --quiet", "ecto.migrate", "test --warnings-as-errors"],
|
test: ["ecto.create --quiet", "pleroma.ecto.migrate --quiet", "test --warnings-as-errors"],
|
||||||
docs: ["pleroma.docs", "docs"],
|
docs: ["pleroma.docs", "docs"],
|
||||||
analyze: ["credo --strict --only=warnings,todo,fixme,consistency,readability"],
|
analyze: ["credo --strict --only=warnings,todo,fixme,consistency,readability"],
|
||||||
copyright: &add_copyright/1,
|
copyright: &add_copyright/1,
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,7 @@
|
||||||
# SPDX-License-Identifier: AGPL-3.0-only
|
# SPDX-License-Identifier: AGPL-3.0-only
|
||||||
|
|
||||||
defmodule Mix.PleromaTest do
|
defmodule Mix.PleromaTest do
|
||||||
use ExUnit.Case, async: true
|
use ExUnit.Case, async: false
|
||||||
import Mix.Pleroma
|
import Mix.Pleroma
|
||||||
|
|
||||||
setup_all do
|
setup_all do
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,7 @@
|
||||||
# SPDX-License-Identifier: AGPL-3.0-only
|
# SPDX-License-Identifier: AGPL-3.0-only
|
||||||
|
|
||||||
defmodule Mix.Tasks.Pleroma.AppTest do
|
defmodule Mix.Tasks.Pleroma.AppTest do
|
||||||
use Pleroma.DataCase, async: true
|
use Pleroma.DataCase, async: false
|
||||||
|
|
||||||
setup_all do
|
setup_all do
|
||||||
Mix.shell(Mix.Shell.Process)
|
Mix.shell(Mix.Shell.Process)
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,7 @@
|
||||||
# SPDX-License-Identifier: AGPL-3.0-only
|
# SPDX-License-Identifier: AGPL-3.0-only
|
||||||
|
|
||||||
defmodule Mix.Tasks.Pleroma.DatabaseTest do
|
defmodule Mix.Tasks.Pleroma.DatabaseTest do
|
||||||
use Pleroma.DataCase, async: true
|
use Pleroma.DataCase, async: false
|
||||||
use Oban.Testing, repo: Pleroma.Repo
|
use Oban.Testing, repo: Pleroma.Repo
|
||||||
|
|
||||||
alias Pleroma.Activity
|
alias Pleroma.Activity
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,7 @@
|
||||||
# SPDX-License-Identifier: AGPL-3.0-only
|
# SPDX-License-Identifier: AGPL-3.0-only
|
||||||
|
|
||||||
defmodule Pleroma.HTTPTest do
|
defmodule Pleroma.HTTPTest do
|
||||||
use ExUnit.Case, async: true
|
use ExUnit.Case, async: false
|
||||||
use Pleroma.Tests.Helpers
|
use Pleroma.Tests.Helpers
|
||||||
|
|
||||||
import Tesla.Mock
|
import Tesla.Mock
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,7 @@
|
||||||
# SPDX-License-Identifier: AGPL-3.0-only
|
# SPDX-License-Identifier: AGPL-3.0-only
|
||||||
|
|
||||||
defmodule Pleroma.Repo.Migrations.AutolinkerToLinkifyTest do
|
defmodule Pleroma.Repo.Migrations.AutolinkerToLinkifyTest do
|
||||||
use Pleroma.DataCase, async: true
|
use Pleroma.DataCase, async: false
|
||||||
import Pleroma.Factory
|
import Pleroma.Factory
|
||||||
import Pleroma.Tests.Helpers
|
import Pleroma.Tests.Helpers
|
||||||
alias Pleroma.ConfigDB
|
alias Pleroma.ConfigDB
|
||||||
|
|
|
||||||
|
|
@ -25,8 +25,8 @@ defmodule Pleroma.Upload.Filter.Exiftool.StripLocationTest do
|
||||||
|
|
||||||
assert Filter.Exiftool.StripLocation.filter(upload) == {:ok, :filtered}
|
assert Filter.Exiftool.StripLocation.filter(upload) == {:ok, :filtered}
|
||||||
|
|
||||||
{exif_original, 0} = System.cmd("exiftool", ["test/fixtures/DSCN0010.#{type}"])
|
{exif_original, 0} = System.cmd("exiftool", ["-m", "test/fixtures/DSCN0010.#{type}"])
|
||||||
{exif_filtered, 0} = System.cmd("exiftool", ["test/fixtures/DSCN0010_tmp.#{type}"])
|
{exif_filtered, 0} = System.cmd("exiftool", ["-m", "test/fixtures/DSCN0010_tmp.#{type}"])
|
||||||
|
|
||||||
assert String.match?(exif_original, ~r/GPS/)
|
assert String.match?(exif_original, ~r/GPS/)
|
||||||
refute String.match?(exif_filtered, ~r/GPS/)
|
refute String.match?(exif_filtered, ~r/GPS/)
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
defmodule Pleroma.Web.ActivityPub.MRF.RemoteReportPolicyTest do
|
defmodule Pleroma.Web.ActivityPub.MRF.RemoteReportPolicyTest do
|
||||||
use Pleroma.DataCase, async: true
|
use Pleroma.DataCase, async: false
|
||||||
|
|
||||||
alias Pleroma.Web.ActivityPub.MRF.RemoteReportPolicy
|
alias Pleroma.Web.ActivityPub.MRF.RemoteReportPolicy
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,7 @@
|
||||||
# SPDX-License-Identifier: AGPL-3.0-only
|
# SPDX-License-Identifier: AGPL-3.0-only
|
||||||
|
|
||||||
defmodule Pleroma.Web.ActivityPub.UtilsTest do
|
defmodule Pleroma.Web.ActivityPub.UtilsTest do
|
||||||
use Pleroma.DataCase, async: true
|
use Pleroma.DataCase, async: false
|
||||||
alias Pleroma.Activity
|
alias Pleroma.Activity
|
||||||
alias Pleroma.Object
|
alias Pleroma.Object
|
||||||
alias Pleroma.Repo
|
alias Pleroma.Repo
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,7 @@
|
||||||
# SPDX-License-Identifier: AGPL-3.0-only
|
# SPDX-License-Identifier: AGPL-3.0-only
|
||||||
|
|
||||||
defmodule Pleroma.Web.ActivityPub.UserViewTest do
|
defmodule Pleroma.Web.ActivityPub.UserViewTest do
|
||||||
use Pleroma.DataCase, async: true
|
use Pleroma.DataCase, async: false
|
||||||
import Pleroma.Factory
|
import Pleroma.Factory
|
||||||
|
|
||||||
alias Pleroma.User
|
alias Pleroma.User
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,7 @@
|
||||||
|
|
||||||
defmodule Pleroma.Web.PleromaAPI.ChatMessageReferenceViewTest do
|
defmodule Pleroma.Web.PleromaAPI.ChatMessageReferenceViewTest do
|
||||||
alias Pleroma.NullCache
|
alias Pleroma.NullCache
|
||||||
use Pleroma.DataCase, async: true
|
use Pleroma.DataCase, async: false
|
||||||
|
|
||||||
alias Pleroma.Chat
|
alias Pleroma.Chat
|
||||||
alias Pleroma.Chat.MessageReference
|
alias Pleroma.Chat.MessageReference
|
||||||
|
|
@ -18,6 +18,11 @@ defmodule Pleroma.Web.PleromaAPI.ChatMessageReferenceViewTest do
|
||||||
import Mox
|
import Mox
|
||||||
import Pleroma.Factory
|
import Pleroma.Factory
|
||||||
|
|
||||||
|
setup do
|
||||||
|
Mox.stub_with(Pleroma.CachexMock, Pleroma.NullCache)
|
||||||
|
:ok
|
||||||
|
end
|
||||||
|
|
||||||
setup do: clear_config([:rich_media, :enabled], true)
|
setup do: clear_config([:rich_media, :enabled], true)
|
||||||
|
|
||||||
test "it displays a chat message" do
|
test "it displays a chat message" do
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,7 @@
|
||||||
|
|
||||||
defmodule Pleroma.Web.RichMedia.CardTest do
|
defmodule Pleroma.Web.RichMedia.CardTest do
|
||||||
use Oban.Testing, repo: Pleroma.Repo
|
use Oban.Testing, repo: Pleroma.Repo
|
||||||
use Pleroma.DataCase, async: true
|
use Pleroma.DataCase, async: false
|
||||||
|
|
||||||
alias Pleroma.Tests.ObanHelpers
|
alias Pleroma.Tests.ObanHelpers
|
||||||
alias Pleroma.UnstubbedConfigMock, as: ConfigMock
|
alias Pleroma.UnstubbedConfigMock, as: ConfigMock
|
||||||
|
|
@ -19,6 +19,8 @@ defmodule Pleroma.Web.RichMedia.CardTest do
|
||||||
setup do
|
setup do
|
||||||
mock_global(fn env -> apply(HttpRequestMock, :request, [env]) end)
|
mock_global(fn env -> apply(HttpRequestMock, :request, [env]) end)
|
||||||
|
|
||||||
|
Mox.stub_with(Pleroma.CachexMock, Pleroma.NullCache)
|
||||||
|
|
||||||
ConfigMock
|
ConfigMock
|
||||||
|> stub_with(Pleroma.Test.StaticConfig)
|
|> stub_with(Pleroma.Test.StaticConfig)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -19,7 +19,12 @@ defmodule Pleroma.Web.StreamerTest do
|
||||||
|
|
||||||
@moduletag needs_streamer: true, capture_log: true
|
@moduletag needs_streamer: true, capture_log: true
|
||||||
|
|
||||||
setup do: clear_config([:instance, :skip_thread_containment])
|
setup do
|
||||||
|
clear_config([:instance, :skip_thread_containment])
|
||||||
|
Mox.stub_with(Pleroma.CachexMock, Pleroma.NullCache)
|
||||||
|
|
||||||
|
:ok
|
||||||
|
end
|
||||||
|
|
||||||
describe "get_topic/_ (unauthenticated)" do
|
describe "get_topic/_ (unauthenticated)" do
|
||||||
test "allows no stream" do
|
test "allows no stream" do
|
||||||
|
|
|
||||||
|
|
@ -3,12 +3,13 @@
|
||||||
# SPDX-License-Identifier: AGPL-3.0-only
|
# SPDX-License-Identifier: AGPL-3.0-only
|
||||||
|
|
||||||
defmodule Pleroma.Web.WebFingerTest do
|
defmodule Pleroma.Web.WebFingerTest do
|
||||||
use Pleroma.DataCase, async: true
|
use Pleroma.DataCase, async: false
|
||||||
alias Pleroma.Web.WebFinger
|
alias Pleroma.Web.WebFinger
|
||||||
import Pleroma.Factory
|
import Pleroma.Factory
|
||||||
import Tesla.Mock
|
import Tesla.Mock
|
||||||
|
|
||||||
setup do
|
setup do
|
||||||
|
Mox.stub_with(Pleroma.CachexMock, Pleroma.NullCache)
|
||||||
mock(fn env -> apply(HttpRequestMock, :request, [env]) end)
|
mock(fn env -> apply(HttpRequestMock, :request, [env]) end)
|
||||||
:ok
|
:ok
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,7 @@
|
||||||
# SPDX-License-Identifier: AGPL-3.0-only
|
# SPDX-License-Identifier: AGPL-3.0-only
|
||||||
|
|
||||||
defmodule Pleroma.Workers.PublisherWorkerTest do
|
defmodule Pleroma.Workers.PublisherWorkerTest do
|
||||||
use Pleroma.DataCase, async: true
|
use Pleroma.DataCase, async: false
|
||||||
use Oban.Testing, repo: Pleroma.Repo
|
use Oban.Testing, repo: Pleroma.Repo
|
||||||
|
|
||||||
import Pleroma.Factory
|
import Pleroma.Factory
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,7 @@
|
||||||
# SPDX-License-Identifier: AGPL-3.0-only
|
# SPDX-License-Identifier: AGPL-3.0-only
|
||||||
|
|
||||||
defmodule Pleroma.Workers.ReachabilityWorkerTest do
|
defmodule Pleroma.Workers.ReachabilityWorkerTest do
|
||||||
use Pleroma.DataCase, async: true
|
use Pleroma.DataCase, async: false
|
||||||
use Oban.Testing, repo: Pleroma.Repo
|
use Oban.Testing, repo: Pleroma.Repo
|
||||||
|
|
||||||
import Mock
|
import Mock
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,7 @@
|
||||||
# SPDX-License-Identifier: AGPL-3.0-only
|
# SPDX-License-Identifier: AGPL-3.0-only
|
||||||
|
|
||||||
defmodule Pleroma.Workers.ReceiverWorkerTest do
|
defmodule Pleroma.Workers.ReceiverWorkerTest do
|
||||||
use Pleroma.DataCase, async: true
|
use Pleroma.DataCase, async: false
|
||||||
use Oban.Testing, repo: Pleroma.Repo
|
use Oban.Testing, repo: Pleroma.Repo
|
||||||
|
|
||||||
import Mock
|
import Mock
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,7 @@
|
||||||
# SPDX-License-Identifier: AGPL-3.0-only
|
# SPDX-License-Identifier: AGPL-3.0-only
|
||||||
|
|
||||||
defmodule Pleroma.Workers.RemoteFetcherWorkerTest do
|
defmodule Pleroma.Workers.RemoteFetcherWorkerTest do
|
||||||
use Pleroma.DataCase, async: true
|
use Pleroma.DataCase, async: false
|
||||||
use Oban.Testing, repo: Pleroma.Repo
|
use Oban.Testing, repo: Pleroma.Repo
|
||||||
|
|
||||||
alias Pleroma.Workers.RemoteFetcherWorker
|
alias Pleroma.Workers.RemoteFetcherWorker
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue