From d211f19eb9fb0ad70a485e81bca15c5d64f658b7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lo=C3=AFc=20Hoguin?= Date: Thu, 14 Nov 2024 12:26:18 +0100 Subject: [PATCH] CQ: Fix flakes in the store file scan test We don't expect random bytes to be there in the current version of the message store as we overwrite empty spaces with zeroes when moving messages around. We also don't expect messages to be false flagged when the broker is running because it checks for message validity in the index. Therefore make sure message bodies in the tests don't contain byte 255. (cherry picked from commit db50739ad833d25248468e00e37fd010e113e13f) --- deps/rabbit/test/backing_queue_SUITE.erl | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/deps/rabbit/test/backing_queue_SUITE.erl b/deps/rabbit/test/backing_queue_SUITE.erl index 0efa3633189a..152daf043081 100644 --- a/deps/rabbit/test/backing_queue_SUITE.erl +++ b/deps/rabbit/test/backing_queue_SUITE.erl @@ -655,9 +655,11 @@ gen_msg() -> gen_msg(1024 * 1024). gen_msg(MaxSize) -> - %% This might generate false positives but very rarely - %% so we don't do anything to prevent them. - rand:bytes(rand:uniform(MaxSize)). + Bytes = rand:bytes(rand:uniform(MaxSize)), + %% We remove 255 to avoid false positives. In a running + %% rabbit node we will not get false positives because + %% we also check messages against the index. + << < 254; _ -> B end>> || <> <= Bytes >>. gen_msg_file(Config, Blocks) -> PrivDir = ?config(priv_dir, Config), @@ -667,8 +669,8 @@ gen_msg_file(Config, Blocks) -> {bin, Bin} -> Bin; {pad, Size} -> - %% This might generate false positives although very unlikely. - rand:bytes(Size); + %% Empty space between messages is expected to be zeroes. + <<0:Size/unit:8>>; {msg, MsgId, Msg} -> Size = 16 + byte_size(Msg), [<>, MsgId, Msg, <<255>>]