2012-10-10 22:14:06 +00:00
|
|
|
%% -------------------------------------------------------------------
|
|
|
|
%%
|
|
|
|
%% Copyright (c) 2012 Basho Technologies, Inc.
|
|
|
|
%%
|
|
|
|
%% This file is provided to you under the Apache License,
|
|
|
|
%% Version 2.0 (the "License"); you may not use this file
|
|
|
|
%% except in compliance with the License. You may obtain
|
|
|
|
%% a copy of the License at
|
|
|
|
%%
|
|
|
|
%% http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
%%
|
|
|
|
%% Unless required by applicable law or agreed to in writing,
|
|
|
|
%% software distributed under the License is distributed on an
|
|
|
|
%% "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
|
|
|
%% KIND, either express or implied. See the License for the
|
|
|
|
%% specific language governing permissions and limitations
|
|
|
|
%% under the License.
|
|
|
|
%%
|
|
|
|
%% -------------------------------------------------------------------
|
2012-01-11 00:21:39 +00:00
|
|
|
-module(verify_build_cluster).
|
2012-11-28 15:25:45 +00:00
|
|
|
-export([confirm/0]).
|
2012-01-11 00:21:39 +00:00
|
|
|
-include_lib("eunit/include/eunit.hrl").
|
|
|
|
|
2012-11-28 15:25:45 +00:00
|
|
|
-import(rt, [wait_until_nodes_ready/1,
|
2012-01-11 00:21:39 +00:00
|
|
|
wait_until_no_pending_changes/1]).
|
|
|
|
|
2012-08-27 19:48:54 +00:00
|
|
|
confirm() ->
|
2012-01-11 00:21:39 +00:00
|
|
|
%% Deploy a set of new nodes
|
2012-11-28 15:25:45 +00:00
|
|
|
lager:info("Deploying 4 nodes"),
|
2012-11-28 17:39:57 +00:00
|
|
|
%% handoff_concurrency needs to be raised to make the leave operation faster.
|
|
|
|
%% most clusters go up to 10, but this one is one louder, isn't it?
|
|
|
|
[Node1, Node2, Node3, Node4] = Nodes = rt:deploy_nodes(4, [{riak_core, [{handoff_concurrency, 11}]}]),
|
2012-01-11 00:21:39 +00:00
|
|
|
|
|
|
|
%% Ensure each node owns 100% of it's own ring
|
|
|
|
lager:info("Ensure each nodes 100% of it's own ring"),
|
2012-12-03 14:46:03 +00:00
|
|
|
|
|
|
|
[rt:wait_until_owners_according_to(Node, [Node]) || Node <- Nodes],
|
2012-01-11 00:21:39 +00:00
|
|
|
|
2012-11-28 17:39:57 +00:00
|
|
|
lager:info("Loading some data up in this cluster."),
|
|
|
|
?assertEqual([], rt:systest_write(Node1, 0, 1000, <<"verify_build_cluster">>, 2)),
|
|
|
|
|
|
|
|
lager:info("joining Node 2 to the cluster... It takes two to make a thing go right"),
|
2012-11-28 15:25:45 +00:00
|
|
|
rt:join(Node2, Node1),
|
|
|
|
wait_and_validate([Node1, Node2]),
|
2012-01-11 00:21:39 +00:00
|
|
|
|
2012-11-28 15:25:45 +00:00
|
|
|
lager:info("joining Node 3 to the cluster"),
|
|
|
|
rt:join(Node3, Node1),
|
|
|
|
wait_and_validate([Node1, Node2, Node3]),
|
|
|
|
|
|
|
|
lager:info("joining Node 4 to the cluster"),
|
|
|
|
rt:join(Node4, Node1),
|
|
|
|
wait_and_validate(Nodes),
|
|
|
|
|
2012-11-28 22:40:52 +00:00
|
|
|
lager:info("taking Node 1 down"),
|
2012-11-28 15:25:45 +00:00
|
|
|
rt:stop(Node1),
|
|
|
|
?assertEqual(ok, rt:wait_until_unpingable(Node1)),
|
|
|
|
wait_and_validate(Nodes, [Node2, Node3, Node4]),
|
|
|
|
|
2012-11-28 22:40:52 +00:00
|
|
|
lager:info("taking Node 2 down"),
|
2012-11-28 15:25:45 +00:00
|
|
|
rt:stop(Node2),
|
|
|
|
?assertEqual(ok, rt:wait_until_unpingable(Node2)),
|
|
|
|
wait_and_validate(Nodes, [Node3, Node4]),
|
|
|
|
|
2012-11-28 22:40:52 +00:00
|
|
|
lager:info("bringing Node 1 up"),
|
2012-11-28 15:25:45 +00:00
|
|
|
rt:start(Node1),
|
2012-11-28 17:39:57 +00:00
|
|
|
ok = rt:wait_until_pingable(Node1),
|
2012-11-28 15:25:45 +00:00
|
|
|
wait_and_validate(Nodes, [Node1, Node3, Node4]),
|
2012-11-28 22:40:52 +00:00
|
|
|
lager:info("bringing Node 2 up"),
|
2012-11-28 15:25:45 +00:00
|
|
|
rt:start(Node2),
|
2012-11-28 17:39:57 +00:00
|
|
|
ok = rt:wait_until_pingable(Node2),
|
2012-11-28 15:25:45 +00:00
|
|
|
wait_and_validate(Nodes),
|
|
|
|
|
|
|
|
% leave 1, 2, and 3
|
2012-11-28 22:40:52 +00:00
|
|
|
lager:info("leaving Node 1"),
|
2012-11-28 15:25:45 +00:00
|
|
|
rt:leave(Node1),
|
|
|
|
?assertEqual(ok, rt:wait_until_unpingable(Node1)),
|
|
|
|
wait_and_validate([Node2, Node3, Node4]),
|
|
|
|
|
2012-11-28 22:40:52 +00:00
|
|
|
lager:info("leaving Node 2"),
|
2012-11-28 15:25:45 +00:00
|
|
|
rt:leave(Node2),
|
|
|
|
?assertEqual(ok, rt:wait_until_unpingable(Node2)),
|
|
|
|
wait_and_validate([Node3, Node4]),
|
2012-11-28 17:39:57 +00:00
|
|
|
|
2012-11-28 22:40:52 +00:00
|
|
|
lager:info("leaving Node 3"),
|
2012-11-28 15:25:45 +00:00
|
|
|
rt:leave(Node3),
|
|
|
|
?assertEqual(ok, rt:wait_until_unpingable(Node3)),
|
|
|
|
|
|
|
|
% verify 4
|
|
|
|
wait_and_validate([Node4]),
|
2012-01-11 00:21:39 +00:00
|
|
|
|
2012-08-23 19:19:21 +00:00
|
|
|
pass.
|
2012-11-28 15:25:45 +00:00
|
|
|
|
|
|
|
wait_and_validate(Nodes) -> wait_and_validate(Nodes, Nodes).
|
|
|
|
wait_and_validate(RingNodes, UpNodes) ->
|
|
|
|
lager:info("Wait until all nodes are ready and there are no pending changes"),
|
|
|
|
?assertEqual(ok, rt:wait_until_nodes_ready(UpNodes)),
|
2012-11-28 22:40:52 +00:00
|
|
|
?assertEqual(ok, rt:wait_until_all_members(UpNodes)),
|
2012-11-28 15:25:45 +00:00
|
|
|
?assertEqual(ok, rt:wait_until_no_pending_changes(UpNodes)),
|
|
|
|
lager:info("Ensure each node owns a portion of the ring"),
|
2012-12-03 14:46:03 +00:00
|
|
|
[rt:wait_until_owners_according_to(Node, RingNodes) || Node <- UpNodes],
|
2012-11-28 22:40:52 +00:00
|
|
|
[rt:wait_for_service(Node, riak_kv) || Node <- UpNodes],
|
2012-11-28 17:39:57 +00:00
|
|
|
lager:info("Verify that you got much data... (this is how we do it)"),
|
|
|
|
?assertEqual([], rt:systest_read(hd(UpNodes), 0, 1000, <<"verify_build_cluster">>, 2)),
|
2012-11-28 15:25:45 +00:00
|
|
|
done.
|