Skip to content

Commit b9669ca

Browse files
Merge pull request #12724 from rabbitmq/mergify/bp/v4.0.x/pr-12721
CQ: Fix flakes in the store file scan test (backport #12721)
2 parents eeaa668 + d211f19 commit b9669ca

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

deps/rabbit/test/backing_queue_SUITE.erl

+7-5
Original file line numberDiff line numberDiff line change
@@ -655,9 +655,11 @@ gen_msg() ->
655655
gen_msg(1024 * 1024).
656656

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

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

0 commit comments

Comments
 (0)