Skip to content

Commit

Permalink
Merge pull request #12721 from rabbitmq/loic-fix-cq-flake
Browse files Browse the repository at this point in the history
CQ: Fix flakes in the store file scan test
  • Loading branch information
michaelklishin authored Nov 14, 2024
2 parents 2795293 + db50739 commit 4ebfd7f
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 @@ -656,9 +656,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 @@ -668,8 +670,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 4ebfd7f

Please sign in to comment.