summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authordcorbacho <dparracorbacho@piotal.io>2019-10-21 16:16:09 +0100
committerdcorbacho <dparracorbacho@piotal.io>2019-10-21 16:16:09 +0100
commit64f9705667a2712841a066722299b3bfa7eaa7a9 (patch)
treeae507d9cdf1d313757654f0c5cd05525db4dd115
parente0152b984880340a57c0d19942a0bd7de73b79ad (diff)
downloadrabbitmq-server-git-64f9705667a2712841a066722299b3bfa7eaa7a9.tar.gz
Make test more resilient to timing changes
* Drain the mailbox of the process until the expected message arrives. If tests are slower for some reason, we might generate more events as they're emitted on an interval by the queue process.
-rw-r--r--test/unit_inbroker_non_parallel_SUITE.erl32
1 files changed, 24 insertions, 8 deletions
diff --git a/test/unit_inbroker_non_parallel_SUITE.erl b/test/unit_inbroker_non_parallel_SUITE.erl
index 9b86d93917..5504265da9 100644
--- a/test/unit_inbroker_non_parallel_SUITE.erl
+++ b/test/unit_inbroker_non_parallel_SUITE.erl
@@ -605,8 +605,12 @@ head_message_timestamp1(_Config) ->
dummy_event_receiver:start(self(), [node()], [queue_stats]),
%% Check timestamp is empty when queue is empty
- Event1 = test_queue_statistics_receive_event(QPid, fun (E) -> proplists:get_value(name, E) == QRes end),
- '' = proplists:get_value(head_message_timestamp, Event1),
+ test_queue_statistics_receive_event(QPid,
+ fun (E) ->
+ (proplists:get_value(name, E) == QRes)
+ and
+ (proplists:get_value(head_message_timestamp, E) == '')
+ end),
rabbit_channel:do(Ch, #'tx.select'{}),
receive #'tx.select_ok'{} -> ok
@@ -625,18 +629,30 @@ head_message_timestamp1(_Config) ->
receive #'tx.commit_ok'{} -> ok
after ?TIMEOUT -> throw(failed_to_receive_tx_commit_ok)
end,
- Event2 = test_queue_statistics_receive_event(QPid, fun (E) -> proplists:get_value(name, E) == QRes end),
- ?assertEqual(1, proplists:get_value(head_message_timestamp, Event2)),
+ test_queue_statistics_receive_event(QPid,
+ fun (E) ->
+ (proplists:get_value(name, E) == QRes)
+ and
+ (proplists:get_value(head_message_timestamp, E) == 1)
+ end),
%% Get first message and check timestamp is that of second message
rabbit_channel:do(Ch, #'basic.get'{queue = QName, no_ack = true}),
- Event3 = test_queue_statistics_receive_event(QPid, fun (E) -> proplists:get_value(name, E) == QRes end),
- ?assertEqual(2, proplists:get_value(head_message_timestamp, Event3)),
+ test_queue_statistics_receive_event(QPid,
+ fun (E) ->
+ (proplists:get_value(name, E) == QRes)
+ and
+ (proplists:get_value(head_message_timestamp, E) == 2)
+ end),
%% Get second message and check timestamp is empty again
rabbit_channel:do(Ch, #'basic.get'{queue = QName, no_ack = true}),
- Event4 = test_queue_statistics_receive_event(QPid, fun (E) -> proplists:get_value(name, E) == QRes end),
- '' = proplists:get_value(head_message_timestamp, Event4),
+ test_queue_statistics_receive_event(QPid,
+ fun (E) ->
+ (proplists:get_value(name, E) == QRes)
+ and
+ (proplists:get_value(head_message_timestamp, E) == '')
+ end),
%% Teardown
rabbit_channel:do(Ch, #'queue.delete'{queue = QName}),