Merge branch '1778-benchmark-fix' into 'develop'

Load Testing: adjust to new CommonAPI.post format.

Closes #1778

See merge request pleroma/pleroma!2546
This commit is contained in:
lain 2020-05-18 12:14:24 +00:00
commit 5c502eb3ad

View File

@ -123,7 +123,7 @@ defmodule Pleroma.LoadTesting.Activities do
Enum.each(1..activity_count, fn _ -> Enum.each(1..activity_count, fn _ ->
random = :rand.uniform() random = :rand.uniform()
i = Enum.find_index(intervals, fn {lower, upper} -> lower <= random && upper > random end) i = Enum.find_index(intervals, fn {lower, upper} -> lower <= random && upper > random end)
CommonAPI.post(Enum.random(users), %{"status" => "a post with the tag #tag_#{i}"}) CommonAPI.post(Enum.random(users), %{status: "a post with the tag #tag_#{i}"})
end) end)
end end
@ -137,8 +137,8 @@ defmodule Pleroma.LoadTesting.Activities do
{:ok, activity} = {:ok, activity} =
CommonAPI.post(user, %{ CommonAPI.post(user, %{
"status" => "Start of #{visibility} long thread", status: "Start of #{visibility} long thread",
"visibility" => visibility visibility: visibility
}) })
Agent.update(:benchmark_state, fn state -> Agent.update(:benchmark_state, fn state ->
@ -186,7 +186,7 @@ defmodule Pleroma.LoadTesting.Activities do
{:ok, _activity} = {:ok, _activity} =
group group
|> get_actor(user, friends, non_friends) |> get_actor(user, friends, non_friends)
|> CommonAPI.post(%{"status" => "Simple status", "visibility" => visibility}) |> CommonAPI.post(%{status: "Simple status", visibility: visibility})
end end
defp insert_activity("emoji", visibility, group, user, friends, non_friends, _opts) do defp insert_activity("emoji", visibility, group, user, friends, non_friends, _opts) do
@ -194,8 +194,8 @@ defmodule Pleroma.LoadTesting.Activities do
group group
|> get_actor(user, friends, non_friends) |> get_actor(user, friends, non_friends)
|> CommonAPI.post(%{ |> CommonAPI.post(%{
"status" => "Simple status with emoji :firefox:", status: "Simple status with emoji :firefox:",
"visibility" => visibility visibility: visibility
}) })
end end
@ -213,8 +213,8 @@ defmodule Pleroma.LoadTesting.Activities do
group group
|> get_actor(user, friends, non_friends) |> get_actor(user, friends, non_friends)
|> CommonAPI.post(%{ |> CommonAPI.post(%{
"status" => Enum.join(user_mentions, ", ") <> " simple status with mentions", status: Enum.join(user_mentions, ", ") <> " simple status with mentions",
"visibility" => visibility visibility: visibility
}) })
end end
@ -236,8 +236,8 @@ defmodule Pleroma.LoadTesting.Activities do
group group
|> get_actor(user, friends, non_friends) |> get_actor(user, friends, non_friends)
|> CommonAPI.post(%{ |> CommonAPI.post(%{
"status" => mentions <> " hell thread status", status: mentions <> " hell thread status",
"visibility" => visibility visibility: visibility
}) })
end end
@ -262,9 +262,9 @@ defmodule Pleroma.LoadTesting.Activities do
{:ok, _activity} = {:ok, _activity} =
CommonAPI.post(actor, %{ CommonAPI.post(actor, %{
"status" => "Post with attachment", status: "Post with attachment",
"visibility" => visibility, visibility: visibility,
"media_ids" => [object.id] media_ids: [object.id]
}) })
end end
@ -272,7 +272,7 @@ defmodule Pleroma.LoadTesting.Activities do
{:ok, _activity} = {:ok, _activity} =
group group
|> get_actor(user, friends, non_friends) |> get_actor(user, friends, non_friends)
|> CommonAPI.post(%{"status" => "Status with #tag", "visibility" => visibility}) |> CommonAPI.post(%{status: "Status with #tag", visibility: visibility})
end end
defp insert_activity("like", visibility, group, user, friends, non_friends, opts) do defp insert_activity("like", visibility, group, user, friends, non_friends, opts) do
@ -312,8 +312,7 @@ defmodule Pleroma.LoadTesting.Activities do
actor = get_actor(group, user, friends, non_friends) actor = get_actor(group, user, friends, non_friends)
tasks = get_reply_tasks(visibility, group) tasks = get_reply_tasks(visibility, group)
{:ok, activity} = {:ok, activity} = CommonAPI.post(user, %{status: "Simple status", visibility: visibility})
CommonAPI.post(user, %{"status" => "Simple status", "visibility" => visibility})
acc = {activity.id, ["@" <> actor.nickname, "reply to status"]} acc = {activity.id, ["@" <> actor.nickname, "reply to status"]}
insert_replies(tasks, visibility, user, friends, non_friends, acc) insert_replies(tasks, visibility, user, friends, non_friends, acc)
@ -336,8 +335,8 @@ defmodule Pleroma.LoadTesting.Activities do
{:ok, activity} = {:ok, activity} =
CommonAPI.post(actor, %{ CommonAPI.post(actor, %{
"status" => Enum.join(data, ", ") <> "simple status", status: Enum.join(data, ", ") <> "simple status",
"visibility" => "direct" visibility: "direct"
}) })
acc = {activity.id, ["@" <> user.nickname | data] ++ ["reply to status"]} acc = {activity.id, ["@" <> user.nickname | data] ++ ["reply to status"]}
@ -527,9 +526,9 @@ defmodule Pleroma.LoadTesting.Activities do
defp insert_reply(actor, data, activity_id, visibility) do defp insert_reply(actor, data, activity_id, visibility) do
{:ok, reply} = {:ok, reply} =
CommonAPI.post(actor, %{ CommonAPI.post(actor, %{
"status" => Enum.join(data, ", "), status: Enum.join(data, ", "),
"visibility" => visibility, visibility: visibility,
"in_reply_to_status_id" => activity_id in_reply_to_status_id: activity_id
}) })
{reply.id, ["@" <> actor.nickname | data]} {reply.id, ["@" <> actor.nickname | data]}