Skip to content

Commit

Permalink
Flaky test: wait till lock is acquired (#4903)
Browse files Browse the repository at this point in the history
  • Loading branch information
aerosol authored Dec 16, 2024
1 parent 729a32e commit fb2e7cd
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions test/plausible/ingestion/event_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -280,7 +280,10 @@ defmodule Plausible.Ingestion.EventTest do
test "drops events on session lock timeout" do
site = new_site()

test = self()

very_slow_buffer = fn sessions ->
send(test, :slow_buffer_insert_started)
Process.sleep(1000)
Plausible.Session.WriteBuffer.insert(sessions)
end
Expand Down Expand Up @@ -310,10 +313,11 @@ defmodule Plausible.Ingestion.EventTest do
)
end)

Process.sleep(200)

assert {:ok, %{buffered: [], dropped: [dropped]}} = Event.build_and_buffer(second_request)
assert dropped.drop_reason == :lock_timeout
receive do
:slow_buffer_insert_started ->
assert {:ok, %{buffered: [], dropped: [dropped]}} = Event.build_and_buffer(second_request)
assert dropped.drop_reason == :lock_timeout
end
end

test "drops pageleave event when no session found from cache" do
Expand Down

0 comments on commit fb2e7cd

Please sign in to comment.