Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Verify Riak Startup when Strong Consistency is Misconfigured #636

Merged
merged 1 commit into from
Jun 16, 2014
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 17 additions & 6 deletions bin/reset-current-env.sh
Original file line number Diff line number Diff line change
Expand Up @@ -19,56 +19,67 @@ RT_BIN_DIR="$( cd -P "$( dirname "$SOURCE" )" && pwd )"
RT_HOME="$( dirname "$RT_BIN_DIR" )"
FULL_CLEAN=false
VERSION="2.0"
NUM_NODES=5

usage() {
echo "Resets the current riak_test environment by rebuilding riak and riak_test using rtdev-current.sh"
echo " -c: Perform a devclean on the riak and clean on riak_test projects (default: $FULL_CLEAN)"
echo " -n: Number of nodes on which to test (default: $NUM_NODES)"
echo " -v: The Riak version to test. The Riak home is calculated as $RT_HOME/riak-<version> (default: $VERSION)"
echo " -h: This help message"
}

while getopts chv: opt; do
while getopts chn:v: opt; do
case $opt in
c) FULL_CLEAN=true
;;
v) VERSION=$OPTARG
;;
n) echo "parsing num nodes"
NUM_NODES=$OPTARG
;;
h) usage
exit 0
;;
esac
shift
done

shift $(($OPTIND-1))

RIAK_HOME=$RT_HOME/riak-$VERSION

if ! [[ -d $RIAK_HOME || -h $RIAK_HOME ]]; then
echo "Riak home $RIAK_HOME does not exist."
exit 1
fi

cd $RIAK_HOME
echo "Reseting the riak_test environment using RIAK_HOME=$RIAK_HOME, RT_HOME=$RT_HOME, NUM_NODES=$NUM_NODES, VERSION=$VERSION, and FULL_CLEAN=$FULL_CLEAN"

echo "Removing previous stagedevrel instance from $RIAK_HOME and rebuilding ..."
cd $RIAK_HOME

# Clean out previous devrel build ...
if [ "$FULL_CLEAN" = true ] ; then
echo "Cleaning Riak in $RIAK_HOME ..."
make devclean
else
echo "Removing previous stagedevrel instance from $RIAK_HOME and rebuilding ..."
rm -rf dev
fi

# Rebuild Riak ...
make stagedevrel
echo "Building Riak stagedevrel with $NUM_NODES nodes in $RIAK_HOME ..."
make stagedevrel DEVNODES=$NUM_NODES

$RT_HOME/bin/rtdev-current.sh

echo "Rebuilding riak_test in $RT_HOME ..."
cd $RT_HOME

if [ "$FULL_CLEAN" = true ] ; then
echo "Cleaning riak_test in $RT_HOME ..."
make clean
fi

echo "Rebuilding riak_test in $RT_HOME ..."
make

# Return back to where we started ...
Expand Down
34 changes: 34 additions & 0 deletions tests/ensemble_start_without_aae.erl
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
%% -------------------------------------------------------------------
%%
%% Copyright (c) 2013-2014 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.
%%
%% -------------------------------------------------------------------

-module(ensemble_start_without_aae).
-export([confirm/0]).
-include_lib("eunit/include/eunit.hrl").

confirm() ->

NumNodes = 5,
NVal = 5,

Config = ensemble_util:fast_config(NVal, false),
lager:info("Building cluster with consensus enabled and AAE disabled. Waiting for ensemble to stablize ..."),

_ = ensemble_util:build_cluster_without_quorum(NumNodes, Config),
pass.
44 changes: 35 additions & 9 deletions tests/ensemble_util.erl
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@
-module(ensemble_util).
-compile(export_all).

-define(DEFAULT_RING_SIZE, 16).

-include_lib("eunit/include/eunit.hrl").

build_cluster(Num, Config, NVal) ->
Expand All @@ -32,21 +34,45 @@ build_cluster(Num, Config, NVal) ->
ensemble_util:wait_until_stable(Node, NVal),
Nodes.

build_cluster_without_quorum(Num, Config) ->
Nodes = rt:deploy_nodes(Num, Config),
SetupLogCaptureFun = fun(Node) ->
rt:setup_log_capture(Node)
end,
lists:map(SetupLogCaptureFun, Nodes),
Node = hd(Nodes),
ok = rpc:call(Node, riak_ensemble_manager, enable, []),
_ = rpc:call(Node, riak_core_ring_manager, force_update, []),
rt:join_cluster(Nodes),
ensemble_util:wait_until_cluster(Nodes),
ensemble_util:wait_for_membership(Node),
Nodes.

fast_config(NVal) ->
fast_config(NVal, 16).

fast_config(NVal, RingSize) ->
[{riak_kv, [{anti_entropy_build_limit, {100, 1000}},
{anti_entropy_concurrency, 100},
{anti_entropy_tick, 100},
{anti_entropy, {on, []}},
{anti_entropy_timeout, 5000},
{storage_backend, riak_kv_memory_backend}]},
fast_config(NVal, ?DEFAULT_RING_SIZE).

fast_config(Nval, RingSize) when is_integer(RingSize) ->
fast_config(Nval, RingSize, true);
fast_config(Nval, EnableAAE) when is_boolean(EnableAAE) ->
fast_config(Nval, ?DEFAULT_RING_SIZE, EnableAAE).

fast_config(NVal, RingSize, EnableAAE) ->
[config_aae(EnableAAE),
{riak_core, [{default_bucket_props, [{n_val, NVal}]},
{vnode_management_timer, 1000},
{ring_creation_size, RingSize},
{enable_consensus, true}]}].

config_aae(true) ->
{riak_kv, [{anti_entropy_build_limit, {100, 1000}},
{anti_entropy_concurrency, 100},
{anti_entropy_tick, 100},
{anti_entropy, {on, []}},
{anti_entropy_timeout, 5000},
{storage_backend, riak_kv_memory_backend}]};
config_aae(false) ->
{riak_kv, [{anti_entropy, {off, []}}]}.

ensembles(Node) ->
rpc:call(Node, riak_kv_ensembles, ensembles, []).

Expand Down