diff options
Diffstat (limited to 'tests/volume.rc')
| -rw-r--r-- | tests/volume.rc | 94 |
1 files changed, 92 insertions, 2 deletions
diff --git a/tests/volume.rc b/tests/volume.rc index 54b6173c5..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 | awk '{print $6}' | sed -n 3p + #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 { @@ -105,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 @@ -119,6 +131,13 @@ 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}' } @@ -225,6 +244,26 @@ function dht_get_layout { 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) ## @@ -233,3 +272,54 @@ function get_backend_paths { 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 +} |
