summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorkjnilsson <knilsson@pivotal.io>2017-07-11 10:26:05 +0100
committerkjnilsson <knilsson@pivotal.io>2017-07-11 10:26:05 +0100
commit6f374fb48a5cc9972ce0bfcf747faa380e1d1e4d (patch)
tree877ee81539bf9e97bd5f1534eb96353888db7342 /test
parent26a1ade4bfff245a00936c4e74953c45bb54e784 (diff)
downloadrabbitmq-server-git-6f374fb48a5cc9972ce0bfcf747faa380e1d1e4d.tar.gz
Replace timer:sleep with a loop waiting on a predicate.
To make it more likely to pass on resource constrained environments.
Diffstat (limited to 'test')
-rw-r--r--test/rabbit_core_metrics_gc_SUITE.erl20
1 files changed, 15 insertions, 5 deletions
diff --git a/test/rabbit_core_metrics_gc_SUITE.erl b/test/rabbit_core_metrics_gc_SUITE.erl
index d63c9ab2fb..8d15afb95c 100644
--- a/test/rabbit_core_metrics_gc_SUITE.erl
+++ b/test/rabbit_core_metrics_gc_SUITE.erl
@@ -370,12 +370,13 @@ cluster_queue_metrics(Config) ->
ok = rabbit_ct_broker_helpers:rpc(Config, Node0, rabbit_amqqueue,
sync_mirrors, [QPid]),
- timer:sleep(1500),
-
% Check ETS table for data
- % rabbit_core_metrics:queue_stats
- [] = rabbit_ct_broker_helpers:rpc(Config, Node0, ets, tab2list,
- [queue_coarse_metrics]),
+ wait_for(fun () ->
+ [] =:= rabbit_ct_broker_helpers:rpc(
+ Config, Node0, ets, tab2list,
+ [queue_coarse_metrics])
+ end, 60),
+
[{Name, 1, 0, 1, _}] = rabbit_ct_broker_helpers:rpc(Config, Node1, ets,
tab2list,
@@ -384,3 +385,12 @@ cluster_queue_metrics(Config) ->
amqp_channel:call(Ch, #'queue.delete'{queue=QueueName}),
rabbit_ct_client_helpers:close_channel(Ch),
Config.
+
+wait_for(_Fun, 0) -> false;
+wait_for(Fun, Seconds) ->
+ case Fun() of
+ true -> ok;
+ false ->
+ timer:sleep(1000),
+ wait_for(Fun, Seconds - 1)
+ end.