Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make default riak services and console configurable in rt.erl #752

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions examples/riak_test.config
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,17 @@
%% scripts in the bin/ directory.
{rt_harness, rtdev},

%% The riak test environment can ensure that a default set of riak
%% services are started. The set of services can be configured by
%% configuring the desired set of services. To alter the default
%% enable and configure the following variable
%% {rt_services, [riak_kv]},

%% The riak test environment integreates with riak_kv_console by
%% default. To override this for other riak_core based apps uncomment
%% and configure teh following variable
%% {rt_console, riak_kv_console},

%% The scratch directory specifies where riak_test will put
%% temporary testing artifacts like client packages, git
%% checkouts, etc.
Expand Down
15 changes: 9 additions & 6 deletions src/rt.erl
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@
-include("rt.hrl").
-include_lib("eunit/include/eunit.hrl").

-define(SERVICES,rt_config:get(rt_services, [riak_kv])).
-define(CONSOLE, rt_config:get(rt_console, riak_kv_console)).

-compile(export_all).
-export([
admin/2,
Expand Down Expand Up @@ -299,15 +302,15 @@ get_https_conn_info(Node) ->
%% nodes deployed.
%% @todo Re-add -spec after adding multi-version support
deploy_nodes(Versions) when is_list(Versions) ->
deploy_nodes(Versions, [riak_kv]);
deploy_nodes(Versions, ?SERVICES);
deploy_nodes(NumNodes) when is_integer(NumNodes) ->
deploy_nodes([ current || _ <- lists:seq(1, NumNodes)]).

%% @doc Deploy a set of freshly installed Riak nodes with the given
%% `InitialConfig', returning a list of the nodes deployed.
-spec deploy_nodes(NumNodes :: integer(), any()) -> [node()].
deploy_nodes(NumNodes, InitialConfig) when is_integer(NumNodes) ->
deploy_nodes(NumNodes, InitialConfig, [riak_kv]);
deploy_nodes(NumNodes, InitialConfig, ?SERVICES);
deploy_nodes(Versions, Services) ->
NodeConfig = [ version_to_config(Version) || Version <- Versions ],
Nodes = ?HARNESS:deploy_nodes(NodeConfig),
Expand Down Expand Up @@ -462,11 +465,11 @@ leave(Node) ->
%% @doc Have `Node' remove `OtherNode' from the cluster
remove(Node, OtherNode) ->
?assertEqual(ok,
rpc:call(Node, riak_kv_console, remove, [[atom_to_list(OtherNode)]])).
rpc:call(Node, ?CONSOLE, remove, [[atom_to_list(OtherNode)]])).

%% @doc Have `Node' mark `OtherNode' as down
down(Node, OtherNode) ->
rpc:call(Node, riak_kv_console, down, [[atom_to_list(OtherNode)]]).
rpc:call(Node, ?CONSOLE, down, [[atom_to_list(OtherNode)]]).

%% @doc partition the `P1' from `P2' nodes
%% note: the nodes remained connected to riak_test@local,
Expand Down Expand Up @@ -652,7 +655,7 @@ wait_until_status_ready(Node) ->
lager:info("Wait until status ready in ~p", [Node]),
?assertEqual(ok, wait_until(Node,
fun(_) ->
case rpc:call(Node, riak_kv_console, status, [[]]) of
case rpc:call(Node, ?CONSOLE, status, [[]]) of
ok ->
true;
Res ->
Expand Down Expand Up @@ -826,7 +829,7 @@ wait_until_partitioned(P1, P2) ->
end || Node <- P2 ].

is_partitioned(Node, Peers) ->
AvailableNodes = rpc:call(Node, riak_core_node_watcher, nodes, [riak_kv]),
AvailableNodes = rpc:call(Node, riak_core_node_watcher, nodes, ?SERVICES),
lists:all(fun(Peer) -> not lists:member(Peer, AvailableNodes) end, Peers).

% when you just can't wait
Expand Down