diff --git a/deps/rabbit/test/metrics_SUITE.erl b/deps/rabbit/test/metrics_SUITE.erl index 4f83f0959f5a..fb7fe75a3d28 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(), @@ -186,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 @@ -195,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, @@ -293,9 +302,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) -> diff --git a/deps/rabbitmq_prometheus/test/prometheus_rabbitmq_federation_collector_SUITE.erl b/deps/rabbitmq_prometheus/test/prometheus_rabbitmq_federation_collector_SUITE.erl index 0e83efc8cbce..b54a77f80e04 100644 --- a/deps/rabbitmq_prometheus/test/prometheus_rabbitmq_federation_collector_SUITE.erl +++ b/deps/rabbitmq_prometheus/test/prometheus_rabbitmq_federation_collector_SUITE.erl @@ -101,8 +101,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.