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.
This commit is contained in:
Jean-Sébastien Pédron 2025-07-16 14:59:07 +02:00
parent c4e9a9bf3d
commit 71ff25499c
No known key found for this signature in database
GPG Key ID: 39E99761A5FD94CC
1 changed files with 27 additions and 27 deletions

View File

@ -301,9 +301,9 @@ add_rem_counter(Config, {Initial, Ops}, {AddFun, RemFun}, Tables) ->
connection(Config) -> connection(Config) ->
Conn = rabbit_ct_client_helpers:open_unmanaged_connection(Config), Conn = rabbit_ct_client_helpers:open_unmanaged_connection(Config),
[_] = read_table_rpc(Config, connection_created), ?awaitMatch([_], read_table_rpc(Config, connection_created), 30000),
[_] = read_table_rpc(Config, connection_metrics), ?awaitMatch([_], read_table_rpc(Config, connection_metrics), 30000),
[_] = read_table_rpc(Config, connection_coarse_metrics), ?awaitMatch([_], read_table_rpc(Config, connection_coarse_metrics), 30000),
ok = rabbit_ct_client_helpers:close_connection(Conn), ok = rabbit_ct_client_helpers:close_connection(Conn),
force_metric_gc(Config), force_metric_gc(Config),
?awaitMatch([], read_table_rpc(Config, connection_created), ?awaitMatch([], read_table_rpc(Config, connection_created),
@ -317,25 +317,25 @@ connection(Config) ->
channel(Config) -> channel(Config) ->
Conn = rabbit_ct_client_helpers:open_unmanaged_connection(Config), Conn = rabbit_ct_client_helpers:open_unmanaged_connection(Config),
{ok, Chan} = amqp_connection:open_channel(Conn), {ok, Chan} = amqp_connection:open_channel(Conn),
[_] = read_table_rpc(Config, channel_created), ?awaitMatch([_], read_table_rpc(Config, channel_created), 30000),
[_] = read_table_rpc(Config, channel_metrics), ?awaitMatch([_], read_table_rpc(Config, channel_metrics), 30000),
[_] = read_table_rpc(Config, channel_process_metrics), ?awaitMatch([_], read_table_rpc(Config, channel_process_metrics), 30000),
ok = amqp_channel:close(Chan), ok = amqp_channel:close(Chan),
[] = read_table_rpc(Config, channel_created), ?awaitMatch([], read_table_rpc(Config, channel_created), 30000),
[] = read_table_rpc(Config, channel_metrics), ?awaitMatch([], read_table_rpc(Config, channel_metrics), 30000),
[] = read_table_rpc(Config, channel_process_metrics), ?awaitMatch([], read_table_rpc(Config, channel_process_metrics), 30000),
ok = rabbit_ct_client_helpers:close_connection(Conn). ok = rabbit_ct_client_helpers:close_connection(Conn).
channel_connection_close(Config) -> channel_connection_close(Config) ->
Conn = rabbit_ct_client_helpers:open_unmanaged_connection(Config), Conn = rabbit_ct_client_helpers:open_unmanaged_connection(Config),
{ok, _} = amqp_connection:open_channel(Conn), {ok, _} = amqp_connection:open_channel(Conn),
[_] = read_table_rpc(Config, channel_created), ?awaitMatch([_], read_table_rpc(Config, channel_created), 30000),
[_] = read_table_rpc(Config, channel_metrics), ?awaitMatch([_], read_table_rpc(Config, channel_metrics), 30000),
[_] = read_table_rpc(Config, channel_process_metrics), ?awaitMatch([_], read_table_rpc(Config, channel_process_metrics), 30000),
ok = rabbit_ct_client_helpers:close_connection(Conn), ok = rabbit_ct_client_helpers:close_connection(Conn),
[] = read_table_rpc(Config, channel_created), ?awaitMatch([], read_table_rpc(Config, channel_created), 30000),
[] = read_table_rpc(Config, channel_metrics), ?awaitMatch([], read_table_rpc(Config, channel_metrics), 30000),
[] = read_table_rpc(Config, channel_process_metrics). ?awaitMatch([], read_table_rpc(Config, channel_process_metrics), 30000).
channel_queue_delete_queue(Config) -> channel_queue_delete_queue(Config) ->
Conn = rabbit_ct_client_helpers:open_unmanaged_connection(Config), Conn = rabbit_ct_client_helpers:open_unmanaged_connection(Config),
@ -344,14 +344,14 @@ channel_queue_delete_queue(Config) ->
ensure_exchange_metrics_populated(Chan, Queue), ensure_exchange_metrics_populated(Chan, Queue),
ensure_channel_queue_metrics_populated(Chan, Queue), ensure_channel_queue_metrics_populated(Chan, Queue),
force_channel_stats(Config), force_channel_stats(Config),
[_] = read_table_rpc(Config, channel_queue_metrics), ?awaitMatch([_], read_table_rpc(Config, channel_queue_metrics), 30000),
[_] = read_table_rpc(Config, channel_queue_exchange_metrics), ?awaitMatch([_], read_table_rpc(Config, channel_queue_exchange_metrics), 30000),
delete_queue(Chan, Queue), delete_queue(Chan, Queue),
force_metric_gc(Config), force_metric_gc(Config),
% ensure removal of queue cleans up channel_queue metrics % ensure removal of queue cleans up channel_queue metrics
[] = read_table_rpc(Config, channel_queue_exchange_metrics), ?awaitMatch([], read_table_rpc(Config, channel_queue_exchange_metrics), 30000),
[] = read_table_rpc(Config, channel_queue_metrics), ?awaitMatch([], read_table_rpc(Config, channel_queue_metrics), 30000),
ok = rabbit_ct_client_helpers:close_connection(Conn), ok = rabbit_ct_client_helpers:close_connection(Conn),
ok. ok.
@ -362,26 +362,26 @@ channel_queue_exchange_consumer_close_connection(Config) ->
ensure_exchange_metrics_populated(Chan, Queue), ensure_exchange_metrics_populated(Chan, Queue),
force_channel_stats(Config), force_channel_stats(Config),
[_] = read_table_rpc(Config, channel_exchange_metrics), ?awaitMatch([_], read_table_rpc(Config, channel_exchange_metrics), 30000),
[_] = read_table_rpc(Config, channel_queue_exchange_metrics), ?awaitMatch([_], read_table_rpc(Config, channel_queue_exchange_metrics), 30000),
ensure_channel_queue_metrics_populated(Chan, Queue), ensure_channel_queue_metrics_populated(Chan, Queue),
force_channel_stats(Config), force_channel_stats(Config),
[_] = read_table_rpc(Config, channel_queue_metrics), ?awaitMatch([_], read_table_rpc(Config, channel_queue_metrics), 30000),
Sub = #'basic.consume'{queue = Queue}, Sub = #'basic.consume'{queue = Queue},
#'basic.consume_ok'{consumer_tag = _} = #'basic.consume_ok'{consumer_tag = _} =
amqp_channel:call(Chan, Sub), amqp_channel:call(Chan, Sub),
[_] = read_table_rpc(Config, consumer_created), ?awaitMatch([_], read_table_rpc(Config, consumer_created), 30000),
ok = rabbit_ct_client_helpers:close_connection(Conn), ok = rabbit_ct_client_helpers:close_connection(Conn),
% ensure cleanup happened % ensure cleanup happened
force_metric_gc(Config), force_metric_gc(Config),
[] = read_table_rpc(Config, channel_exchange_metrics), ?awaitMatch([], read_table_rpc(Config, channel_exchange_metrics), 30000),
[] = read_table_rpc(Config, channel_queue_exchange_metrics), ?awaitMatch([], read_table_rpc(Config, channel_queue_exchange_metrics), 30000),
[] = read_table_rpc(Config, channel_queue_metrics), ?awaitMatch([], read_table_rpc(Config, channel_queue_metrics), 30000),
[] = read_table_rpc(Config, consumer_created), ?awaitMatch([], read_table_rpc(Config, consumer_created), 30000),
ok. ok.