From 34c1fd13d9a25034b1bc0f03a51e9fa758cbf3c8 Mon Sep 17 00:00:00 2001 From: Diana Parra Corbacho Date: Wed, 30 Oct 2024 12:00:57 +0100 Subject: [PATCH 1/3] Tests: wait for connection closed in metrics_SUITE --- deps/rabbit/test/metrics_SUITE.erl | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/deps/rabbit/test/metrics_SUITE.erl b/deps/rabbit/test/metrics_SUITE.erl index 4cdbbd549b5f..7e5c0f8d6cf5 100644 --- a/deps/rabbit/test/metrics_SUITE.erl +++ b/deps/rabbit/test/metrics_SUITE.erl @@ -46,7 +46,8 @@ merge_app_env(Config) -> rabbit_ct_helpers:merge_app_env(Config, {rabbit, [ {collect_statistics, fine}, - {collect_statistics_interval, 500} + {collect_statistics_interval, 500}, + {core_metrics_gc_interval, 5000} ]}). init_per_suite(Config) -> rabbit_ct_helpers:log_environment(), @@ -295,9 +296,12 @@ connection(Config) -> [_] = read_table_rpc(Config, connection_coarse_metrics), ok = rabbit_ct_client_helpers:close_connection(Conn), force_metric_gc(Config), - [] = read_table_rpc(Config, connection_created), - [] = read_table_rpc(Config, connection_metrics), - [] = read_table_rpc(Config, connection_coarse_metrics), + ?awaitMatch([], read_table_rpc(Config, connection_created), + 30000), + ?awaitMatch([], read_table_rpc(Config, connection_metrics), + 30000), + ?awaitMatch([], read_table_rpc(Config, connection_coarse_metrics), + 30000), ok. channel(Config) -> From e1c22a0d2aaed18531eeaddccf836cf7c3d3fa25 Mon Sep 17 00:00:00 2001 From: Diana Parra Corbacho Date: Wed, 30 Oct 2024 19:37:41 +0100 Subject: [PATCH 2/3] Test: wait for metrics --- .../test/prometheus_rabbitmq_federation_collector_SUITE.erl | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/deps/rabbitmq_federation_prometheus/test/prometheus_rabbitmq_federation_collector_SUITE.erl b/deps/rabbitmq_federation_prometheus/test/prometheus_rabbitmq_federation_collector_SUITE.erl index 5a15a0ffb4d9..92947807fa2c 100644 --- a/deps/rabbitmq_federation_prometheus/test/prometheus_rabbitmq_federation_collector_SUITE.erl +++ b/deps/rabbitmq_federation_prometheus/test/prometheus_rabbitmq_federation_collector_SUITE.erl @@ -94,8 +94,10 @@ single_link_then_second_added(Config) -> timer:sleep(3000), [_L1] = rabbit_ct_broker_helpers:rpc(Config, 0, rabbit_federation_status, status, []), - MFs = get_metrics(Config), - [?ONE_RUNNING_METRIC] = MFs, + rabbit_ct_helpers:eventually(?_assertEqual([?ONE_RUNNING_METRIC], + get_metrics(Config)), + 500, + 5), maybe_declare_queue(Config, Ch, q(<<"fed.downstream2">>, [{<<"x-queue-type">>, longstr, <<"classic">>}])), %% here we race against queue.declare... most of the times there is going to be %% new status=starting metric. In this case we wait a bit more for running=2. From 0df71d54cbd91e8db30ea1d051c36b7f8fc1e140 Mon Sep 17 00:00:00 2001 From: Diana Parra Corbacho Date: Thu, 31 Oct 2024 09:21:55 +0100 Subject: [PATCH 3/3] Test: metrics_SUITE queue_idemp wait for queue metrics --- deps/rabbit/test/metrics_SUITE.erl | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/deps/rabbit/test/metrics_SUITE.erl b/deps/rabbit/test/metrics_SUITE.erl index 7e5c0f8d6cf5..b740a24207c8 100644 --- a/deps/rabbit/test/metrics_SUITE.erl +++ b/deps/rabbit/test/metrics_SUITE.erl @@ -187,6 +187,10 @@ queue_metric_idemp(Config, {N, R}) -> Queue end || _ <- lists:seq(1, N)], + ?awaitMatch(N, length(read_table_rpc(Config, queue_metrics)), + 30000), + ?awaitMatch(N, length(read_table_rpc(Config, queue_coarse_metrics)), + 30000), Table = [ Pid || {Pid, _, _} <- read_table_rpc(Config, queue_metrics)], Table2 = [ Pid || {Pid, _, _} <- read_table_rpc(Config, queue_coarse_metrics)], % refresh stats 'R' times @@ -196,12 +200,16 @@ queue_metric_idemp(Config, {N, R}) -> gen_server2:call(Pid, flush) end|| {Pid, _, _} <- ChanTable ] || _ <- lists:seq(1, R)], force_metric_gc(Config), + ?awaitMatch(N, length(read_table_rpc(Config, queue_metrics)), + 30000), + ?awaitMatch(N, length(read_table_rpc(Config, queue_coarse_metrics)), + 30000), TableAfter = [ Pid || {Pid, _, _} <- read_table_rpc(Config, queue_metrics)], TableAfter2 = [ Pid || {Pid, _, _} <- read_table_rpc(Config, queue_coarse_metrics)], [ delete_queue(Chan, Q) || Q <- Queues], rabbit_ct_client_helpers:close_connection(Conn), - (Table2 == TableAfter2) and (Table == TableAfter) and - (N == length(Table)) and (N == length(TableAfter)). + (lists:sort(Table2) == lists:sort(TableAfter2)) + and (lists:sort(Table) == lists:sort(TableAfter)). connection_metric_count(Config, Ops) -> add_rem_counter(Config, Ops,