diff options
Diffstat (limited to 'tests/volume.rc')
| -rw-r--r-- | tests/volume.rc | 130 |
1 files changed, 127 insertions, 3 deletions
diff --git a/tests/volume.rc b/tests/volume.rc index fe4d8306b..171f8d709 100644 --- a/tests/volume.rc +++ b/tests/volume.rc @@ -27,11 +27,18 @@ function volume_option() } function rebalance_status_field { - $CLI volume rebalance $1 status | sed -n '$p' | cut -d' ' -f4 + #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'). + #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 + + $CLI volume rebalance $1 status | awk '{print $7,$8,$9}' |sed -n 3p |tr -d '[^0-9+\.]'|sed 's/ *$//g' } function remove_brick_status_completed_field { - $CLI volume remove-brick $V0 $H0:$B0/r2d2_{4,5} status | awk '{print $6}' | sed -n 3p + local vol=$1 + local brick_list=$2 + $CLI volume remove-brick $vol $brick_list status | awk '{print $7}' | sed -n 3p } function get_mount_process_pid { @@ -39,11 +46,27 @@ function get_mount_process_pid { ps aux | grep glusterfs | grep -E "volfile-id[ =]/?$vol " | awk '{print $2}' | head -1 } +function get_nfs_pid () +{ + ps aux | grep "volfile-id\ gluster\/nfs" | awk '{print $2}' | head -1 +} + +function read_nfs_pidfile () +{ + echo `cat /var/lib/glusterd/nfs/run/nfs.pid` +} + +function cleanup_statedump { + pid=$1 + rm -f $statedumpdir/*$pid.dump.* + #.vimrc friendly comment */ +} + function generate_statedump { local fpath="" pid=$1 #remove old stale statedumps - rm -f $statedumpdir/*$pid.dump.* + cleanup_statedump $pid kill -USR1 $pid #Wait till the statedump is generated sleep 1 @@ -56,6 +79,11 @@ function generate_mount_statedump { generate_statedump $(get_mount_process_pid $vol) } +function cleanup_mount_statedump { + local vol=$1 + cleanup_statedump $(get_mount_process_pid $vol) +} + function _afr_child_up_status { local vol=$1 #brick_id is (brick-num in volume info - 1) @@ -84,6 +112,11 @@ function generate_shd_statedump { generate_statedump $(get_shd_process_pid $vol) } +function generate_nfs_statedump { + local vol=$1 + generate_statedump $(get_nfs_pid $vol) +} + function generate_brick_statedump { local vol=$1 local host=$2 @@ -98,6 +131,17 @@ function afr_child_up_status_in_shd { _afr_child_up_status $vol $brick_id generate_shd_statedump } +function afr_child_up_status_in_nfs { + local vol=$1 + #brick_id is (brick-num in volume info - 1) + local brick_id=$2 + _afr_child_up_status $vol $brick_id generate_nfs_statedump +} + +function nfs_up_status { + gluster volume status | grep "NFS Server" | awk '{print $6}' +} + function glustershd_up_status { gluster volume status | grep "Self-heal Daemon" | awk '{print $6}' } @@ -199,3 +243,83 @@ function dht_get_layout { local my_xa=trusted.glusterfs.dht getfattr -d -e hex -n $my_xa $1 2> /dev/null | grep "$my_xa=" | cut -d= -f2 } + +function afr_get_specific_changelog_xattr () +{ + local path=$1 + local key=$2 + local type=$3 + local specific_changelog="" + + changelog_xattr=$(afr_get_changelog_xattr "$path" "$key") + if [ "$type" == "data" ]; then + specific_changelog=${changelog_xattr:2:8} + elif [ "$type" == "metadata" ]; then + specific_changelog=${changelog_xattr:10:8} + elif [ "$type" == "entry" ]; then + specific_changelog=${changelog_xattr:18:8} + else + specific_changlog="error" + fi + + echo $specific_changelog +} +## + # query pathinfo xattr and extract POSIX pathname(s) + ## +function get_backend_paths { + local path=$1 + + getfattr -m . -n trusted.glusterfs.pathinfo $path | tr ' ' '\n' | sed -n 's/<POSIX.*:.*:\(.*\)>.*/\1/p' +} + +function do_volume_operations() { + local operation=$1 + local count=$2 + local force=$3 + + local pids=() + local cli + local v + + for i in `seq 1 $count`; do + cli="CLI_$i" + v="V`expr $i - 1`" + ${!cli} volume $operation ${!v} $force & + pids[$i]=$! + done + + for i in `seq 1 $count`; do + wait ${pids[$i]} + done +} + +function start_volumes() { + do_volume_operations start $1 +} + +function stop_volumes() { + do_volume_operations stop $1 +} + +function start_force_volumes() { + do_volume_operations start $1 force +} + +function stop_force_volumes() { + do_volume_operations stop $1 force +} + +function delete_volumes() { + do_volume_operations delete $1 +} + +function volume_exists() { + local volname=$1 + $CLI volume info $volname 2>&1 | grep -q 'does not exist' + if [ $? -eq 0 ]; then + return 1 + else + return 0 + fi +} |
