Skip to content

Commit

Permalink
CQ: Fix flakes in the store file scan test
Browse files Browse the repository at this point in the history
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 db50739)
  • Loading branch information
lhoguin authored and mergify[bot] committed Nov 14, 2024
1 parent eeaa668 commit d211f19
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions deps/rabbit/test/backing_queue_SUITE.erl
Original file line number Diff line number Diff line change
Expand Up @@ -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.
<< <<case B of 255 -> 254; _ -> B end>> || <<B>> <= Bytes >>.

gen_msg_file(Config, Blocks) ->
PrivDir = ?config(priv_dir, Config),
Expand All @@ -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),
[<<Size:64>>, MsgId, Msg, <<255>>]
Expand Down

0 comments on commit d211f19

Please sign in to comment.