Skip to content

Commit 46f335e

Browse files
kjnilssonmichaelklishin
authored andcommitted
Merge pull request #2145 from rabbitmq/head-timestamp-test
Make test more resilient to timing changes (cherry picked from commit d9bfc86)
1 parent 2e632e1 commit 46f335e

File tree

1 file changed

+24
-8
lines changed

1 file changed

+24
-8
lines changed

test/unit_inbroker_non_parallel_SUITE.erl

Lines changed: 24 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -590,8 +590,12 @@ head_message_timestamp1(_Config) ->
590590
dummy_event_receiver:start(self(), [node()], [queue_stats]),
591591

592592
%% Check timestamp is empty when queue is empty
593-
Event1 = test_queue_statistics_receive_event(QPid, fun (E) -> proplists:get_value(name, E) == QRes end),
594-
'' = proplists:get_value(head_message_timestamp, Event1),
593+
test_queue_statistics_receive_event(QPid,
594+
fun (E) ->
595+
(proplists:get_value(name, E) == QRes)
596+
and
597+
(proplists:get_value(head_message_timestamp, E) == '')
598+
end),
595599

596600
rabbit_channel:do(Ch, #'tx.select'{}),
597601
receive #'tx.select_ok'{} -> ok
@@ -610,18 +614,30 @@ head_message_timestamp1(_Config) ->
610614
receive #'tx.commit_ok'{} -> ok
611615
after ?TIMEOUT -> throw(failed_to_receive_tx_commit_ok)
612616
end,
613-
Event2 = test_queue_statistics_receive_event(QPid, fun (E) -> proplists:get_value(name, E) == QRes end),
614-
?assertEqual(1, proplists:get_value(head_message_timestamp, Event2)),
617+
test_queue_statistics_receive_event(QPid,
618+
fun (E) ->
619+
(proplists:get_value(name, E) == QRes)
620+
and
621+
(proplists:get_value(head_message_timestamp, E) == 1)
622+
end),
615623

616624
%% Get first message and check timestamp is that of second message
617625
rabbit_channel:do(Ch, #'basic.get'{queue = QName, no_ack = true}),
618-
Event3 = test_queue_statistics_receive_event(QPid, fun (E) -> proplists:get_value(name, E) == QRes end),
619-
?assertEqual(2, proplists:get_value(head_message_timestamp, Event3)),
626+
test_queue_statistics_receive_event(QPid,
627+
fun (E) ->
628+
(proplists:get_value(name, E) == QRes)
629+
and
630+
(proplists:get_value(head_message_timestamp, E) == 2)
631+
end),
620632

621633
%% Get second message and check timestamp is empty again
622634
rabbit_channel:do(Ch, #'basic.get'{queue = QName, no_ack = true}),
623-
Event4 = test_queue_statistics_receive_event(QPid, fun (E) -> proplists:get_value(name, E) == QRes end),
624-
'' = proplists:get_value(head_message_timestamp, Event4),
635+
test_queue_statistics_receive_event(QPid,
636+
fun (E) ->
637+
(proplists:get_value(name, E) == QRes)
638+
and
639+
(proplists:get_value(head_message_timestamp, E) == '')
640+
end),
625641

626642
%% Teardown
627643
rabbit_channel:do(Ch, #'queue.delete'{queue = QName}),

0 commit comments

Comments
 (0)