summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Klishin <mklishin@pivotal.io>2016-12-05 20:57:33 +0300
committerMichael Klishin <mklishin@pivotal.io>2016-12-05 20:57:33 +0300
commitd5e2ed834fd359626c5140c9f1608e836945d3ac (patch)
tree030b5a31c32f1470f7a76021a5bda5b7ea0f77b5
parent8b7e898d46846b02ce7ac918910219c52ceb3b33 (diff)
parent59a0b318574b04bb844bb3d8c43007af9f4ab91c (diff)
downloadrabbitmq-server-git-d5e2ed834fd359626c5140c9f1608e836945d3ac.tar.gz
Merge branch 'stable' into rabbitmq-auth-backend-ldap-7
-rw-r--r--test/metrics_SUITE.erl14
-rw-r--r--test/unit_inbroker_SUITE.erl73
2 files changed, 44 insertions, 43 deletions
diff --git a/test/metrics_SUITE.erl b/test/metrics_SUITE.erl
index 20bac74325..c70a7dc61f 100644
--- a/test/metrics_SUITE.erl
+++ b/test/metrics_SUITE.erl
@@ -88,26 +88,26 @@ end_per_testcase(Testcase, Config) ->
% NB: node_stats tests are in the management_agent repo
connection_metric_count_test(Config) ->
- rabbit_proper_helpers:run_proper(fun prop_connection_metric_count/1, [Config], 25).
+ rabbit_ct_proper_helpers:run_proper(fun prop_connection_metric_count/1, [Config], 25).
channel_metric_count_test(Config) ->
- rabbit_proper_helpers:run_proper(fun prop_channel_metric_count/1, [Config], 25).
+ rabbit_ct_proper_helpers:run_proper(fun prop_channel_metric_count/1, [Config], 25).
queue_metric_count_test(Config) ->
- rabbit_proper_helpers:run_proper(fun prop_queue_metric_count/1, [Config], 5).
+ rabbit_ct_proper_helpers:run_proper(fun prop_queue_metric_count/1, [Config], 5).
queue_metric_count_channel_per_queue_test(Config) ->
- rabbit_proper_helpers:run_proper(fun prop_queue_metric_count_channel_per_queue/1,
+ rabbit_ct_proper_helpers:run_proper(fun prop_queue_metric_count_channel_per_queue/1,
[Config], 5).
connection_metric_idemp_test(Config) ->
- rabbit_proper_helpers:run_proper(fun prop_connection_metric_idemp/1, [Config], 25).
+ rabbit_ct_proper_helpers:run_proper(fun prop_connection_metric_idemp/1, [Config], 25).
channel_metric_idemp_test(Config) ->
- rabbit_proper_helpers:run_proper(fun prop_channel_metric_idemp/1, [Config], 25).
+ rabbit_ct_proper_helpers:run_proper(fun prop_channel_metric_idemp/1, [Config], 25).
queue_metric_idemp_test(Config) ->
- rabbit_proper_helpers:run_proper(fun prop_queue_metric_idemp/1, [Config], 25).
+ rabbit_ct_proper_helpers:run_proper(fun prop_queue_metric_idemp/1, [Config], 25).
prop_connection_metric_idemp(Config) ->
?FORALL(N, {integer(1, 25), integer(1, 25)},
diff --git a/test/unit_inbroker_SUITE.erl b/test/unit_inbroker_SUITE.erl
index 98cd77ccbe..f80f83c391 100644
--- a/test/unit_inbroker_SUITE.erl
+++ b/test/unit_inbroker_SUITE.erl
@@ -2907,10 +2907,13 @@ channel_statistics1(_Config) ->
dummy_event_receiver:start(self(), [node()], [channel_stats]),
%% Check stats empty
- Event = test_ch_statistics_receive_event(Ch, fun (_) -> true end),
- [] = proplists:get_value(channel_queue_stats, Event),
- [] = proplists:get_value(channel_exchange_stats, Event),
- [] = proplists:get_value(channel_queue_exchange_stats, Event),
+ Check1 = fun() ->
+ [] = ets:match(channel_queue_metrics, {Ch, QRes}),
+ [] = ets:match(channel_exchange_metrics, {Ch, X}),
+ [] = ets:match(channel_queue_exchange_metrics,
+ {Ch, {QRes, X}})
+ end,
+ test_ch_metrics(Check1, ?TIMEOUT),
%% Publish and get a message
rabbit_channel:do(Ch, #'basic.publish'{exchange = <<"">>,
@@ -2919,46 +2922,44 @@ channel_statistics1(_Config) ->
rabbit_channel:do(Ch, #'basic.get'{queue = QName}),
%% Check the stats reflect that
- Event2 = test_ch_statistics_receive_event(
- Ch,
- fun (E) ->
- length(proplists:get_value(
- channel_queue_exchange_stats, E)) > 0
- end),
- [{QRes, [{get,1}]}] = proplists:get_value(channel_queue_stats, Event2),
- [{X,[{publish,1}]}] = proplists:get_value(channel_exchange_stats, Event2),
- [{{QRes,X},[{publish,1}]}] =
- proplists:get_value(channel_queue_exchange_stats, Event2),
+ 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}})
+ end,
+ test_ch_metrics(Check2, ?TIMEOUT),
%% Check the stats remove stuff on queue deletion
rabbit_channel:do(Ch, #'queue.delete'{queue = QName}),
- Event3 = test_ch_statistics_receive_event(
- Ch,
- fun (E) ->
- length(proplists:get_value(
- channel_queue_exchange_stats, E)) == 0
- end),
-
- [] = proplists:get_value(channel_queue_stats, Event3),
- [{X,[{publish,1}]}] = proplists:get_value(channel_exchange_stats, Event3),
- [] = proplists:get_value(channel_queue_exchange_stats, Event3),
+ Check3 = fun() ->
+ [] = ets:lookup(channel_queue_metrics, {Ch, QRes}),
+ [{{Ch, X}, 1, 0, 0}] = ets:lookup(
+ channel_exchange_metrics,
+ {Ch, X}),
+ [] = ets:lookup(channel_queue_exchange_metrics,
+ {Ch, {QRes, X}})
+ end,
+ test_ch_metrics(Check3, ?TIMEOUT),
rabbit_channel:shutdown(Ch),
dummy_event_receiver:stop(),
passed.
-test_ch_statistics_receive_event(Ch, Matcher) ->
- rabbit_channel:flush(Ch),
- Ch ! emit_stats,
- test_ch_statistics_receive_event1(Ch, Matcher).
-
-test_ch_statistics_receive_event1(Ch, Matcher) ->
- receive #event{type = channel_stats, props = Props} ->
- case Matcher(Props) of
- true -> Props;
- _ -> test_ch_statistics_receive_event1(Ch, Matcher)
- end
- after ?TIMEOUT -> throw(failed_to_receive_event)
+test_ch_metrics(Fun, Timeout) when Timeout =< 0 ->
+ Fun();
+test_ch_metrics(Fun, Timeout) ->
+ try
+ Fun()
+ catch
+ _:{badmatch, _} ->
+ timer:sleep(1000),
+ test_ch_metrics(Fun, Timeout - 1000)
end.
head_message_timestamp_statistics(Config) ->