Skip to content

Commit 87fcd0b

Browse files
committed
metrics_SUITE: Wait for ETS table to be up-to-date
... in several test cases. [Why] In CI or any slow and/or busy environment, it may take time for the ETS tables to ge updated.
1 parent 63d06c1 commit 87fcd0b

File tree

1 file changed

+27
-27
lines changed

1 file changed

+27
-27
lines changed

deps/rabbit/test/metrics_SUITE.erl

Lines changed: 27 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -301,9 +301,9 @@ add_rem_counter(Config, {Initial, Ops}, {AddFun, RemFun}, Tables) ->
301301

302302
connection(Config) ->
303303
Conn = rabbit_ct_client_helpers:open_unmanaged_connection(Config),
304-
[_] = read_table_rpc(Config, connection_created),
305-
[_] = read_table_rpc(Config, connection_metrics),
306-
[_] = read_table_rpc(Config, connection_coarse_metrics),
304+
?awaitMatch([_], read_table_rpc(Config, connection_created), 30000),
305+
?awaitMatch([_], read_table_rpc(Config, connection_metrics), 30000),
306+
?awaitMatch([_], read_table_rpc(Config, connection_coarse_metrics), 30000),
307307
ok = rabbit_ct_client_helpers:close_connection(Conn),
308308
force_metric_gc(Config),
309309
?awaitMatch([], read_table_rpc(Config, connection_created),
@@ -317,25 +317,25 @@ connection(Config) ->
317317
channel(Config) ->
318318
Conn = rabbit_ct_client_helpers:open_unmanaged_connection(Config),
319319
{ok, Chan} = amqp_connection:open_channel(Conn),
320-
[_] = read_table_rpc(Config, channel_created),
321-
[_] = read_table_rpc(Config, channel_metrics),
322-
[_] = read_table_rpc(Config, channel_process_metrics),
320+
?awaitMatch([_], read_table_rpc(Config, channel_created), 30000),
321+
?awaitMatch([_], read_table_rpc(Config, channel_metrics), 30000),
322+
?awaitMatch([_], read_table_rpc(Config, channel_process_metrics), 30000),
323323
ok = amqp_channel:close(Chan),
324-
[] = read_table_rpc(Config, channel_created),
325-
[] = read_table_rpc(Config, channel_metrics),
326-
[] = read_table_rpc(Config, channel_process_metrics),
324+
?awaitMatch([], read_table_rpc(Config, channel_created), 30000),
325+
?awaitMatch([], read_table_rpc(Config, channel_metrics), 30000),
326+
?awaitMatch([], read_table_rpc(Config, channel_process_metrics), 30000),
327327
ok = rabbit_ct_client_helpers:close_connection(Conn).
328328

329329
channel_connection_close(Config) ->
330330
Conn = rabbit_ct_client_helpers:open_unmanaged_connection(Config),
331331
{ok, _} = amqp_connection:open_channel(Conn),
332-
[_] = read_table_rpc(Config, channel_created),
333-
[_] = read_table_rpc(Config, channel_metrics),
334-
[_] = read_table_rpc(Config, channel_process_metrics),
332+
?awaitMatch([_], read_table_rpc(Config, channel_created), 30000),
333+
?awaitMatch([_], read_table_rpc(Config, channel_metrics), 30000),
334+
?awaitMatch([_], read_table_rpc(Config, channel_process_metrics), 30000),
335335
ok = rabbit_ct_client_helpers:close_connection(Conn),
336-
[] = read_table_rpc(Config, channel_created),
337-
[] = read_table_rpc(Config, channel_metrics),
338-
[] = read_table_rpc(Config, channel_process_metrics).
336+
?awaitMatch([], read_table_rpc(Config, channel_created), 30000),
337+
?awaitMatch([], read_table_rpc(Config, channel_metrics), 30000),
338+
?awaitMatch([], read_table_rpc(Config, channel_process_metrics), 30000).
339339

340340
channel_queue_delete_queue(Config) ->
341341
Conn = rabbit_ct_client_helpers:open_unmanaged_connection(Config),
@@ -344,14 +344,14 @@ channel_queue_delete_queue(Config) ->
344344
ensure_exchange_metrics_populated(Chan, Queue),
345345
ensure_channel_queue_metrics_populated(Chan, Queue),
346346
force_channel_stats(Config),
347-
[_] = read_table_rpc(Config, channel_queue_metrics),
348-
[_] = read_table_rpc(Config, channel_queue_exchange_metrics),
347+
?awaitMatch([_], read_table_rpc(Config, channel_queue_metrics), 30000),
348+
?awaitMatch([_], read_table_rpc(Config, channel_queue_exchange_metrics), 30000),
349349

350350
delete_queue(Chan, Queue),
351351
force_metric_gc(Config),
352352
% ensure removal of queue cleans up channel_queue metrics
353-
[] = read_table_rpc(Config, channel_queue_exchange_metrics),
354-
[] = read_table_rpc(Config, channel_queue_metrics),
353+
?awaitMatch([], read_table_rpc(Config, channel_queue_exchange_metrics), 30000),
354+
?awaitMatch([], read_table_rpc(Config, channel_queue_metrics), 30000),
355355
ok = rabbit_ct_client_helpers:close_connection(Conn),
356356
ok.
357357

@@ -362,26 +362,26 @@ channel_queue_exchange_consumer_close_connection(Config) ->
362362
ensure_exchange_metrics_populated(Chan, Queue),
363363
force_channel_stats(Config),
364364

365-
[_] = read_table_rpc(Config, channel_exchange_metrics),
366-
[_] = read_table_rpc(Config, channel_queue_exchange_metrics),
365+
?awaitMatch([_], read_table_rpc(Config, channel_exchange_metrics), 30000),
366+
?awaitMatch([_], read_table_rpc(Config, channel_queue_exchange_metrics), 30000),
367367

368368
ensure_channel_queue_metrics_populated(Chan, Queue),
369369
force_channel_stats(Config),
370-
[_] = read_table_rpc(Config, channel_queue_metrics),
370+
?awaitMatch([_], read_table_rpc(Config, channel_queue_metrics), 30000),
371371

372372
Sub = #'basic.consume'{queue = Queue},
373373
#'basic.consume_ok'{consumer_tag = _} =
374374
amqp_channel:call(Chan, Sub),
375375

376-
[_] = read_table_rpc(Config, consumer_created),
376+
?awaitMatch([_], read_table_rpc(Config, consumer_created), 30000),
377377

378378
ok = rabbit_ct_client_helpers:close_connection(Conn),
379379
% ensure cleanup happened
380380
force_metric_gc(Config),
381-
[] = read_table_rpc(Config, channel_exchange_metrics),
382-
[] = read_table_rpc(Config, channel_queue_exchange_metrics),
383-
[] = read_table_rpc(Config, channel_queue_metrics),
384-
[] = read_table_rpc(Config, consumer_created),
381+
?awaitMatch([], read_table_rpc(Config, channel_exchange_metrics), 30000),
382+
?awaitMatch([], read_table_rpc(Config, channel_queue_exchange_metrics), 30000),
383+
?awaitMatch([], read_table_rpc(Config, channel_queue_metrics), 30000),
384+
?awaitMatch([], read_table_rpc(Config, consumer_created), 30000),
385385
ok.
386386

387387

0 commit comments

Comments
 (0)