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-04-27 23:50:31 +00:00
|
|
|
-module(verify_capabilities).
|
2012-12-14 15:50:49 +00:00
|
|
|
-behavior(riak_test).
|
2012-08-27 19:48:54 +00:00
|
|
|
-export([confirm/0]).
|
2012-04-27 23:50:31 +00:00
|
|
|
-include_lib("eunit/include/eunit.hrl").
|
|
|
|
|
2012-11-16 16:26:23 +00:00
|
|
|
%% 1.3 {riak_kv, anti_entropy} -> [disabled, enabled_v1]
|
2012-08-27 19:48:54 +00:00
|
|
|
confirm() ->
|
2012-04-27 23:50:31 +00:00
|
|
|
lager:info("Deploying mixed set of nodes"),
|
2012-11-16 16:26:23 +00:00
|
|
|
Nodes = rt:deploy_nodes([current, previous, legacy]),
|
|
|
|
[CNode, PNode, LNode] = Nodes,
|
|
|
|
|
|
|
|
lager:info("Verify staged_joins == true"),
|
2013-01-04 16:55:55 +00:00
|
|
|
?assertEqual(ok, rt:wait_until_capability(CNode, {riak_core, staged_joins}, true)),
|
2012-11-16 16:26:23 +00:00
|
|
|
|
|
|
|
%% This test is written with the intent that 1.3 is 'current'
|
|
|
|
CCapabilities = rt:capability(CNode, all),
|
|
|
|
assert_capability(CCapabilities, {riak_kv, legacy_keylisting}, false),
|
|
|
|
assert_capability(CCapabilities, {riak_kv, listkeys_backpressure}, true),
|
|
|
|
assert_capability(CCapabilities, {riak_core, staged_joins}, true),
|
|
|
|
assert_capability(CCapabilities, {riak_kv, index_backpressure}, true),
|
|
|
|
assert_capability(CCapabilities, {riak_pipe, trace_format}, ordsets),
|
|
|
|
assert_capability(CCapabilities, {riak_kv, mapred_2i_pipe}, true),
|
|
|
|
assert_capability(CCapabilities, {riak_kv, mapred_system}, pipe),
|
|
|
|
assert_capability(CCapabilities, {riak_kv, vnode_vclocks}, true),
|
|
|
|
assert_capability(CCapabilities, {riak_core, vnode_routing}, proxy),
|
|
|
|
assert_supported(CCapabilities, {riak_core, staged_joins}, [true,false]),
|
|
|
|
assert_supported(CCapabilities, {riak_core, vnode_routing}, [proxy,legacy]),
|
|
|
|
assert_supported(CCapabilities, {riak_kv, index_backpressure}, [true,false]),
|
|
|
|
assert_supported(CCapabilities, {riak_kv, legacy_keylisting}, [false]),
|
|
|
|
assert_supported(CCapabilities, {riak_kv, listkeys_backpressure}, [true,false]),
|
|
|
|
assert_supported(CCapabilities, {riak_kv, mapred_2i_pipe}, [true,false]),
|
|
|
|
assert_supported(CCapabilities, {riak_kv, mapred_system}, [pipe]),
|
|
|
|
assert_supported(CCapabilities, {riak_kv, vnode_vclocks}, [true,false]),
|
|
|
|
assert_supported(CCapabilities, {riak_pipe, trace_format}, [ordsets,sets]),
|
2012-04-27 23:50:31 +00:00
|
|
|
|
|
|
|
lager:info("Crash riak_core_capability server"),
|
2013-01-04 16:55:55 +00:00
|
|
|
restart_capability_server(CNode),
|
2012-04-27 23:50:31 +00:00
|
|
|
|
2012-11-16 16:26:23 +00:00
|
|
|
lager:info("Verify staged_joins == true after crash"),
|
2013-01-04 16:55:55 +00:00
|
|
|
?assertEqual(ok, rt:wait_until_capability(CNode, {riak_core, staged_joins}, true)),
|
2012-11-16 16:26:23 +00:00
|
|
|
|
|
|
|
lager:info("Building current + legacy cluster"),
|
|
|
|
rt:join(LNode, CNode),
|
|
|
|
?assertEqual(ok, rt:wait_until_all_members([CNode], [CNode, LNode])),
|
|
|
|
?assertEqual(ok, rt:wait_until_legacy_ringready(CNode)),
|
|
|
|
|
|
|
|
LCapabilities = rt:capability(CNode, all),
|
|
|
|
assert_capability(LCapabilities, {riak_kv, legacy_keylisting}, false),
|
|
|
|
assert_capability(LCapabilities, {riak_kv, listkeys_backpressure}, true),
|
|
|
|
assert_capability(LCapabilities, {riak_core, staged_joins}, false),
|
|
|
|
assert_capability(LCapabilities, {riak_kv, index_backpressure}, false),
|
|
|
|
assert_capability(LCapabilities, {riak_pipe, trace_format}, sets),
|
|
|
|
assert_capability(LCapabilities, {riak_kv, mapred_2i_pipe}, true),
|
|
|
|
assert_capability(LCapabilities, {riak_kv, mapred_system}, pipe),
|
|
|
|
assert_capability(LCapabilities, {riak_kv, vnode_vclocks}, true),
|
|
|
|
assert_capability(LCapabilities, {riak_core, vnode_routing}, proxy),
|
|
|
|
assert_supported(LCapabilities, {riak_core, staged_joins}, [true,false]),
|
|
|
|
assert_supported(LCapabilities, {riak_core, vnode_routing}, [proxy,legacy]),
|
|
|
|
assert_supported(LCapabilities, {riak_kv, index_backpressure}, [true,false]),
|
|
|
|
assert_supported(LCapabilities, {riak_kv, legacy_keylisting}, [false]),
|
|
|
|
assert_supported(LCapabilities, {riak_kv, listkeys_backpressure}, [true,false]),
|
|
|
|
assert_supported(LCapabilities, {riak_kv, mapred_2i_pipe}, [true,false]),
|
|
|
|
assert_supported(LCapabilities, {riak_kv, mapred_system}, [pipe]),
|
|
|
|
assert_supported(LCapabilities, {riak_kv, vnode_vclocks}, [true,false]),
|
|
|
|
assert_supported(LCapabilities, {riak_pipe, trace_format}, [ordsets,sets]),
|
|
|
|
|
2012-04-27 23:50:31 +00:00
|
|
|
lager:info("Crash riak_core_capability server"),
|
2013-01-04 16:55:55 +00:00
|
|
|
restart_capability_server(CNode),
|
2012-04-27 23:50:31 +00:00
|
|
|
|
2012-11-16 16:26:23 +00:00
|
|
|
lager:info("Verify staged_joins == false after crash"),
|
2013-01-04 16:55:55 +00:00
|
|
|
?assertEqual(ok, rt:wait_until_capability(CNode, {riak_core, staged_joins}, false)),
|
2012-11-16 16:26:23 +00:00
|
|
|
|
|
|
|
lager:info("Adding previous node to cluster"),
|
|
|
|
rt:join(PNode, LNode),
|
|
|
|
?assertEqual(ok, rt:wait_until_all_members([CNode], [CNode, LNode, PNode])),
|
|
|
|
?assertEqual(ok, rt:wait_until_legacy_ringready(CNode)),
|
|
|
|
|
2013-01-04 16:55:55 +00:00
|
|
|
lager:info("Verify staged_joins == false after crash"),
|
|
|
|
?assertEqual(ok, rt:wait_until_capability(CNode, {riak_core, staged_joins}, false)),
|
2012-11-16 16:26:23 +00:00
|
|
|
|
|
|
|
PCapabilities = rt:capability(CNode, all),
|
|
|
|
assert_capability(PCapabilities, {riak_kv, legacy_keylisting}, false),
|
|
|
|
assert_capability(PCapabilities, {riak_kv, listkeys_backpressure}, true),
|
|
|
|
assert_capability(PCapabilities, {riak_core, staged_joins}, false),
|
|
|
|
assert_capability(PCapabilities, {riak_kv, index_backpressure}, false),
|
|
|
|
assert_capability(PCapabilities, {riak_pipe, trace_format}, sets),
|
|
|
|
assert_capability(PCapabilities, {riak_kv, mapred_2i_pipe}, true),
|
|
|
|
assert_capability(PCapabilities, {riak_kv, mapred_system}, pipe),
|
|
|
|
assert_capability(PCapabilities, {riak_kv, vnode_vclocks}, true),
|
|
|
|
assert_capability(PCapabilities, {riak_core, vnode_routing}, proxy),
|
|
|
|
assert_supported(PCapabilities, {riak_core, staged_joins}, [true,false]),
|
|
|
|
assert_supported(PCapabilities, {riak_core, vnode_routing}, [proxy,legacy]),
|
|
|
|
assert_supported(PCapabilities, {riak_kv, index_backpressure}, [true,false]),
|
|
|
|
assert_supported(PCapabilities, {riak_kv, legacy_keylisting}, [false]),
|
|
|
|
assert_supported(PCapabilities, {riak_kv, listkeys_backpressure}, [true,false]),
|
|
|
|
assert_supported(PCapabilities, {riak_kv, mapred_2i_pipe}, [true,false]),
|
|
|
|
assert_supported(PCapabilities, {riak_kv, mapred_system}, [pipe]),
|
|
|
|
assert_supported(PCapabilities, {riak_kv, vnode_vclocks}, [true,false]),
|
|
|
|
assert_supported(PCapabilities, {riak_pipe, trace_format}, [ordsets,sets]),
|
|
|
|
|
|
|
|
lager:info("Upgrade Legacy node"),
|
|
|
|
rt:upgrade(LNode, current),
|
2012-12-19 18:56:18 +00:00
|
|
|
?assertEqual(ok, rt:wait_until_all_members([CNode], [CNode, LNode, PNode])),
|
|
|
|
?assertEqual(ok, rt:wait_until_legacy_ringready(CNode)),
|
2012-11-16 16:26:23 +00:00
|
|
|
|
|
|
|
lager:info("Verify staged_joins == true after upgrade of legacy -> current"),
|
2013-01-04 16:55:55 +00:00
|
|
|
?assertEqual(ok, rt:wait_until_capability(CNode, {riak_core, staged_joins}, true)),
|
2012-11-16 16:26:23 +00:00
|
|
|
|
|
|
|
PCap2 = rt:capability(CNode, all),
|
|
|
|
assert_capability(PCap2, {riak_kv, legacy_keylisting}, false),
|
|
|
|
assert_capability(PCap2, {riak_kv, listkeys_backpressure}, true),
|
|
|
|
assert_capability(PCap2, {riak_core, staged_joins}, true),
|
|
|
|
assert_capability(PCap2, {riak_kv, index_backpressure}, false),
|
|
|
|
assert_capability(PCap2, {riak_pipe, trace_format}, sets),
|
|
|
|
assert_capability(PCap2, {riak_kv, mapred_2i_pipe}, true),
|
|
|
|
assert_capability(PCap2, {riak_kv, mapred_system}, pipe),
|
|
|
|
assert_capability(PCap2, {riak_kv, vnode_vclocks}, true),
|
|
|
|
assert_capability(PCap2, {riak_core, vnode_routing}, proxy),
|
|
|
|
assert_supported(PCap2, {riak_core, staged_joins}, [true,false]),
|
|
|
|
assert_supported(PCap2, {riak_core, vnode_routing}, [proxy,legacy]),
|
|
|
|
assert_supported(PCap2, {riak_kv, index_backpressure}, [true,false]),
|
|
|
|
assert_supported(PCap2, {riak_kv, legacy_keylisting}, [false]),
|
|
|
|
assert_supported(PCap2, {riak_kv, listkeys_backpressure}, [true,false]),
|
|
|
|
assert_supported(PCap2, {riak_kv, mapred_2i_pipe}, [true,false]),
|
|
|
|
assert_supported(PCap2, {riak_kv, mapred_system}, [pipe]),
|
|
|
|
assert_supported(PCap2, {riak_kv, vnode_vclocks}, [true,false]),
|
|
|
|
assert_supported(PCap2, {riak_pipe, trace_format}, [ordsets,sets]),
|
|
|
|
|
|
|
|
lager:info("Upgrading Previous node"),
|
|
|
|
rt:upgrade(PNode, current),
|
|
|
|
|
|
|
|
lager:info("Verifying index_backpressue changes to true"),
|
|
|
|
?assertEqual(ok, rt:wait_until_capability(CNode, {riak_kv, index_backpressure}, true)),
|
|
|
|
|
|
|
|
lager:info("Verifying riak_pipe,trace_format changes to ordsets"),
|
|
|
|
?assertEqual(ok, rt:wait_until_capability(CNode, {riak_pipe, trace_format}, ordsets)),
|
|
|
|
|
|
|
|
CCap2 = rt:capability(CNode, all),
|
|
|
|
assert_capability(CCap2, {riak_kv, legacy_keylisting}, false),
|
|
|
|
assert_capability(CCap2, {riak_kv, listkeys_backpressure}, true),
|
|
|
|
assert_capability(CCap2, {riak_core, staged_joins}, true),
|
|
|
|
assert_capability(CCap2, {riak_kv, index_backpressure}, true),
|
|
|
|
assert_capability(CCap2, {riak_pipe, trace_format}, ordsets),
|
|
|
|
assert_capability(CCap2, {riak_kv, mapred_2i_pipe}, true),
|
|
|
|
assert_capability(CCap2, {riak_kv, mapred_system}, pipe),
|
|
|
|
assert_capability(CCap2, {riak_kv, vnode_vclocks}, true),
|
|
|
|
assert_capability(CCap2, {riak_core, vnode_routing}, proxy),
|
|
|
|
assert_supported(CCap2, {riak_core, staged_joins}, [true,false]),
|
|
|
|
assert_supported(CCap2, {riak_core, vnode_routing}, [proxy,legacy]),
|
|
|
|
assert_supported(CCap2, {riak_kv, index_backpressure}, [true,false]),
|
|
|
|
assert_supported(CCap2, {riak_kv, legacy_keylisting}, [false]),
|
|
|
|
assert_supported(CCap2, {riak_kv, listkeys_backpressure}, [true,false]),
|
|
|
|
assert_supported(CCap2, {riak_kv, mapred_2i_pipe}, [true,false]),
|
|
|
|
assert_supported(CCap2, {riak_kv, mapred_system}, [pipe]),
|
|
|
|
assert_supported(CCap2, {riak_kv, vnode_vclocks}, [true,false]),
|
|
|
|
assert_supported(CCap2, {riak_pipe, trace_format}, [ordsets,sets]),
|
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-11-16 16:26:23 +00:00
|
|
|
?assertEqual(legacy, rt:capability(CNode, {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-11-16 16:26:23 +00:00
|
|
|
?assertEqual(proxy, rt:capability(CNode, {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-11-16 16:26:23 +00:00
|
|
|
?assertEqual(legacy, rt:capability(CNode, {riak_core, vnode_routing})),
|
2012-04-27 23:50:31 +00:00
|
|
|
|
|
|
|
[rt:stop(Node) || Node <- Nodes],
|
2012-08-27 19:48:54 +00:00
|
|
|
pass.
|
2012-04-27 23:50:31 +00:00
|
|
|
|
2012-11-16 16:26:23 +00:00
|
|
|
assert_capability(Capabilities, Capability, Value) ->
|
|
|
|
lager:info("Checking Capability Setting ~p =:= ~p", [Capability, Value]),
|
|
|
|
?assertEqual(Value, proplists:get_value(Capability, Capabilities)).
|
|
|
|
|
|
|
|
assert_supported(Capabilities, Capability, Value) ->
|
|
|
|
lager:info("Checking Capability Supported Values ~p =:= ~p", [Capability, Value]),
|
|
|
|
?assertEqual(Value, proplists:get_value(Capability, proplists:get_value('$supported', Capabilities))).
|
|
|
|
|
2013-01-04 16:55:55 +00:00
|
|
|
restart_capability_server(Node) ->
|
2012-04-27 23:50:31 +00:00
|
|
|
Pid = rpc:call(Node, erlang, whereis, [riak_core_capability]),
|
2013-01-04 16:55:55 +00:00
|
|
|
rpc:call(Node, erlang, exit, [Pid, kill]),
|
|
|
|
HasNewPid =
|
|
|
|
fun(N) ->
|
|
|
|
case rpc:call(N, erlang, whereis, [riak_core_capability]) of
|
|
|
|
Pid -> false;
|
|
|
|
NewPid when is_pid(NewPid) -> true;
|
|
|
|
_ -> false
|
|
|
|
end
|
|
|
|
end,
|
|
|
|
rt:wait_until(Node, HasNewPid).
|
2012-04-27 23:50:31 +00:00
|
|
|
|