From 779b69870001637f05525c3199e1dd3f6de6dbdd Mon Sep 17 00:00:00 2001 From: lordnull Date: Thu, 6 Mar 2014 14:26:21 -0600 Subject: [PATCH 1/2] Fixes wm stats for multiple client connections --- src/riak_repl_wm_stats.erl | 56 ++++++++++++++++++++++++---- test/riak_core_cluster_mgr_tests.erl | 2 +- 2 files changed, 49 insertions(+), 9 deletions(-) diff --git a/src/riak_repl_wm_stats.erl b/src/riak_repl_wm_stats.erl index eaf99ebb..5501642a 100644 --- a/src/riak_repl_wm_stats.erl +++ b/src/riak_repl_wm_stats.erl @@ -157,17 +157,18 @@ jsonify_stats([{K, V}|T], Acc) when is_atom(K) and is_tuple(V) jsonify_stats([{active, false}, {reactivation_scheduled, true} | T], Acc) end; jsonify_stats([{K,V}|T], Acc) when is_atom(K) - andalso (K == server_stats orelse K == client_stats) -> - case V of - [{Pid, Mq, {status, Stats}}] -> + andalso (K == server_stats orelse K == client_stats), is_list(V) -> + StackedStats = lists:foldl(fun + ({Pid, Mq, {status, Stats}}, FoldAcc) -> FormattedPid = format_pid(Pid), NewStats = {status, lists:map(fun format_pid_stat/1, Stats)}, % could be client or server pid - ServerPid = [{pid, FormattedPid}], - jsonify_stats([NewStats | T], [Mq | [ServerPid | Acc]]); - [] -> - jsonify_stats(T, Acc) - end; + ServerPid = {pid, FormattedPid}, + [ServerPid, Mq, NewStats] ++ FoldAcc; + (_, FoldAcc) -> + FoldAcc + end, [], V), + jsonify_stats(StackedStats ++ T, Acc); jsonify_stats([{S,IP,Port}|T], Acc) when is_atom(S) andalso is_list(IP) andalso is_integer(Port) -> jsonify_stats(T, [{S, list_to_binary(IP++":"++integer_to_list(Port))}|Acc]); @@ -392,6 +393,45 @@ jsonify_stats_test_() -> _Result = mochijson2:encode({struct, Actual}) % fail if crash end}, + {"multiple fs client connections", + fun() -> + Pid = spawn(fun() -> ok end), + Actual = [{client_stats, [ + {Pid, {message_queue_len,0}, {status, [ + {node,'riak@test-riak-1'}, + {site,"test3"}, + {strategy,riak_repl_keylist_server}, + {fullsync_worker,Pid}, + {queue_pid,Pid}, + {dropped_count,0}, + {queue_length,0}, + {queue_byte_size,0}, + {queue_max_size,104857600}, + {queue_percentage,0}, + {queue_pending,0}, + {queue_max_pending,5}, + {state,wait_for_partition} + ]}}, + {Pid, {message_queue_len,0}, {status, [ + {node,'riak@test-riak-1'}, + {site,"site2"}, + {strategy,riak_repl_keylist_server}, + {fullsync_worker,Pid}, + {queue_pid,Pid}, + {dropped_count,0}, + {queue_length,0}, + {queue_byte_size,0}, + {queue_max_size,104857600}, + {queue_percentage,0}, + {queue_pending,0}, + {queue_max_pending,5}, + {state,wait_for_partition} + ]}} + ]}], + Jsonified = jsonify_stats(Actual, []), + _ = mochijson2:encode({struct, Jsonified}) + end}, + %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%% tests during basho bench, bnw fullsync, 1.2 + 1.3 realtime, source side diff --git a/test/riak_core_cluster_mgr_tests.erl b/test/riak_core_cluster_mgr_tests.erl index 92a6b77d..69b28e6c 100644 --- a/test/riak_core_cluster_mgr_tests.erl +++ b/test/riak_core_cluster_mgr_tests.erl @@ -5,7 +5,7 @@ -compile(export_all). -include("riak_core_cluster.hrl"). --include_lib("riak_core/include/riak_core_connection.hrl"). +-include("riak_core_connection.hrl"). -include_lib("eunit/include/eunit.hrl"). -define(TRACE(Stmt),Stmt). From 2a8d4647ba31349698315d6a63d28e732b5bbece Mon Sep 17 00:00:00 2001 From: lordnull Date: Mon, 10 Mar 2014 09:50:37 -0500 Subject: [PATCH 2/2] Fixed cluster mgr sup tests so they compile and run. --- test/riak_core_cluster_mgr_sup_tests.erl | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/riak_core_cluster_mgr_sup_tests.erl b/test/riak_core_cluster_mgr_sup_tests.erl index acf8fe1e..2c7ab1c0 100644 --- a/test/riak_core_cluster_mgr_sup_tests.erl +++ b/test/riak_core_cluster_mgr_sup_tests.erl @@ -1,7 +1,7 @@ -module(riak_core_cluster_mgr_sup_tests). -compile(export_all). --ifdef(EQC). --include_lib("riak_core/include/riak_core_connection.hrl"). +-ifdef(TEST). +-include("riak_core_connection.hrl"). -include_lib("eunit/include/eunit.hrl"). murdering_test_() ->