Skip to content

Commit 4ebfd7f

Browse files
Merge pull request #12721 from rabbitmq/loic-fix-cq-flake
CQ: Fix flakes in the store file scan test
2 parents 2795293 + db50739 commit 4ebfd7f

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

deps/rabbit/test/backing_queue_SUITE.erl

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -656,9 +656,11 @@ gen_msg() ->
656656
gen_msg(1024 * 1024).
657657

658658
gen_msg(MaxSize) ->
659-
%% This might generate false positives but very rarely
660-
%% so we don't do anything to prevent them.
661-
rand:bytes(rand:uniform(MaxSize)).
659+
Bytes = rand:bytes(rand:uniform(MaxSize)),
660+
%% We remove 255 to avoid false positives. In a running
661+
%% rabbit node we will not get false positives because
662+
%% we also check messages against the index.
663+
<< <<case B of 255 -> 254; _ -> B end>> || <<B>> <= Bytes >>.
662664

663665
gen_msg_file(Config, Blocks) ->
664666
PrivDir = ?config(priv_dir, Config),
@@ -668,8 +670,8 @@ gen_msg_file(Config, Blocks) ->
668670
{bin, Bin} ->
669671
Bin;
670672
{pad, Size} ->
671-
%% This might generate false positives although very unlikely.
672-
rand:bytes(Size);
673+
%% Empty space between messages is expected to be zeroes.
674+
<<0:Size/unit:8>>;
673675
{msg, MsgId, Msg} ->
674676
Size = 16 + byte_size(Msg),
675677
[<<Size:64>>, MsgId, Msg, <<255>>]

0 commit comments

Comments
 (0)