From 8afad1395ecfe78e9bd27bf13521d5c8ddb8ca03 Mon Sep 17 00:00:00 2001 From: TzeYiing Date: Wed, 29 Nov 2023 16:51:05 +0800 Subject: [PATCH] chore: reduce elixir test time for sync tests --- logflare-ex/test/batcher_test.exs | 8 ++++---- logflare-ex/test/logger_backend_test.exs | 11 ++++++----- 2 files changed, 10 insertions(+), 9 deletions(-) diff --git a/logflare-ex/test/batcher_test.exs b/logflare-ex/test/batcher_test.exs index c74ccc6..e1a10b1 100644 --- a/logflare-ex/test/batcher_test.exs +++ b/logflare-ex/test/batcher_test.exs @@ -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 @@ -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 @@ -132,7 +132,7 @@ 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 @@ -140,7 +140,7 @@ defmodule LogflareEx.BatcherTest 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 diff --git a/logflare-ex/test/logger_backend_test.exs b/logflare-ex/test/logger_backend_test.exs index 4a799b1..b179fe9 100644 --- a/logflare-ex/test/logger_backend_test.exs +++ b/logflare-ex/test/logger_backend_test.exs @@ -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 -> @@ -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 @@ -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 @@ -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)