2012-11-16 19:49:28 +00:00
|
|
|
-module(replication_upgrade).
|
2012-12-14 15:50:49 +00:00
|
|
|
-behavior(riak_test).
|
|
|
|
-export([confirm/0]).
|
2012-11-16 19:49:28 +00:00
|
|
|
-include_lib("eunit/include/eunit.hrl").
|
|
|
|
|
|
|
|
confirm() ->
|
2013-01-22 18:49:22 +00:00
|
|
|
TestMetaData = riak_test_runner:metadata(),
|
|
|
|
FromVersion = proplists:get_value(upgrade_version, TestMetaData, previous),
|
2012-11-16 19:49:28 +00:00
|
|
|
|
2013-01-22 18:49:22 +00:00
|
|
|
lager:info("Doing rolling replication upgrade test from ~p to ~p",
|
|
|
|
[FromVersion, "current"]),
|
2012-11-16 19:49:28 +00:00
|
|
|
|
2013-04-26 15:02:23 +00:00
|
|
|
NumNodes = rt_config:get(num_nodes, 6),
|
2012-11-16 19:49:28 +00:00
|
|
|
|
2013-04-26 15:02:23 +00:00
|
|
|
UpgradeOrder = rt_config:get(repl_upgrade_order, "forwards"),
|
2012-11-16 19:49:28 +00:00
|
|
|
|
2013-01-22 18:49:22 +00:00
|
|
|
lager:info("Deploy ~p nodes", [NumNodes]),
|
2012-11-16 19:49:28 +00:00
|
|
|
Conf = [
|
|
|
|
{riak_repl,
|
|
|
|
[
|
|
|
|
{fullsync_on_connect, false},
|
|
|
|
{fullsync_interval, disabled}
|
|
|
|
]}
|
|
|
|
],
|
|
|
|
|
|
|
|
NodeConfig = [{FromVersion, Conf} || _ <- lists:seq(1, NumNodes)],
|
|
|
|
|
2014-12-18 21:07:00 +00:00
|
|
|
Nodes = rt:deploy_nodes(NodeConfig, [riak_kv, riak_repl]),
|
2012-11-16 19:49:28 +00:00
|
|
|
|
|
|
|
NodeUpgrades = case UpgradeOrder of
|
|
|
|
"forwards" ->
|
|
|
|
Nodes;
|
|
|
|
"backwards" ->
|
|
|
|
lists:reverse(Nodes);
|
|
|
|
"alternate" ->
|
|
|
|
%% eg 1, 4, 2, 5, 3, 6
|
|
|
|
lists:flatten(lists:foldl(fun(E, [A,B,C]) -> [B, C, A ++ [E]] end,
|
|
|
|
[[],[],[]], Nodes));
|
|
|
|
"random" ->
|
|
|
|
%% halfass randomization
|
|
|
|
lists:sort(fun(_, _) -> random:uniform(100) < 50 end, Nodes);
|
|
|
|
Other ->
|
|
|
|
lager:error("Invalid upgrade ordering ~p", [Other]),
|
|
|
|
erlang:exit()
|
|
|
|
end,
|
|
|
|
|
2013-04-26 15:02:23 +00:00
|
|
|
ClusterASize = rt_config:get(cluster_a_size, 3),
|
2012-11-16 19:49:28 +00:00
|
|
|
{ANodes, BNodes} = lists:split(ClusterASize, Nodes),
|
|
|
|
lager:info("ANodes: ~p", [ANodes]),
|
|
|
|
lager:info("BNodes: ~p", [BNodes]),
|
|
|
|
|
|
|
|
lager:info("Build cluster A"),
|
2013-01-30 04:37:36 +00:00
|
|
|
repl_util:make_cluster(ANodes),
|
2012-11-16 19:49:28 +00:00
|
|
|
|
|
|
|
lager:info("Build cluster B"),
|
2013-01-30 04:37:36 +00:00
|
|
|
repl_util:make_cluster(BNodes),
|
|
|
|
|
|
|
|
lager:info("Replication First pass...homogenous cluster"),
|
2012-11-16 19:49:28 +00:00
|
|
|
|
|
|
|
%% initial replication run, homogeneous cluster
|
|
|
|
replication:replication(ANodes, BNodes, false),
|
2013-01-30 04:37:36 +00:00
|
|
|
|
|
|
|
lager:info("Upgrading nodes in order: ~p", [NodeUpgrades]),
|
|
|
|
rt:log_to_nodes(Nodes, "Upgrading nodes in order: ~p", [NodeUpgrades]),
|
2012-11-16 19:49:28 +00:00
|
|
|
%% upgrade the nodes, one at a time
|
2014-06-10 17:56:01 +00:00
|
|
|
ok = lists:foreach(fun(Node) ->
|
|
|
|
lager:info("Upgrade node: ~p", [Node]),
|
|
|
|
rt:log_to_nodes(Nodes, "Upgrade node: ~p", [Node]),
|
|
|
|
rtdev:upgrade(Node, current),
|
|
|
|
rt:wait_until_pingable(Node),
|
|
|
|
rt:wait_for_service(Node, [riak_kv, riak_pipe, riak_repl]),
|
|
|
|
[rt:wait_until_ring_converged(N) || N <- [ANodes, BNodes]],
|
|
|
|
%% Prior to 1.4.8 riak_repl registered
|
|
|
|
%% as a service before completing all
|
|
|
|
%% initialization including establishing
|
|
|
|
%% realtime connections.
|
|
|
|
%%
|
|
|
|
%% @TODO Ideally the test would only wait
|
|
|
|
%% for the connection in the case of the
|
|
|
|
%% node version being < 1.4.8, but currently
|
|
|
|
%% the rt API does not provide a
|
|
|
|
%% harness-agnostic method do get the node
|
|
|
|
%% version. For now the test waits for all
|
|
|
|
%% source cluster nodes to establish a
|
|
|
|
%% connection before proceeding.
|
|
|
|
case lists:member(Node, ANodes) of
|
|
|
|
true ->
|
2014-06-12 03:46:24 +00:00
|
|
|
replication:wait_until_connection(Node);
|
2014-06-10 17:56:01 +00:00
|
|
|
false ->
|
|
|
|
ok
|
|
|
|
end,
|
|
|
|
lager:info("Replication with upgraded node: ~p", [Node]),
|
|
|
|
rt:log_to_nodes(Nodes, "Replication with upgraded node: ~p", [Node]),
|
|
|
|
replication:replication(ANodes, BNodes, true)
|
|
|
|
end, NodeUpgrades),
|
|
|
|
pass.
|