2012-04-27 23:50:31 +00:00
|
|
|
-module(verify_capabilities).
|
|
|
|
-export([verify_capabilities/0]).
|
|
|
|
-include_lib("eunit/include/eunit.hrl").
|
|
|
|
|
|
|
|
verify_capabilities() ->
|
|
|
|
lager:info("Deploying mixed set of nodes"),
|
2012-08-03 04:52:56 +00:00
|
|
|
Nodes = rt:deploy_nodes([current, "0.14.2", "1.1.4", "1.0.3"]),
|
2012-04-27 23:50:31 +00:00
|
|
|
[Node1, Node2, Node3, Node4] = Nodes,
|
|
|
|
|
|
|
|
lager:info("Verify vnode_routing == proxy"),
|
2012-08-03 04:52:56 +00:00
|
|
|
?assertEqual(ok, rt:wait_until_capability(Node1, {riak_core, vnode_routing}, proxy)),
|
2012-04-27 23:50:31 +00:00
|
|
|
|
|
|
|
lager:info("Crash riak_core_capability server"),
|
|
|
|
crash_capability_server(Node1),
|
|
|
|
timer:sleep(1000),
|
|
|
|
|
|
|
|
lager:info("Verify vnode_routing == proxy after crash"),
|
2012-08-03 04:52:56 +00:00
|
|
|
?assertEqual(proxy, rt:capability(Node1, {riak_core, vnode_routing})),
|
2012-04-27 23:50:31 +00:00
|
|
|
|
|
|
|
lager:info("Building current + 0.14.2 cluster"),
|
|
|
|
rt:join(Node2, Node1),
|
|
|
|
?assertEqual(ok, rt:wait_until_all_members([Node1], [Node1, Node2])),
|
|
|
|
?assertEqual(ok, rt:wait_until_legacy_ringready(Node1)),
|
|
|
|
|
|
|
|
lager:info("Verifying vnode_routing == legacy"),
|
2012-08-03 04:52:56 +00:00
|
|
|
?assertEqual(ok, rt:wait_until_capability(Node1, {riak_core, vnode_routing}, legacy)),
|
2012-04-27 23:50:31 +00:00
|
|
|
|
|
|
|
lager:info("Crash riak_core_capability server"),
|
|
|
|
crash_capability_server(Node1),
|
|
|
|
timer:sleep(1000),
|
|
|
|
|
|
|
|
lager:info("Verify vnode_routing == legacy after crash"),
|
2012-08-03 04:52:56 +00:00
|
|
|
?assertEqual(legacy, rt:capability(Node1, {riak_core, vnode_routing})),
|
2012-04-27 23:50:31 +00:00
|
|
|
|
2012-08-03 04:52:56 +00:00
|
|
|
lager:info("Adding 1.1.4 node to cluster"),
|
2012-04-27 23:50:31 +00:00
|
|
|
rt:join(Node3, Node2),
|
|
|
|
?assertEqual(ok, rt:wait_until_all_members([Node1], [Node1, Node2, Node3])),
|
|
|
|
?assertEqual(ok, rt:wait_until_legacy_ringready(Node1)),
|
|
|
|
|
|
|
|
lager:info("Verifying vnode_routing == legacy"),
|
2012-08-03 04:52:56 +00:00
|
|
|
?assertEqual(legacy, rt:capability(Node1, {riak_core, vnode_routing})),
|
2012-04-27 23:50:31 +00:00
|
|
|
|
|
|
|
lager:info("Upgrade 0.14.2 node"),
|
2012-08-05 19:29:01 +00:00
|
|
|
rt:upgrade(Node2, current),
|
2012-04-27 23:50:31 +00:00
|
|
|
|
|
|
|
lager:info("Verifying vnode_routing == proxy"),
|
2012-08-03 04:52:56 +00:00
|
|
|
?assertEqual(ok, rt:wait_until_capability(Node1, {riak_core, vnode_routing}, proxy)),
|
2012-04-27 23:50:31 +00:00
|
|
|
|
|
|
|
lager:info("Adding 1.0.3 node to cluster"),
|
|
|
|
rt:join(Node4, Node1),
|
|
|
|
?assertEqual(ok, rt:wait_until_nodes_ready([Node1, Node2, Node3, Node4])),
|
|
|
|
|
|
|
|
lager:info("Verifying vnode_routing == legacy"),
|
2012-08-03 04:52:56 +00:00
|
|
|
?assertEqual(legacy, rt:capability(Node1, {riak_core, vnode_routing})),
|
2012-04-27 23:50:31 +00:00
|
|
|
|
|
|
|
lager:info("Upgrading 1.0.3 node"),
|
2012-08-05 19:29:01 +00:00
|
|
|
rt:upgrade(Node4, current),
|
2012-04-27 23:50:31 +00:00
|
|
|
|
|
|
|
lager:info("Verifying vnode_routing changes to proxy"),
|
2012-08-03 04:52:56 +00:00
|
|
|
?assertEqual(ok, rt:wait_until_capability(Node1, {riak_core, vnode_routing}, proxy)),
|
2012-04-27 23:50:31 +00:00
|
|
|
|
2012-08-03 04:52:56 +00:00
|
|
|
lager:info("Upgrade 1.1.4 node"),
|
2012-08-05 19:29:01 +00:00
|
|
|
rt:upgrade(Node3, current),
|
2012-04-27 23:50:31 +00:00
|
|
|
|
|
|
|
%% All nodes are now current version. Test override behavior.
|
|
|
|
Override = fun(undefined, Prefer) ->
|
|
|
|
[{riak_core, [{override_capability,
|
|
|
|
[{vnode_routing,
|
|
|
|
[{prefer, Prefer}]
|
|
|
|
}]}]
|
|
|
|
}];
|
|
|
|
(Use, Prefer) ->
|
|
|
|
[{riak_core, [{override_capability,
|
|
|
|
[{vnode_routing,
|
|
|
|
[{use, Use},
|
|
|
|
{prefer, Prefer}]
|
|
|
|
}]}]
|
|
|
|
}]
|
|
|
|
end,
|
|
|
|
|
|
|
|
lager:info("Override: (use: legacy), (prefer: proxy)"),
|
|
|
|
[rt:update_app_config(Node, Override(legacy, proxy)) || Node <- Nodes],
|
|
|
|
|
|
|
|
lager:info("Verify vnode_routing == legacy"),
|
2012-08-03 04:52:56 +00:00
|
|
|
?assertEqual(legacy, rt:capability(Node1, {riak_core, vnode_routing})),
|
2012-04-27 23:50:31 +00:00
|
|
|
|
|
|
|
lager:info("Override: (use: proxy), (prefer: legacy)"),
|
|
|
|
[rt:update_app_config(Node, Override(proxy, legacy)) || Node <- Nodes],
|
|
|
|
|
|
|
|
lager:info("Verify vnode_routing == proxy"),
|
2012-08-03 04:52:56 +00:00
|
|
|
?assertEqual(proxy, rt:capability(Node1, {riak_core, vnode_routing})),
|
2012-04-27 23:50:31 +00:00
|
|
|
|
|
|
|
lager:info("Override: (prefer: legacy)"),
|
|
|
|
[rt:update_app_config(Node, Override(undefined, legacy)) || Node <- Nodes],
|
|
|
|
|
|
|
|
lager:info("Verify vnode_routing == legacy"),
|
2012-08-03 04:52:56 +00:00
|
|
|
?assertEqual(legacy, rt:capability(Node1, {riak_core, vnode_routing})),
|
2012-04-27 23:50:31 +00:00
|
|
|
|
|
|
|
[rt:stop(Node) || Node <- Nodes],
|
|
|
|
ok.
|
|
|
|
|
|
|
|
crash_capability_server(Node) ->
|
|
|
|
Pid = rpc:call(Node, erlang, whereis, [riak_core_capability]),
|
|
|
|
rpc:call(Node, erlang, exit, [Pid, kill]).
|
|
|
|
|