Wait for the specified services (or riak_kv by default) when deploying nodes.

This commit is contained in:
Sean Cribbs 2012-11-20 11:59:37 -05:00
parent 280c9e0119
commit 362d5725e2
2 changed files with 19 additions and 17 deletions

View File

@ -191,21 +191,25 @@ connection_info(Nodes) ->
%% nodes deployed.
%% @todo Re-add -spec after adding multi-version support
deploy_nodes(Versions) when is_list(Versions) ->
NodeConfig = lists:map(fun({Vsn,Config}) ->
{Vsn, Config};
(Vsn) ->
{Vsn, default}
end, Versions),
?HARNESS:deploy_nodes(NodeConfig);
deploy_nodes(NumNodes) ->
deploy_nodes(NumNodes, default).
deploy_nodes(Versions, [riak_kv]);
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) ->
deploy_nodes(NumNodes, InitialConfig) when is_integer(NumNodes) ->
NodeConfig = [{current, InitialConfig} || _ <- lists:seq(1,NumNodes)],
?HARNESS:deploy_nodes(NodeConfig).
deploy_nodes(NodeConfig);
deploy_nodes(Versions, Services) ->
NodeConfig = [ version_to_config(Version) || Version <- Versions ],
Nodes = ?HARNESS:deploy_nodes(NodeConfig),
lager:info("Waiting for services ~p to start on ~p.", [Services, Nodes]),
[ ok = wait_for_service(Node, Service) || Node <- Nodes, Service <- Services ],
Nodes.
version_to_config({_, _}=Config) -> Config;
version_to_config(Version) -> {Version, default}.
%% @doc Start the specified Riak node
start(Node) ->

View File

@ -7,15 +7,13 @@
confirm() ->
prereqs(),
GemDir = dat_gem(),
rt:update_app_config(all, [{riak_kv, [{test, true},
{add_paths, filename:join([GemDir, "erl_src"])}]},
Nodes = rt:deploy_nodes([{current,
[{riak_kv, [{test, true},
{add_paths, [filename:join([GemDir, "erl_src"])]}]},
{riak_search, [{enabled, true},
{backend, riak_search_test_backend}]}]
),
Nodes = rt:deploy_nodes(1),
{search_backend, riak_search_test_backend}]}]}],
[riak_search]),
[Node1] = Nodes,
?assertEqual(ok, rt:wait_until_nodes_ready([Node1])),
[{Node1, ConnectionInfo}] = rt:connection_info([Node1]),
{_HTTP_Host, HTTP_Port} = orddict:fetch(http, ConnectionInfo),