Skip to content

Commit 27390fb

Browse files
committed
Merge pull request #624 from basho/bugfix/jra/rex
Add test for safe_rpc when rex is down
2 parents 177f901 + 110bf7e commit 27390fb

File tree

1 file changed

+59
-0
lines changed

1 file changed

+59
-0
lines changed

tests/riak_rex.erl

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
%% -------------------------------------------------------------------
2+
%%
3+
%% Copyright (c) 2013 Basho Technologies, Inc.
4+
%%
5+
%% -------------------------------------------------------------------
6+
-module(riak_rex).
7+
-behaviour(riak_test).
8+
-export([confirm/0]).
9+
-compile(export_all).
10+
-include_lib("eunit/include/eunit.hrl").
11+
12+
%% @doc riak_test entry point
13+
confirm() ->
14+
SetupData = setup(current),
15+
rex_test(SetupData),
16+
pass.
17+
18+
setup(Type) ->
19+
deploy_node(Type).
20+
21+
rex_test(Node) ->
22+
% validated we can get the rex pid on the node
23+
RexPid1 = riak_core_util:safe_rpc(Node, erlang, whereis, [rex]),
24+
?assertEqual(node(RexPid1), Node),
25+
% kill rex on the node and check that safe_rpc works
26+
kill_rex(Node),
27+
ErrorTuple = riak_core_util:safe_rpc(Node, erlang, whereis, [rex]),
28+
?assertEqual(ErrorTuple, {badrpc,rpc_process_down}),
29+
% restart rex
30+
supervisor:restart_child({kernel_sup, Node}, rex),
31+
RexPid2 = riak_core_util:safe_rpc(Node, erlang, whereis, [rex]),
32+
?assertEqual(node(RexPid2), Node).
33+
34+
35+
deploy_node(NumNodes, current) ->
36+
rt:deploy_nodes(NumNodes, conf());
37+
deploy_node(_, mixed) ->
38+
Conf = conf(),
39+
rt:deploy_nodes([{current, Conf}, {previous, Conf}]).
40+
41+
deploy_node(Type) ->
42+
NumNodes = rt_config:get(num_nodes, 1),
43+
44+
lager:info("Deploy ~p node", [NumNodes]),
45+
Node = deploy_node(NumNodes, Type),
46+
lager:info("Node: ~p", [Node]),
47+
hd(Node).
48+
49+
kill_rex(Node) ->
50+
ok = supervisor:terminate_child({kernel_sup, Node}, rex).
51+
52+
conf() ->
53+
[
54+
{riak_kv,
55+
[
56+
{anti_entropy, {off, []}}
57+
]
58+
}
59+
].

0 commit comments

Comments
 (0)