forked from AkkomaGang/akkoma
tests: significantly reduce streamer timeout
there is no reason IPC between two processes on the same node should take 4 seconds
This commit is contained in:
parent
54029fe212
commit
6ffbfdeeb2
1 changed files with 23 additions and 19 deletions
|
@ -16,6 +16,10 @@ defmodule Pleroma.Web.StreamerTest do
|
||||||
alias Pleroma.Web.Streamer.Worker
|
alias Pleroma.Web.Streamer.Worker
|
||||||
|
|
||||||
@moduletag needs_streamer: true, capture_log: true
|
@moduletag needs_streamer: true, capture_log: true
|
||||||
|
|
||||||
|
@streamer_timeout 150
|
||||||
|
@streamer_start_wait 10
|
||||||
|
|
||||||
clear_config_all([:instance, :skip_thread_containment])
|
clear_config_all([:instance, :skip_thread_containment])
|
||||||
|
|
||||||
describe "user streams" do
|
describe "user streams" do
|
||||||
|
@ -28,7 +32,7 @@ defmodule Pleroma.Web.StreamerTest do
|
||||||
test "it sends notify to in the 'user' stream", %{user: user, notify: notify} do
|
test "it sends notify to in the 'user' stream", %{user: user, notify: notify} do
|
||||||
task =
|
task =
|
||||||
Task.async(fn ->
|
Task.async(fn ->
|
||||||
assert_receive {:text, _}, 4_000
|
assert_receive {:text, _}, @streamer_timeout
|
||||||
end)
|
end)
|
||||||
|
|
||||||
Streamer.add_socket(
|
Streamer.add_socket(
|
||||||
|
@ -43,7 +47,7 @@ test "it sends notify to in the 'user' stream", %{user: user, notify: notify} do
|
||||||
test "it sends notify to in the 'user:notification' stream", %{user: user, notify: notify} do
|
test "it sends notify to in the 'user:notification' stream", %{user: user, notify: notify} do
|
||||||
task =
|
task =
|
||||||
Task.async(fn ->
|
Task.async(fn ->
|
||||||
assert_receive {:text, _}, 4_000
|
assert_receive {:text, _}, @streamer_timeout
|
||||||
end)
|
end)
|
||||||
|
|
||||||
Streamer.add_socket(
|
Streamer.add_socket(
|
||||||
|
@ -61,7 +65,7 @@ test "it doesn't send notify to the 'user:notification' stream when a user is bl
|
||||||
blocked = insert(:user)
|
blocked = insert(:user)
|
||||||
{:ok, _user_relationship} = User.block(user, blocked)
|
{:ok, _user_relationship} = User.block(user, blocked)
|
||||||
|
|
||||||
task = Task.async(fn -> refute_receive {:text, _}, 4_000 end)
|
task = Task.async(fn -> refute_receive {:text, _}, @streamer_timeout end)
|
||||||
|
|
||||||
Streamer.add_socket(
|
Streamer.add_socket(
|
||||||
"user:notification",
|
"user:notification",
|
||||||
|
@ -79,7 +83,7 @@ test "it doesn't send notify to the 'user:notification' stream when a thread is
|
||||||
user: user
|
user: user
|
||||||
} do
|
} do
|
||||||
user2 = insert(:user)
|
user2 = insert(:user)
|
||||||
task = Task.async(fn -> refute_receive {:text, _}, 4_000 end)
|
task = Task.async(fn -> refute_receive {:text, _}, @streamer_timeout end)
|
||||||
|
|
||||||
Streamer.add_socket(
|
Streamer.add_socket(
|
||||||
"user:notification",
|
"user:notification",
|
||||||
|
@ -97,7 +101,7 @@ test "it doesn't send notify to the 'user:notification' stream' when a domain is
|
||||||
user: user
|
user: user
|
||||||
} do
|
} do
|
||||||
user2 = insert(:user, %{ap_id: "https://hecking-lewd-place.com/user/meanie"})
|
user2 = insert(:user, %{ap_id: "https://hecking-lewd-place.com/user/meanie"})
|
||||||
task = Task.async(fn -> refute_receive {:text, _}, 4_000 end)
|
task = Task.async(fn -> refute_receive {:text, _}, @streamer_timeout end)
|
||||||
|
|
||||||
Streamer.add_socket(
|
Streamer.add_socket(
|
||||||
"user:notification",
|
"user:notification",
|
||||||
|
@ -116,7 +120,9 @@ test "it sends follow activities to the 'user:notification' stream", %{
|
||||||
user: user
|
user: user
|
||||||
} do
|
} do
|
||||||
user2 = insert(:user)
|
user2 = insert(:user)
|
||||||
task = Task.async(fn -> assert_receive {:text, _}, 4_000 end)
|
task = Task.async(fn -> assert_receive {:text, _}, @streamer_timeout end)
|
||||||
|
|
||||||
|
Process.sleep(@streamer_start_wait)
|
||||||
|
|
||||||
Streamer.add_socket(
|
Streamer.add_socket(
|
||||||
"user:notification",
|
"user:notification",
|
||||||
|
@ -137,7 +143,7 @@ test "it sends to public" do
|
||||||
|
|
||||||
task =
|
task =
|
||||||
Task.async(fn ->
|
Task.async(fn ->
|
||||||
assert_receive {:text, _}, 4_000
|
assert_receive {:text, _}, @streamer_timeout
|
||||||
end)
|
end)
|
||||||
|
|
||||||
fake_socket = %StreamerSocket{
|
fake_socket = %StreamerSocket{
|
||||||
|
@ -164,7 +170,7 @@ test "it sends to public" do
|
||||||
}
|
}
|
||||||
|> Jason.encode!()
|
|> Jason.encode!()
|
||||||
|
|
||||||
assert_receive {:text, received_event}, 4_000
|
assert_receive {:text, received_event}, @streamer_timeout
|
||||||
assert received_event == expected_event
|
assert received_event == expected_event
|
||||||
end)
|
end)
|
||||||
|
|
||||||
|
@ -458,9 +464,7 @@ test "it doesn't send posts from muted threads" do
|
||||||
|
|
||||||
{:ok, activity} = CommonAPI.add_mute(user2, activity)
|
{:ok, activity} = CommonAPI.add_mute(user2, activity)
|
||||||
|
|
||||||
task = Task.async(fn -> refute_receive {:text, _}, 4_000 end)
|
task = Task.async(fn -> refute_receive {:text, _}, @streamer_timeout end)
|
||||||
|
|
||||||
Process.sleep(4000)
|
|
||||||
|
|
||||||
Streamer.add_socket(
|
Streamer.add_socket(
|
||||||
"user",
|
"user",
|
||||||
|
@ -482,7 +486,7 @@ test "it sends conversation update to the 'direct' stream", %{} do
|
||||||
|
|
||||||
task =
|
task =
|
||||||
Task.async(fn ->
|
Task.async(fn ->
|
||||||
assert_receive {:text, received_event}, 4_000
|
assert_receive {:text, received_event}, @streamer_timeout
|
||||||
|
|
||||||
assert %{"event" => "conversation", "payload" => received_payload} =
|
assert %{"event" => "conversation", "payload" => received_payload} =
|
||||||
Jason.decode!(received_event)
|
Jason.decode!(received_event)
|
||||||
|
@ -518,13 +522,13 @@ test "it doesn't send conversation update to the 'direct' stream when the last m
|
||||||
|
|
||||||
task =
|
task =
|
||||||
Task.async(fn ->
|
Task.async(fn ->
|
||||||
assert_receive {:text, received_event}, 4_000
|
assert_receive {:text, received_event}, @streamer_timeout
|
||||||
assert %{"event" => "delete", "payload" => _} = Jason.decode!(received_event)
|
assert %{"event" => "delete", "payload" => _} = Jason.decode!(received_event)
|
||||||
|
|
||||||
refute_receive {:text, _}, 4_000
|
refute_receive {:text, _}, @streamer_timeout
|
||||||
end)
|
end)
|
||||||
|
|
||||||
Process.sleep(1000)
|
Process.sleep(@streamer_start_wait)
|
||||||
|
|
||||||
Streamer.add_socket(
|
Streamer.add_socket(
|
||||||
"direct",
|
"direct",
|
||||||
|
@ -555,11 +559,11 @@ test "it sends conversation update to the 'direct' stream when a message is dele
|
||||||
|
|
||||||
task =
|
task =
|
||||||
Task.async(fn ->
|
Task.async(fn ->
|
||||||
assert_receive {:text, received_event}, 4_000
|
|
||||||
|
assert_receive {:text, received_event}, @streamer_timeout
|
||||||
assert %{"event" => "delete", "payload" => _} = Jason.decode!(received_event)
|
assert %{"event" => "delete", "payload" => _} = Jason.decode!(received_event)
|
||||||
|
|
||||||
assert_receive {:text, received_event}, 4_000
|
assert_receive {:text, received_event}, @streamer_timeout
|
||||||
|
|
||||||
assert %{"event" => "conversation", "payload" => received_payload} =
|
assert %{"event" => "conversation", "payload" => received_payload} =
|
||||||
Jason.decode!(received_event)
|
Jason.decode!(received_event)
|
||||||
|
|
||||||
|
@ -567,7 +571,7 @@ test "it sends conversation update to the 'direct' stream when a message is dele
|
||||||
assert last_status["id"] == to_string(create_activity.id)
|
assert last_status["id"] == to_string(create_activity.id)
|
||||||
end)
|
end)
|
||||||
|
|
||||||
Process.sleep(1000)
|
Process.sleep(@streamer_start_wait)
|
||||||
|
|
||||||
Streamer.add_socket(
|
Streamer.add_socket(
|
||||||
"direct",
|
"direct",
|
||||||
|
|
Loading…
Reference in a new issue