diff options
Diffstat (limited to 'tests/volume.rc')
| -rw-r--r-- | tests/volume.rc | 171 |
1 files changed, 145 insertions, 26 deletions
diff --git a/tests/volume.rc b/tests/volume.rc index 261c6554d46..b38848c0e52 100644 --- a/tests/volume.rc +++ b/tests/volume.rc @@ -84,10 +84,6 @@ function fix-layout_status_field { $CLI volume rebalance $1 status | awk '{print $2,$3,$4}' |sed -n 3p |tr -d '[^0-9+\.]'|sed 's/ *$//g' } -function detach_tier_status_field_complete { - $CLI volume tier $1 detach status | awk '{print $7}' |sed -n 4p -} - function remove_brick_status_completed_field { local vol=$1 local brick_list=$2 @@ -116,16 +112,33 @@ function cleanup_statedump { #.vimrc friendly comment */ } +function wait_statedump_ready { + local maxtime="${1}000000000" + local pid="$2" + local deadline="$(($(date +%s%N) + maxtime))" + local fname + + while [[ "$(date +%s%N)" < "$deadline" ]]; do + fname="$statedumpdir/$(ls $statedumpdir | grep -E "\.$pid\.dump\.")" + if [[ -f "$fname" ]]; then + grep "^DUMP-END-TIME" "$fname" >/dev/null + if [[ $? -eq 0 ]]; then + echo $fname + return + fi + fi + sleep 0.1 + done + + echo "nostatedump" +} + function generate_statedump { - local fpath="" pid=$1 #remove old stale statedumps cleanup_statedump $pid kill -USR1 $pid - #Wait till the statedump is generated - sleep 1 - fname=$(ls $statedumpdir | grep -E "\.$pid\.dump\.") - echo $statedumpdir/$fname + wait_statedump_ready 3 $pid } function generate_mount_statedump { @@ -180,7 +193,7 @@ function afr_child_up_status_meta { local mnt=$1 local repl=$2 local child=$3 - grep "child_up\[$child\]" $mnt/.meta/graphs/active/$repl/private | awk '{print $3}' + grep -E "^child_up\[$child\]" $mnt/.meta/graphs/active/$repl/private | awk '{print $3}' } function client_connected_status_meta { @@ -237,11 +250,13 @@ function ec_child_up_count_shd { } function get_shd_process_pid { - ps auxww | grep glusterfs | grep -E "glustershd/glustershd.pid" | awk '{print $2}' | head -1 + local vol=$1 + ps auxww | grep "process-name\ glustershd" | awk '{print $2}' | head -1 } function generate_shd_statedump { - generate_statedump $(get_shd_process_pid) + local vol=$1 + generate_statedump $(get_shd_process_pid $vol) } function generate_nfs_statedump { @@ -281,6 +296,10 @@ function quotad_up_status { gluster volume status | grep "Quota Daemon" | awk '{print $7}' } +function get_glusterd_pid { + pgrep '^glusterd$' | head -1 +} + function get_brick_pidfile { local vol=$1 local host=$2 @@ -303,15 +322,12 @@ function kill_brick { local socket=$(cat $cmdline | tr '\0' '\n' | grep '\.socket$') gf_attach -d $socket $brick - cnt=1 - while [ "$cnt" -le "$PROCESS_UP_TIMEOUT" ] ; - do - online=`$CLI volume status $vol $host:$brick --xml | sed -ne 's/.*<status>\([01]\)<\/status>/\1/p'` - if [ $online -eq 0 ] ; then - break; - fi - cnt=$(( $cnt + 1 )) - sleep 1 + + local deadline="$(($(date +%s%N) + ${PROCESS_UP_TIMEOUT}000000000))" + while [[ "$(date +%s%N)" < "$deadline" ]]; do + if [[ "$(brick_up_status $vol $host $brick)" == "0" ]]; then + break + fi done } @@ -371,6 +387,19 @@ function get_gfid2path { getfattr -h --only-values -n glusterfs.gfidtopath $path 2>/dev/null } +function get_mdata { + local path=$1 + getfattr -h -e hex -n trusted.glusterfs.mdata $path 2>/dev/null | grep "trusted.glusterfs.mdata" | cut -f2 -d'=' +} + +function get_mdata_count { + getfattr -d -m . -e hex $@ 2>/dev/null | grep mdata | wc -l +} + +function get_mdata_uniq_count { + getfattr -d -m . -e hex $@ 2>/dev/null | grep mdata | uniq | wc -l +} + function get_xattr_key { local key=$1 local path=$2 @@ -540,9 +569,8 @@ function volume_exists() { } function killall_gluster() { - pkill gluster + terminate_pids $(process_pids gluster) find $GLUSTERD_PIDFILEDIR -name '*.pid' | xargs rm -f - sleep 1 } function afr_get_index_count { @@ -833,6 +861,9 @@ function get_fd_count { else count=$(grep "${brick}.active.1" -A3 $statedump | grep "gfid=$gfid_str" -A2 | grep fd-count | cut -f2 -d'=' | tail -1) fi +# If no information is found for a given gfid, it means it has not been +# accessed, so it doesn't have any open fd. In this case we return 0. + count="${count:-0}" rm -f $statedump echo $count } @@ -859,7 +890,6 @@ function get_mount_active_size_value { local vol=$1 local mount=$2 local statedump=$(generate_mount_statedump $vol $mount) - sleep 1 local val=$(grep "active_size" $statedump | cut -f2 -d'=' | tail -1) rm -f $statedump echo $val @@ -869,7 +899,6 @@ function get_mount_lru_size_value { local vol=$1 local mount=$2 local statedump=$(generate_mount_statedump $vol $mount) - sleep 1 local val=$(grep "lru_size" $statedump | cut -f2 -d'=' | tail -1) rm -f $statedump echo $val @@ -879,5 +908,95 @@ function check_changelog_op { local clog_path=$1 local op=$2 - $PYTHON $(dirname $0)/../../utils/changelogparser.py ${clog_path}/CHANGELOG | grep $op | wc -l + $PYTHON $(dirname $0)/../../utils/changelogparser.py ${clog_path}/CHANGELOG | grep "$op" | wc -l +} + +function processed_changelogs { + local processed_dir=$1 + count=$(ls -l $processed_dir | grep CHANGELOG | wc -l) + if [ $count -gt 0 ]; + then + echo "Y" + else + echo "N" + fi +} + +function volgen_check_ancestry { + #Returns Y if ancestor_xl is an ancestor of $child_xl according to the volfile + local volfile="$1" + + local child_xl_type="$2" + local child_xl="$3" + + local ancestor_xl_type="$4" + local ancestor_xl="$5" + + child_linenum=$(awk '/type $child_xl_type\/$child_xl/ {print FNR}' $volfile) + ancestor_linenum=$(awk '/type $ancestor_xl_type\/$ancestor_xl/ {print FNR}' $volfile) + + if [ $child_linenum -lt $ancestor_linenum ]; + then + echo "Y" + else + echo "N" + fi +} + +function get_shd_mux_pid { + local volume=$1 + pid=`$CLI volume status $volume shd | awk '/Self-heal/{print $8}'` + echo $pid +} + +function shd_count { + ps aux | grep "glustershd" | grep -v grep | wc -l +} + +function number_healer_threads_shd { + local pid=$(get_shd_mux_pid $1) + pstack $pid | grep $2 | wc -l +} + +function get_mtime { + local time=$(get-mdata-xattr -m $1) + if [ $time == "-1" ]; + then + echo $(stat -c %Y $1) + else + echo $time + fi +} + +function get_ctime { + local time=$(get-mdata-xattr -c $1) + if [ $time == "-1" ]; + then + echo $(stat -c %Z $1) + else + echo $time + fi +} + +function get_atime { + local time=$(get-mdata-xattr -a $1) + if [ $time == "-1" ]; + then + echo $(stat -c %X $1) + else + echo $time + fi +} + +function get-xml() +{ + $CLI $1 --xml | xmllint --format - | grep $2 | sed 's/\(<"$2">\|<\/"$2">\)//g' +} + +function logging_time_check() +{ + local logdir=$1 + local logfile=`echo ${0##*/}`_glusterd1.log + + cat $logdir/1/$logfile | tail -n 2 | head -n 1 | grep $(date +%H:%M) | wc -l } |
