summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJean-Sébastien Pédron <jean-sebastien@rabbitmq.com>2020-03-24 13:45:34 +0100
committerJean-Sébastien Pédron <jean-sebastien@rabbitmq.com>2020-03-24 13:47:10 +0100
commitbbd30b0c44ccd4dac86d1762e799afc1947f28ad (patch)
treea374cf63bbeeff7607900b6938e113c27f9ed54b
parent170977bd905b918f8e39a25fe802314fe4a0353a (diff)
downloadrabbitmq-server-git-bbd30b0c44ccd4dac86d1762e799afc1947f28ad.tar.gz
product_info_SUITE: Try to grep several times
... in case the log file was not fsync'd yet (and thus we don't see the content yet). This happens sometimes in Travis CI for instance.
-rw-r--r--test/product_info_SUITE.erl17
1 files changed, 14 insertions, 3 deletions
diff --git a/test/product_info_SUITE.erl b/test/product_info_SUITE.erl
index 1b4aec1f5a..ceb62d51dc 100644
--- a/test/product_info_SUITE.erl
+++ b/test/product_info_SUITE.erl
@@ -151,10 +151,21 @@ grep_in_log_file(Config, Node, String) ->
[Log | _] = rabbit_ct_broker_helpers:rpc(
Config, Node, rabbit, log_locations, []),
ct:pal(?LOW_IMPORTANCE, "Grepping \"~s\" in ~s", [String, Log]),
+ %% We try to grep several times, in case the log file was not
+ %% fsync'd yet (and thus we don't see the content yet).
+ do_grep_in_log_file(String, Log, 30).
+
+do_grep_in_log_file(String, Log, Retries) ->
{ok, Content} = file:read_file(Log),
- ?assertMatch(
- match,
- re:run(Content, ["\\b", String, "\\b"], [{capture, none}])).
+ case re:run(Content, ["\\b", String, "\\b"], [{capture, none}]) of
+ match ->
+ ok;
+ nomatch when Retries > 1 ->
+ timer:sleep(1000),
+ do_grep_in_log_file(String, Log, Retries - 1);
+ nomatch ->
+ throw({failed_to_grep, String, Log, Content})
+ end.
grep_in_stdout(Config, Node, String) ->
[Log | _] = rabbit_ct_broker_helpers:rpc(