summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.gitlab-ci.yml4
-rw-r--r--changelog.d/fix-bookmark-folder-tests.skip0
-rw-r--r--changelog.d/postgres-jit.change1
-rw-r--r--changelog.d/test-improvements.skip0
-rw-r--r--changelog.d/transient-validators-defaults.change1
-rw-r--r--config/config.exs2
-rw-r--r--config/test.exs2
-rw-r--r--docs/installation/debian_based_jp.md4
-rw-r--r--docs/installation/generic_dependencies.include2
-rw-r--r--lib/pleroma/application.ex23
-rw-r--r--lib/pleroma/search/database_search.ex9
-rw-r--r--lib/pleroma/web/activity_pub/object_validators/attachment_validator.ex4
-rw-r--r--lib/pleroma/web/activity_pub/object_validators/question_options_validator.ex4
-rw-r--r--test/pleroma/search/database_search_test.exs15
-rw-r--r--test/pleroma/web/mastodon_api/controllers/search_controller_test.exs30
-rw-r--r--test/pleroma/web/pleroma_api/controllers/bookmark_folder_controller_test.exs (renamed from test/pleroma/web/pleroma_api/controllers/bookmark_folder_controller_test.ex)0
-rw-r--r--test/test_helper.exs2
17 files changed, 29 insertions, 74 deletions
diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index 09ce2efd9..dab52e4c6 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -26,10 +26,10 @@ cache: &global_cache_policy
- _build
stages:
- - check-changelog
- build
- lint
- test
+ - check-changelog
- benchmark
- deploy
- release
@@ -113,7 +113,7 @@ benchmark:
variables:
MIX_ENV: benchmark
services:
- - name: postgres:9.6-alpine
+ - name: postgres:11.22-alpine
alias: postgres
command: ["postgres", "-c", "fsync=off", "-c", "synchronous_commit=off", "-c", "full_page_writes=off"]
script:
diff --git a/changelog.d/fix-bookmark-folder-tests.skip b/changelog.d/fix-bookmark-folder-tests.skip
new file mode 100644
index 000000000..e69de29bb
--- /dev/null
+++ b/changelog.d/fix-bookmark-folder-tests.skip
diff --git a/changelog.d/postgres-jit.change b/changelog.d/postgres-jit.change
new file mode 100644
index 000000000..38225b06b
--- /dev/null
+++ b/changelog.d/postgres-jit.change
@@ -0,0 +1 @@
+Disable jit by default for PostgreSQL
diff --git a/changelog.d/test-improvements.skip b/changelog.d/test-improvements.skip
new file mode 100644
index 000000000..e69de29bb
--- /dev/null
+++ b/changelog.d/test-improvements.skip
diff --git a/changelog.d/transient-validators-defaults.change b/changelog.d/transient-validators-defaults.change
new file mode 100644
index 000000000..225cf4d0c
--- /dev/null
+++ b/changelog.d/transient-validators-defaults.change
@@ -0,0 +1 @@
+Set default values on validators for transient objects (attachment, poll options)
diff --git a/config/config.exs b/config/config.exs
index d0496cef8..32c8509be 100644
--- a/config/config.exs
+++ b/config/config.exs
@@ -799,7 +799,7 @@ config :pleroma, :modules, runtime_dir: "instance/modules"
config :pleroma, configurable_from_database: false
config :pleroma, Pleroma.Repo,
- parameters: [gin_fuzzy_search_limit: "500"],
+ parameters: [gin_fuzzy_search_limit: "500", jit: "off"],
prepare: :unnamed
config :pleroma, :connections_pool,
diff --git a/config/test.exs b/config/test.exs
index 9d752bdf8..80b01932c 100644
--- a/config/test.exs
+++ b/config/test.exs
@@ -49,7 +49,7 @@ config :pleroma, Pleroma.Repo,
hostname: System.get_env("DB_HOST") || "localhost",
port: System.get_env("DB_PORT") || "5432",
pool: Ecto.Adapters.SQL.Sandbox,
- pool_size: 50
+ pool_size: System.schedulers_online() * 2
config :pleroma, :dangerzone, override_repo_pool_size: true
diff --git a/docs/installation/debian_based_jp.md b/docs/installation/debian_based_jp.md
index 1424ad7f4..b6b5c9c07 100644
--- a/docs/installation/debian_based_jp.md
+++ b/docs/installation/debian_based_jp.md
@@ -12,8 +12,8 @@ Note: This article is potentially outdated because at this time we may not have
### 必要なソフトウェア
-- PostgreSQL 9.6以上 (Ubuntu16.04では9.5しか提供されていないので,[](https://www.postgresql.org/download/linux/ubuntu/)こちらから新しいバージョンを入手してください)
-- `postgresql-contrib` 9.6以上 (同上)
+- PostgreSQL 11.0以上 (Ubuntu16.04では9.5しか提供されていないので,[](https://www.postgresql.org/download/linux/ubuntu/)こちらから新しいバージョンを入手してください)
+- `postgresql-contrib` 11.0以上 (同上)
- Elixir 1.8 以上 ([Debianのリポジトリからインストールしないこと!!! ここからインストールすること!](https://elixir-lang.org/install.html#unix-and-unix-like)。または [asdf](https://github.com/asdf-vm/asdf) をpleromaユーザーでインストールしてください)
- `erlang-dev`
- `erlang-nox`
diff --git a/docs/installation/generic_dependencies.include b/docs/installation/generic_dependencies.include
index aebf21e7c..6572716ed 100644
--- a/docs/installation/generic_dependencies.include
+++ b/docs/installation/generic_dependencies.include
@@ -1,6 +1,6 @@
## Required dependencies
-* PostgreSQL >=9.6
+* PostgreSQL >=11.0
* Elixir >=1.11.0 <1.15
* Erlang OTP >=22.2.0 (supported: <27)
* git
diff --git a/lib/pleroma/application.ex b/lib/pleroma/application.ex
index de668052f..f2b234022 100644
--- a/lib/pleroma/application.ex
+++ b/lib/pleroma/application.ex
@@ -119,28 +119,7 @@ defmodule Pleroma.Application do
max_restarts = Application.get_env(:pleroma, __MODULE__)[:max_restarts]
opts = [strategy: :one_for_one, name: Pleroma.Supervisor, max_restarts: max_restarts]
- result = Supervisor.start_link(children, opts)
-
- set_postgres_server_version()
-
- result
- end
-
- defp set_postgres_server_version do
- version =
- with %{rows: [[version]]} <- Ecto.Adapters.SQL.query!(Pleroma.Repo, "show server_version"),
- {num, _} <- Float.parse(version) do
- num
- else
- e ->
- Logger.warning(
- "Could not get the postgres version: #{inspect(e)}.\nSetting the default value of 9.6"
- )
-
- 9.6
- end
-
- :persistent_term.put({Pleroma.Repo, :postgres_version}, version)
+ Supervisor.start_link(children, opts)
end
def load_custom_modules do
diff --git a/lib/pleroma/search/database_search.ex b/lib/pleroma/search/database_search.ex
index c6311e0c7..31bfc7e33 100644
--- a/lib/pleroma/search/database_search.ex
+++ b/lib/pleroma/search/database_search.ex
@@ -23,19 +23,12 @@ defmodule Pleroma.Search.DatabaseSearch do
offset = Keyword.get(options, :offset, 0)
author = Keyword.get(options, :author)
- search_function =
- if :persistent_term.get({Pleroma.Repo, :postgres_version}) >= 11 do
- :websearch
- else
- :plain
- end
-
try do
Activity
|> Activity.with_preloaded_object()
|> Activity.restrict_deactivated_users()
|> restrict_public(user)
- |> query_with(index_type, search_query, search_function)
+ |> query_with(index_type, search_query, :websearch)
|> maybe_restrict_local(user)
|> maybe_restrict_author(author)
|> maybe_restrict_blocked(user)
diff --git a/lib/pleroma/web/activity_pub/object_validators/attachment_validator.ex b/lib/pleroma/web/activity_pub/object_validators/attachment_validator.ex
index 398020bff..72975f348 100644
--- a/lib/pleroma/web/activity_pub/object_validators/attachment_validator.ex
+++ b/lib/pleroma/web/activity_pub/object_validators/attachment_validator.ex
@@ -12,13 +12,13 @@ defmodule Pleroma.Web.ActivityPub.ObjectValidators.AttachmentValidator do
@primary_key false
embedded_schema do
field(:id, :string)
- field(:type, :string)
+ field(:type, :string, default: "Link")
field(:mediaType, ObjectValidators.MIME, default: "application/octet-stream")
field(:name, :string)
field(:blurhash, :string)
embeds_many :url, UrlObjectValidator, primary_key: false do
- field(:type, :string)
+ field(:type, :string, default: "Link")
field(:href, ObjectValidators.Uri)
field(:mediaType, ObjectValidators.MIME, default: "application/octet-stream")
field(:width, :integer)
diff --git a/lib/pleroma/web/activity_pub/object_validators/question_options_validator.ex b/lib/pleroma/web/activity_pub/object_validators/question_options_validator.ex
index 541945fa4..8d7f7b9fa 100644
--- a/lib/pleroma/web/activity_pub/object_validators/question_options_validator.ex
+++ b/lib/pleroma/web/activity_pub/object_validators/question_options_validator.ex
@@ -14,10 +14,10 @@ defmodule Pleroma.Web.ActivityPub.ObjectValidators.QuestionOptionsValidator do
embeds_one :replies, Replies, primary_key: false do
field(:totalItems, :integer)
- field(:type, :string)
+ field(:type, :string, default: "Collection")
end
- field(:type, :string)
+ field(:type, :string, default: "Note")
end
def changeset(struct, data) do
diff --git a/test/pleroma/search/database_search_test.exs b/test/pleroma/search/database_search_test.exs
index 6c47ff425..d8dd09063 100644
--- a/test/pleroma/search/database_search_test.exs
+++ b/test/pleroma/search/database_search_test.exs
@@ -35,21 +35,6 @@ defmodule Pleroma.Search.DatabaseSearchTest do
assert [] = Search.search(nil, "wednesday")
end
- test "using plainto_tsquery on postgres < 11" do
- old_version = :persistent_term.get({Pleroma.Repo, :postgres_version})
- :persistent_term.put({Pleroma.Repo, :postgres_version}, 10.0)
- on_exit(fn -> :persistent_term.put({Pleroma.Repo, :postgres_version}, old_version) end)
-
- user = insert(:user)
- {:ok, post} = CommonAPI.post(user, %{status: "it's wednesday my dudes"})
- {:ok, _post2} = CommonAPI.post(user, %{status: "it's wednesday my bros"})
-
- # plainto doesn't understand complex queries
- assert [result] = Search.search(nil, "wednesday -dudes")
-
- assert result.id == post.id
- end
-
test "using websearch_to_tsquery" do
user = insert(:user)
{:ok, _post} = CommonAPI.post(user, %{status: "it's wednesday my dudes"})
diff --git a/test/pleroma/web/mastodon_api/controllers/search_controller_test.exs b/test/pleroma/web/mastodon_api/controllers/search_controller_test.exs
index b05487abe..ad4144da4 100644
--- a/test/pleroma/web/mastodon_api/controllers/search_controller_test.exs
+++ b/test/pleroma/web/mastodon_api/controllers/search_controller_test.exs
@@ -322,26 +322,20 @@ defmodule Pleroma.Web.MastodonAPI.SearchControllerTest do
end
test "search fetches remote statuses and prefers them over other results", %{conn: conn} do
- old_version = :persistent_term.get({Pleroma.Repo, :postgres_version})
- :persistent_term.put({Pleroma.Repo, :postgres_version}, 10.0)
- on_exit(fn -> :persistent_term.put({Pleroma.Repo, :postgres_version}, old_version) end)
-
- capture_log(fn ->
- {:ok, %{id: activity_id}} =
- CommonAPI.post(insert(:user), %{
- status: "check out http://mastodon.example.org/@admin/99541947525187367"
- })
+ {:ok, %{id: activity_id}} =
+ CommonAPI.post(insert(:user), %{
+ status: "check out http://mastodon.example.org/@admin/99541947525187367"
+ })
- results =
- conn
- |> get("/api/v1/search?q=http://mastodon.example.org/@admin/99541947525187367")
- |> json_response_and_validate_schema(200)
+ %{"url" => result_url, "id" => result_id} =
+ conn
+ |> get("/api/v1/search?q=http://mastodon.example.org/@admin/99541947525187367")
+ |> json_response_and_validate_schema(200)
+ |> Map.get("statuses")
+ |> List.first()
- assert [
- %{"url" => "http://mastodon.example.org/@admin/99541947525187367"},
- %{"id" => ^activity_id}
- ] = results["statuses"]
- end)
+ refute match?(^result_id, activity_id)
+ assert match?(^result_url, "http://mastodon.example.org/@admin/99541947525187367")
end
test "search doesn't show statuses that it shouldn't", %{conn: conn} do
diff --git a/test/pleroma/web/pleroma_api/controllers/bookmark_folder_controller_test.ex b/test/pleroma/web/pleroma_api/controllers/bookmark_folder_controller_test.exs
index 9bd90ed2e..9bd90ed2e 100644
--- a/test/pleroma/web/pleroma_api/controllers/bookmark_folder_controller_test.ex
+++ b/test/pleroma/web/pleroma_api/controllers/bookmark_folder_controller_test.exs
diff --git a/test/test_helper.exs b/test/test_helper.exs
index e65f7c1d1..a117584ae 100644
--- a/test/test_helper.exs
+++ b/test/test_helper.exs
@@ -4,6 +4,8 @@
Code.put_compiler_option(:warnings_as_errors, true)
+ExUnit.configure(max_cases: System.schedulers_online())
+
ExUnit.start(exclude: [:federated, :erratic])
if match?({:unix, :darwin}, :os.type()) do