summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorPhilip Kuryloski <pkuryloski@pivotal.io>2020-04-20 15:23:42 +0200
committerJean-Sébastien Pédron <jean-sebastien@rabbitmq.com>2020-04-21 15:18:42 +0200
commitde224081cb8fe3a260ab42ef27530c109e6a5085 (patch)
tree90f5392782ee67252a519e386dc34b65460ab069 /test
parentc139e2f3ea7dd8aa8c90f5917c1e0526c2790fa8 (diff)
downloadrabbitmq-server-git-de224081cb8fe3a260ab42ef27530c109e6a5085.tar.gz
Attempt to make unit_log_managment_SUITE less flaky
Rather than wait a fixed 2000ms, poll the test condition for up to 5000ms. Also switch from a raw message send in rabbit.erl to a gen_event:call/4 to the lager backend. I had hoped this would behave synchronously, which it does not appear to, but at least we now get a value back from the call.
Diffstat (limited to 'test')
-rw-r--r--test/unit_log_management_SUITE.erl30
1 files changed, 20 insertions, 10 deletions
diff --git a/test/unit_log_management_SUITE.erl b/test/unit_log_management_SUITE.erl
index 07177b10d6..31d96f38c2 100644
--- a/test/unit_log_management_SUITE.erl
+++ b/test/unit_log_management_SUITE.erl
@@ -138,26 +138,36 @@ log_management1(_Config) ->
%% simple log rotation
ok = rabbit:rotate_logs(),
- %% FIXME: rabbit:rotate_logs/0 is asynchronous due to a limitation
- %% in Lager. Therefore, we have no choice but to wait an arbitrary
+ %% rabbit:rotate_logs/0 is asynchronous due to a limitation in
+ %% Lager. Therefore, we have no choice but to wait an arbitrary
%% amount of time.
- timer:sleep(2000),
- [true, true] = non_empty_files([LogFile ++ Suffix, LogFile]),
+ ok = rabbit_ct_helpers:await_condition(
+ fun() ->
+ [true, true] =:=
+ non_empty_files([LogFile ++ Suffix, LogFile])
+ end, 5000),
ok = test_logs_working([LogFile]),
%% log rotation on empty files
ok = clean_logs([LogFile], Suffix),
ok = rabbit:rotate_logs(),
- timer:sleep(2000),
- ?assertEqual([true, true], non_empty_files([LogFile ++ Suffix, LogFile])),
+ ok = rabbit_ct_helpers:await_condition(
+ fun() ->
+ [true, true] =:=
+ non_empty_files([LogFile ++ Suffix, LogFile])
+ end, 5000),
%% logs with suffix are not writable
ok = rabbit:rotate_logs(),
- timer:sleep(2000),
- ok = make_files_non_writable([LogFile ++ Suffix]),
+ ok = rabbit_ct_helpers:await_condition(
+ fun() ->
+ ok =:= make_files_non_writable([LogFile ++ Suffix])
+ end, 5000),
ok = rabbit:rotate_logs(),
- timer:sleep(2000),
- ok = test_logs_working([LogFile]),
+ ok = rabbit_ct_helpers:await_condition(
+ fun() ->
+ ok =:= test_logs_working([LogFile])
+ end, 5000),
%% rotate when original log files are not writable
ok = make_files_non_writable([LogFile]),