2014-05-30 18:55:34 +00:00
|
|
|
%% -------------------------------------------------------------------
|
|
|
|
%%
|
|
|
|
%% Copyright (c) 2013 Basho Technologies, Inc.
|
|
|
|
%%
|
|
|
|
%% -------------------------------------------------------------------
|
|
|
|
-module(riak_rex).
|
|
|
|
-behaviour(riak_test).
|
|
|
|
-export([confirm/0]).
|
|
|
|
-compile(export_all).
|
|
|
|
-include_lib("eunit/include/eunit.hrl").
|
|
|
|
|
|
|
|
%% @doc riak_test entry point
|
|
|
|
confirm() ->
|
|
|
|
SetupData = setup(current),
|
|
|
|
rex_test(SetupData),
|
|
|
|
pass.
|
|
|
|
|
|
|
|
setup(Type) ->
|
2014-05-30 19:44:06 +00:00
|
|
|
deploy_node(Type).
|
2014-05-30 18:55:34 +00:00
|
|
|
|
|
|
|
rex_test(Node) ->
|
|
|
|
% validated we can get the rex pid on the node
|
2014-05-30 19:44:06 +00:00
|
|
|
RexPid1 = riak_core_util:safe_rpc(Node, erlang, whereis, [rex]),
|
|
|
|
?assertEqual(node(RexPid1), Node),
|
|
|
|
% kill rex on the node and check that safe_rpc works
|
|
|
|
kill_rex(Node),
|
2014-05-30 18:55:34 +00:00
|
|
|
ErrorTuple = riak_core_util:safe_rpc(Node, erlang, whereis, [rex]),
|
|
|
|
?assertEqual(ErrorTuple, {badrpc,rpc_process_down}),
|
2014-05-30 19:44:06 +00:00
|
|
|
% restart rex
|
|
|
|
supervisor:restart_child({kernel_sup, Node}, rex),
|
|
|
|
RexPid2 = riak_core_util:safe_rpc(Node, erlang, whereis, [rex]),
|
|
|
|
?assertEqual(node(RexPid2), Node).
|
2014-05-30 18:55:34 +00:00
|
|
|
|
2014-05-30 19:44:06 +00:00
|
|
|
|
|
|
|
deploy_node(NumNodes, current) ->
|
2014-05-30 18:55:34 +00:00
|
|
|
rt:deploy_nodes(NumNodes, conf());
|
2014-05-30 19:44:06 +00:00
|
|
|
deploy_node(_, mixed) ->
|
2014-05-30 18:55:34 +00:00
|
|
|
Conf = conf(),
|
|
|
|
rt:deploy_nodes([{current, Conf}, {previous, Conf}]).
|
|
|
|
|
2014-05-30 19:44:06 +00:00
|
|
|
deploy_node(Type) ->
|
2014-05-30 18:55:34 +00:00
|
|
|
NumNodes = rt_config:get(num_nodes, 1),
|
|
|
|
|
2014-05-30 19:44:06 +00:00
|
|
|
lager:info("Deploy ~p node", [NumNodes]),
|
|
|
|
Node = deploy_node(NumNodes, Type),
|
2014-05-30 18:55:34 +00:00
|
|
|
lager:info("Node: ~p", [Node]),
|
|
|
|
hd(Node).
|
|
|
|
|
|
|
|
kill_rex(Node) ->
|
2014-05-30 19:44:06 +00:00
|
|
|
ok = supervisor:terminate_child({kernel_sup, Node}, rex).
|
2014-05-30 18:55:34 +00:00
|
|
|
|
|
|
|
conf() ->
|
|
|
|
[
|
|
|
|
{riak_kv,
|
|
|
|
[
|
|
|
|
{anti_entropy, {off, []}}
|
|
|
|
]
|
|
|
|
}
|
|
|
|
].
|