diff options
| author | Jean-Sébastien Pédron <jean-sebastien@rabbitmq.com> | 2017-03-06 17:28:00 +0100 |
|---|---|---|
| committer | Jean-Sébastien Pédron <jean-sebastien@rabbitmq.com> | 2017-03-06 17:28:00 +0100 |
| commit | 609080c659b38a4336fff8c2331282fb72f89931 (patch) | |
| tree | 0c2ca5aa26e4f2229d56efb50751fa22260f905e /test | |
| parent | 9ae10c32aa6f1732969649dc23333e0e28ea62fe (diff) | |
| parent | bd4619cdd73691f7f990649996199def6880a1b7 (diff) | |
| download | rabbitmq-server-git-609080c659b38a4336fff8c2331282fb72f89931.tar.gz | |
Merge branch 'stable'
Diffstat (limited to 'test')
| -rw-r--r-- | test/metrics_SUITE.erl | 8 | ||||
| -rw-r--r-- | test/unit_inbroker_SUITE.erl | 48 |
2 files changed, 38 insertions, 18 deletions
diff --git a/test/metrics_SUITE.erl b/test/metrics_SUITE.erl index 14955d127d..a66e9cec3c 100644 --- a/test/metrics_SUITE.erl +++ b/test/metrics_SUITE.erl @@ -146,7 +146,7 @@ connection_metric_idemp(Config, {N, R}) -> Table2 = [ Pid || {Pid, _} <- read_table_rpc(Config, connection_coarse_metrics)], % referesh stats 'R' times [[Pid ! emit_stats || Pid <- Table] || _ <- lists:seq(1, R)], - timer:sleep(100), + force_metric_gc(Config), TableAfter = [ Pid || {Pid, _} <- read_table_rpc(Config, connection_metrics)], TableAfter2 = [ Pid || {Pid, _} <- read_table_rpc(Config, connection_coarse_metrics)], [rabbit_ct_client_helpers:close_connection(Conn) || Conn <- Conns], @@ -160,7 +160,7 @@ channel_metric_idemp(Config, {N, R}) -> Table2 = [ Pid || {Pid, _} <- read_table_rpc(Config, channel_process_metrics)], % referesh stats 'R' times [[Pid ! emit_stats || Pid <- Table] || _ <- lists:seq(1, R)], - timer:sleep(100), + force_metric_gc(Config), TableAfter = [ Pid || {Pid, _} <- read_table_rpc(Config, channel_metrics)], TableAfter2 = [ Pid || {Pid, _} <- read_table_rpc(Config, channel_process_metrics)], rabbit_ct_client_helpers:close_connection(Conn), @@ -184,7 +184,7 @@ queue_metric_idemp(Config, {N, R}) -> % referesh stats 'R' times ChanTable = read_table_rpc(Config, channel_created), [[Pid ! emit_stats || {Pid, _, _} <- ChanTable ] || _ <- lists:seq(1, R)], - timer:sleep(100), + force_metric_gc(Config), 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], @@ -398,7 +398,7 @@ read_table(Table) -> ets:tab2list(Table). force_metric_gc(Config) -> - timer:sleep(100), + timer:sleep(300), rabbit_ct_broker_helpers:rpc(Config, 0, erlang, send, [rabbit_core_metrics_gc, start_gc]), rabbit_ct_broker_helpers:rpc(Config, 0, gen_server, call, diff --git a/test/unit_inbroker_SUITE.erl b/test/unit_inbroker_SUITE.erl index f2451ce5c4..8439be45b3 100644 --- a/test/unit_inbroker_SUITE.erl +++ b/test/unit_inbroker_SUITE.erl @@ -2314,34 +2314,54 @@ channel_statistics1(_Config) -> %% Check the stats reflect that Check2 = fun() -> - [{{Ch, QRes}, 1, 0, 0, 0, 0, 0}] = ets:lookup( - channel_queue_metrics, - {Ch, QRes}), - [{{Ch, X}, 1, 0, 0}] = ets:lookup( - channel_exchange_metrics, - {Ch, X}), - [{{Ch, {QRes, X}}, 1}] = ets:lookup( - channel_queue_exchange_metrics, - {Ch, {QRes, X}}) + [{{Ch, QRes}, 1, 0, 0, 0, 0, 0, 0}] = ets:lookup( + channel_queue_metrics, + {Ch, QRes}), + [{{Ch, X}, 1, 0, 0, 0}] = ets:lookup( + channel_exchange_metrics, + {Ch, X}), + [{{Ch, {QRes, X}}, 1, 0}] = ets:lookup( + channel_queue_exchange_metrics, + {Ch, {QRes, X}}) end, test_ch_metrics(Check2, ?TIMEOUT), - %% Check the stats remove stuff on queue deletion + %% Check the stats are marked for removal on queue deletion. rabbit_channel:do(Ch, #'queue.delete'{queue = QName}), Check3 = fun() -> + [{{Ch, QRes}, 1, 0, 0, 0, 0, 0, 1}] = ets:lookup( + channel_queue_metrics, + {Ch, QRes}), + [{{Ch, X}, 1, 0, 0, 0}] = ets:lookup( + channel_exchange_metrics, + {Ch, X}), + [{{Ch, {QRes, X}}, 1, 1}] = ets:lookup( + channel_queue_exchange_metrics, + {Ch, {QRes, X}}) + end, + test_ch_metrics(Check3, ?TIMEOUT), + + %% Check the garbage collection removes stuff. + force_metric_gc(), + Check4 = fun() -> [] = ets:lookup(channel_queue_metrics, {Ch, QRes}), - [{{Ch, X}, 1, 0, 0}] = ets:lookup( - channel_exchange_metrics, - {Ch, X}), + [{{Ch, X}, 1, 0, 0, 0}] = ets:lookup( + channel_exchange_metrics, + {Ch, X}), [] = ets:lookup(channel_queue_exchange_metrics, {Ch, {QRes, X}}) end, - test_ch_metrics(Check3, ?TIMEOUT), + test_ch_metrics(Check4, ?TIMEOUT), rabbit_channel:shutdown(Ch), dummy_event_receiver:stop(), passed. +force_metric_gc() -> + timer:sleep(300), + rabbit_core_metrics_gc ! start_gc, + gen_server:call(rabbit_core_metrics_gc, test). + test_ch_metrics(Fun, Timeout) when Timeout =< 0 -> Fun(); test_ch_metrics(Fun, Timeout) -> |
