From aa09a2cd9c7c5a613db9026c7546eedb48b3d8ff Mon Sep 17 00:00:00 2001 From: Luke Bakken Date: Fri, 9 Aug 2019 12:17:38 -0700 Subject: [PATCH] Only sleep for a long time when CI env variable is present, like on Travis CI --- test/lager_test_backend.erl | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/test/lager_test_backend.erl b/test/lager_test_backend.erl index 6ecd633..94dd22e 100644 --- a/test/lager_test_backend.erl +++ b/test/lager_test_backend.erl @@ -1776,6 +1776,8 @@ async_threshold_test_() -> {foreach, Setup, Cleanup, [ {"async threshold works", {timeout, 30, fun() -> + Sleep = get_long_sleep_value(), + %% we start out async ?assertEqual(true, lager_config:get(async)), ?assertEqual([{sync_toggled, 0}], @@ -1790,7 +1792,7 @@ async_threshold_test_() -> %% serialize on mailbox _ = gen_event:which_handlers(lager_event), - timer:sleep(5000), + timer:sleep(Sleep), %% By now the flood of messages should have forced the backend throttle %% to turn off async mode, but it's possible all outstanding requests @@ -1807,12 +1809,12 @@ async_threshold_test_() -> %% serialize on the mailbox again _ = gen_event:which_handlers(lager_event), - timer:sleep(5000), + timer:sleep(Sleep), lager:info("hello world"), _ = gen_event:which_handlers(lager_event), - timer:sleep(5000), + timer:sleep(Sleep), %% async is true again now that the mailbox has drained ?assertEqual(true, lager_config:get(async)), @@ -1904,4 +1906,12 @@ high_watermark_test_() -> ] }. +get_long_sleep_value() -> + case os:getenv("CI") of + false -> + 500; + _ -> + 5000 + end. + -endif.