glusterfs/tests/tier.rc
hari gowtham d5e67cd2b2 tier/cli : printing a warning instead of skipping the node
Problem: skipping the status of the nodes down creates confusion
to the user as one might see the status as completed for all nodes
and while performing detach commit, the operation will fail as the
node is down

Fix: Display a warning message

Note: When the last node is down (as per the peer list) then
warning message can't be displayed as the total number of peers
participating in the transaction is considered to be the total count.

Change-Id: Ib7afbd1b26df3378e4d537db06f41f5c105ad86e
BUG: 1324439
Signed-off-by: hari gowtham <hgowtham@redhat.com>
Reviewed-on: http://review.gluster.org/14347
Tested-by: hari gowtham <hari.gowtham005@gmail.com>
Smoke: Gluster Build System <jenkins@build.gluster.com>
CentOS-regression: Gluster Build System <jenkins@build.gluster.com>
Reviewed-by: Atin Mukherjee <amukherj@redhat.com>
NetBSD-regression: NetBSD Build System <jenkins@build.gluster.org>
2016-05-20 07:25:37 -07:00

150 lines
3.0 KiB
Bash

#!/bin/bash
# Common tier functions
# Check if a file is being migrated
# by checking for the presence of
# the sticky bit
# Args: $1 : path to file
function is_sticky_set () {
echo $1
if [ -k $1 ];
then
echo "yes"
else
echo "no"
fi
}
function exists_and_regular_file () {
filepath=$1
if [ -n "$filepath" ];
then
if [ -k "$filepath" ]
then
echo "no"
else
echo "yes"
fi
else
echo "no"
fi
}
function check_counters {
index=0
ret=0
rm -f /tmp/tc*.txt
echo "0" > /tmp/tc2.txt
$CLI volume rebalance $V0 tier status | grep localhost > /tmp/tc.txt
promote=`cat /tmp/tc.txt |awk '{print $2}'`
demote=`cat /tmp/tc.txt |awk '{print $3}'`
if [ "${promote}" != "${1}" ]; then
echo "1" > /tmp/tc2.txt
elif [ "${demote}" != "${2}" ]; then
echo "2" > /tmp/tc2.txt
fi
# temporarily disable non-Linux tests.
case $OSTYPE in
NetBSD | FreeBSD | Darwin)
echo "0" > /tmp/tc2.txt
;;
esac
cat /tmp/tc2.txt
}
function detach_start {
$CLI volume tier $1 detach start
echo $?;
}
# Grab md5sum without file path (failed attempt notifications are discarded)
function fingerprint {
md5sum $1 2> /dev/null | grep --only-matching -m 1 '^[0-9a-f]*'
}
# Create a large number of files in the current directory.
# $1 : file name prefix. Will create files $2-1 to $2-$3
# $2 : number of files
function create_many_files {
filename=$1
num=$2
for i in `seq 1 $num`; do
dd if=/dev/urandom of=./${dirname}/${filename}$i bs=104857 count=1;
done
}
function confirm_tier_removed {
$CLI system getspec $V0 | grep $1
if [ $? == 0 ]; then
echo "1"
else
echo "0"
fi
}
function confirm_vol_stopped {
$CLI volume stop $1
if [ $? == 0 ]; then
echo "0"
else
echo "1"
fi
}
function sleep_first_cycle {
startTime=$(date +%s)
mod=$(( ( $startTime % $1 ) + 1 ))
sleep $mod
}
function sleep_until_mid_cycle {
startTime=$(date +%s)
mod=$(( ( $startTime % $1 ) + 1 ))
mod=$(( $1 - $mod ))
mod=$(( $mod + $1 / 2 ))
sleep $mod
}
function tier_daemon_check () {
pgrep -f "rebalance/$V0"
echo "$?"
}
function rebalance_run_time () {
local time=$($CLI volume rebalance $1 status | awk '{print $9}' | sed -n 3p);
local hh=$(echo $time | cut -d ':' -f1);
local mm=$(echo $time | cut -d ':' -f2);
local ss=$(echo $time | cut -d ':' -f3);
local total=$(($hh * 3600 + $mm * 60 + $ss));
echo $total;
}
function tier_detach_commit () {
$CLI_1 volume tier $V0 detach commit | grep "success" | wc -l
}
function tier_detach_status_node_down () {
$CLI_1 volume tier $V0 detach status | grep "WARNING" | wc -l
}
function tier_status_node_down () {
$CLI_1 volume tier $V0 status | grep "WARNING" | wc -l
}