test(takeover): randomize messages for random natural ordering

This commit is contained in:
Andrew Mayorov 2023-09-08 13:37:30 +04:00
parent f022c9b1a4
commit 04731b7ef7
No known key found for this signature in database
GPG Key ID: 2837C62ACFBFED5D
1 changed files with 12 additions and 1 deletions

View File

@ -160,4 +160,15 @@ assert_messages_order([Msg | Ls1], [{publish, #{payload := No}} | Ls2]) ->
end.
messages(Cnt) ->
[emqx_message:make(ct, 1, ?TOPIC, integer_to_binary(I)) || I <- lists:seq(1, Cnt)].
[emqx_message:make(ct, 1, ?TOPIC, payload(I)) || I <- lists:seq(1, Cnt)].
payload(I) ->
% NOTE
% Introduce randomness so that natural order is not the same as arrival order.
iolist_to_binary(
io_lib:format("~4.16.0B [~B] [~s]", [
rand:uniform(16#10000) - 1,
I,
emqx_utils_calendar:now_to_rfc3339(millisecond)
])
).