diff options
Diffstat (limited to 'tests/cluster.rc')
| -rw-r--r-- | tests/cluster.rc | 67 |
1 files changed, 51 insertions, 16 deletions
diff --git a/tests/cluster.rc b/tests/cluster.rc index f89f67e725b..34f5b02398f 100644 --- a/tests/cluster.rc +++ b/tests/cluster.rc @@ -11,7 +11,7 @@ function launch_cluster() { define_backends $count; define_hosts $count; define_glusterds $count $2; - define_clis $count; + define_clis $count $3; start_glusterds; } @@ -50,15 +50,16 @@ function define_glusterds() { sopt="management.glusterd-sockfile=${!b}/glusterd/gd.sock" #Get the logdir logdir=`gluster --print-logdir` + clopt="management.cluster-test-mode=${logdir}/$i"; #Fetch the testcases name and prefix the glusterd log with it logfile=`echo ${0##*/}`_glusterd$i.log - lopt="--log-file=$logdir/$logfile" + lopt="--log-file=$logdir/$i/$logfile" if [ "$2" == "-LDEBUG" ]; then - eval "glusterd_$i='glusterd -LDEBUG --xlator-option $wopt --xlator-option $bopt --xlator-option $ropt --xlator-option $sopt $lopt $popt'"; - eval "glusterd$i='glusterd -LDEBUG --xlator-option $wopt --xlator-option $bopt --xlator-option $ropt --xlator-option $sopt $lopt $popt'"; + eval "glusterd_$i='glusterd -LDEBUG --xlator-option $wopt --xlator-option $bopt --xlator-option $ropt --xlator-option $sopt --xlator-option $clopt $lopt $popt'"; + eval "glusterd$i='glusterd -LDEBUG --xlator-option $wopt --xlator-option $bopt --xlator-option $ropt --xlator-option $sopt --xlator-option $clopt $lopt $popt'"; else - eval "glusterd_$i='glusterd --xlator-option $wopt --xlator-option $bopt --xlator-option $ropt --xlator-option $sopt $lopt $popt'"; - eval "glusterd$i='glusterd --xlator-option $wopt --xlator-option $bopt --xlator-option $ropt --xlator-option $sopt $lopt $popt'"; + eval "glusterd_$i='glusterd --xlator-option $wopt --xlator-option $bopt --xlator-option $ropt --xlator-option $sopt --xlator-option $clopt $lopt $popt'"; + eval "glusterd$i='glusterd --xlator-option $wopt --xlator-option $bopt --xlator-option $ropt --xlator-option $sopt --xlator-option $clopt $lopt $popt'"; fi done } @@ -89,6 +90,20 @@ function kill_glusterd() { kill `cat $pidfile`; } +function restart_glusterd() { + local index=$1 + local b + local pidfile + local g + + b="B$index" + pidfile="${!b}/glusterd.pid" + + kill `cat $pidfile` + + g="glusterd_${index}" + ${!g} +} function kill_node() { local index=$1; @@ -96,7 +111,7 @@ function kill_node() { h="H$index"; - kill -9 $(ps -ef | grep gluster | grep ${!h} | awk '{print $2}'); + terminate_pids $(ps -ef | grep gluster | grep ${!h} | awk '{print $2}') find $B0/$index/glusterd/vols -name '*.pid' | xargs rm -f } @@ -133,8 +148,13 @@ function define_clis() { lopt1="--log-file=$logdir/$logfile1" - eval "CLI_$i='$CLI --glusterd-sock=${!b}/glusterd/gd.sock $lopt'"; - eval "CLI$i='$CLI --glusterd-sock=${!b}/glusterd/gd.sock $lopt1'"; + if [ "$2" == "-NO_FORCE" ]; then + eval "CLI_$i='$CLI_NO_FORCE --glusterd-sock=${!b}/glusterd/gd.sock $lopt'"; + eval "CLI$i='$CLI_NO_FORCE --glusterd-sock=${!b}/glusterd/gd.sock $lopt1'"; + else + eval "CLI_$i='$CLI --glusterd-sock=${!b}/glusterd/gd.sock $lopt'"; + eval "CLI$i='$CLI --glusterd-sock=${!b}/glusterd/gd.sock $lopt1'"; + fi done } @@ -142,9 +162,19 @@ function peer_count() { $CLI_1 peer status | grep 'Peer in Cluster (Connected)' | wc -l } +function attempt_replace_brick { + local cli_no=$1 + local vol=$2; + local src_brick=$3; + local dst_brick=$4; + + eval \$CLI_$cli_no volume replace-brick $vol $src_brick $dst_brick commit force; + echo $? +} + function cluster_rebalance_status_field { - #The rebalance status can be upto 3 words, (ex:'fix-layout in progress'), hence the awk-print $7 thru $9. - #But if the status is less than 3 words, it also prints the next field i.e the run_time_in_secs.(ex:'completed 3.00'). + #The rebalance status can be up to 3 words, (e.g.:'fix-layout in progress'), hence the awk-print $7 thru $9. + #But if the status is less than 3 words, it also prints the next field i.e the run_time_in_secs.(e.g.:'completed 3.00'). #So we trim the numbers out with `tr`. Finally remove the trailing white spaces with sed. What we get is one of the #strings in the 'cli_vol_task_status_str' char array of cli-rpc-ops.c @@ -174,10 +204,15 @@ function volinfo_field_2() $CLI_2 volume info $vol | grep "^$field: " | sed 's/.*: //'; } -function brick_up_status_1 { - local vol=$1 - local host=$2 - local brick=$3 - $CLI_1 volume status $vol $host:$brick --xml | sed -ne 's/.*<status>\([01]\)<\/status>/\1/p' +function cluster_brick_up_status { + local vol=$2 + local host=$3 + local brick=$4 + eval \$CLI_$1 volume status $vol $host:$brick --xml | sed -ne 's/.*<status>\([01]\)<\/status>/\1/p' } +function cluster_remove_brick_status_completed_field { + local vol=$1 + local brick_list=$2 + $CLI_1 volume remove-brick $vol $brick_list status | awk '{print $7}' | sed -n 3p +} |
