Skip to content

Commit

Permalink
chore: reduce elixir test time for sync tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Ziinc committed Nov 29, 2023
1 parent 109f583 commit 8afad13
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 9 deletions.
8 changes: 4 additions & 4 deletions logflare-ex/test/batcher_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ defmodule LogflareEx.BatcherTest do

insert(:pending_event, source_token: "some-uuid")
assert :ok = Batcher.flush(source_token: "some-uuid")
Process.sleep(1000)
Process.sleep(300)
assert [] = Batcher.list_events_by(:all)
end

Expand All @@ -123,7 +123,7 @@ defmodule LogflareEx.BatcherTest do

insert(:pending_event, source_name: "some name")
assert :ok = Batcher.flush(source_name: "some name")
Process.sleep(500)
Process.sleep(300)
assert [] = Batcher.list_events_by(:all)
end

Expand All @@ -132,15 +132,15 @@ defmodule LogflareEx.BatcherTest do
start_supervised!({Batcher, client})

insert(:pending_event, source_name: "some name")
Process.sleep(500)
Process.sleep(300)
assert [] = Batcher.list_events_by(:all)
end

test ":auto_flush disabled" do
client = Client.new(source_name: "some name", auto_flush: false, flush_interval: 100)
start_supervised!({Batcher, client})
insert(:pending_event, source_name: "some name")
Process.sleep(500)
Process.sleep(300)
assert [_] = Batcher.list_events_by(:all)
end
end
Expand Down
11 changes: 6 additions & 5 deletions logflare-ex/test/logger_backend_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,11 @@ defmodule LogflareEx.LoggerBackendTest do
{:ok, _pid} = Logger.add_backend(LoggerBackend)

:ok =
Logger.configure_backend(LoggerBackend, source_token: "some-token", flush_interval: 500)
Logger.configure_backend(LoggerBackend, source_token: "some-token", flush_interval: 200)

Logger.put_module_level(__MODULE__, :all)
:timer.sleep(600)
Logger.flush()
:timer.sleep(300)
end)

on_exit(fn ->
Expand Down Expand Up @@ -58,7 +59,7 @@ defmodule LogflareEx.LoggerBackendTest do
end) =~ "a log event"

assert LogflareEx.count_queued_events() == 10
Process.sleep(500)
Process.sleep(300)
# should clear cache
assert LogflareEx.count_queued_events() == 0
end
Expand Down Expand Up @@ -99,7 +100,7 @@ defmodule LogflareEx.LoggerBackendTest do
assert capture_log(fn ->
spawn(fn -> 3.14 / 0 end)
spawn(fn -> Enum.find(nil, & &1) end)
Process.sleep(500)
Process.sleep(300)
end) =~ "Protocol.UndefinedError"

assert_receive :ok
Expand Down Expand Up @@ -338,7 +339,7 @@ defmodule LogflareEx.LoggerBackendTest do

# clear the test process inbox
capture_io(fn -> :c.flush() end)
:timer.sleep(500)
:timer.sleep(300)

on_exit(fn ->
Logger.remove_backend(LoggerBackend)
Expand Down

0 comments on commit 8afad13

Please sign in to comment.