Whamcloud - gitweb
LU-7227 tests: check dmesg for errors after test
[fs/lustre-release.git] / lustre / tests / test-framework.sh
index 47f65ea..eaa4878 100755 (executable)
@@ -1116,7 +1116,7 @@ get_osd_param() {
        local name=$3
 
        do_nodes $nodes "$LCTL get_param -n obdfilter.$device.$name \
-               osd-*.$device.$name 2>&1" | grep -v 'Found no match'
+               osd-*.$device.$name 2>&1" | grep -v 'error:'
 }
 
 set_osd_param() {
@@ -1126,7 +1126,7 @@ set_osd_param() {
        local value=$4
 
        do_nodes $nodes "$LCTL set_param -n obdfilter.$device.$name=$value \
-               osd-*.$device.$name=$value 2>&1" | grep -v 'Found no match'
+               osd-*.$device.$name=$value 2>&1" | grep -v 'error:'
 }
 
 set_debug_size () {
@@ -1382,70 +1382,6 @@ quota_type() {
        return $rc
 }
 
-# XXX This function is kept for interoperability with old server (< 2.3.50),
-#     it should be removed whenever we drop the interoperability for such
-#     server.
-restore_quota_old() {
-       local mntpt=${1:-$MOUNT}
-       local quota_type=$(quota_type $FSNAME | grep MDT | cut -d "=" -f2)
-       if [ ! "$old_QUOTA_TYPE" ] ||
-               [ "$quota_type" = "$old_QUOTA_TYPE" ]; then
-               return
-       fi
-       quota_save_version $old_QUOTA_TYPE
-}
-
-# XXX This function is kept for interoperability with old server (< 2.3.50),
-#     it should be removed whenever we drop the interoperability for such
-#     server.
-setup_quota_old(){
-       local mntpt=$1
-
-       # no quota enforcement for now and accounting works out of the box
-       return
-
-    # We need save the original quota_type params, and restore them after testing
-
-    # Suppose that quota type the same on mds and ost
-    local quota_type=$(quota_type | grep MDT | cut -d "=" -f2)
-    [ ${PIPESTATUS[0]} -eq 0 ] || error "quota_type failed!"
-    echo "[HOST:$HOSTNAME] [old_quota_type:$quota_type] [new_quota_type:$QUOTA_TYPE]"
-    if [ "$quota_type" != "$QUOTA_TYPE" ]; then
-        export old_QUOTA_TYPE=$quota_type
-        quota_save_version $QUOTA_TYPE
-    else
-        qtype=$(tr -c -d "ug" <<< $QUOTA_TYPE)
-        $LFS quotacheck -$qtype $mntpt || error "quotacheck has failed for $type"
-    fi
-
-    local quota_usrs=$QUOTA_USERS
-
-    # get_filesystem_size
-    local disksz=$(lfs_df $mntpt | grep "summary"  | awk '{print $2}')
-    local blk_soft=$((disksz + 1024))
-    local blk_hard=$((blk_soft + blk_soft / 20)) # Go 5% over
-
-    local Inodes=$(lfs_df -i $mntpt | grep "summary"  | awk '{print $2}')
-    local i_soft=$Inodes
-    local i_hard=$((i_soft + i_soft / 20))
-
-    echo "Total disk size: $disksz  block-softlimit: $blk_soft block-hardlimit:
-        $blk_hard inode-softlimit: $i_soft inode-hardlimit: $i_hard"
-
-    local cmd
-    for usr in $quota_usrs; do
-        echo "Setting up quota on $HOSTNAME:$mntpt for $usr..."
-        for type in u g; do
-            cmd="$LFS setquota -$type $usr -b $blk_soft -B $blk_hard -i $i_soft -I $i_hard $mntpt"
-            echo "+ $cmd"
-            eval $cmd || error "$cmd FAILED!"
-        done
-        # display the quota status
-        echo "Quota settings for $usr : "
-        $LFS quota -v -u $usr $mntpt || true
-    done
-}
-
 # get mdt quota type
 mdt_quota_type() {
        local varsvc=${SINGLEMDS}_svc
@@ -1463,11 +1399,6 @@ ost_quota_type() {
 
 # restore old quota type settings
 restore_quota() {
-       if [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.3.50) ]; then
-               restore_quota_old
-               return
-       fi
-
        if [ "$old_MDT_QUOTA_TYPE" ]; then
                do_facet mgs $LCTL conf_param \
                        $FSNAME.quota.mdt=$old_MDT_QUOTA_TYPE
@@ -1503,11 +1434,6 @@ mdt_free_inodes() {
 }
 
 setup_quota(){
-       if [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.3.50) ]; then
-               setup_quota_old $1
-               return
-       fi
-
        local mntpt=$1
 
        # save old quota type & set new quota type
@@ -4636,33 +4562,10 @@ set_nodes_failloc () {
 }
 
 cancel_lru_locks() {
-    $LCTL mark "cancel_lru_locks $1 start"
-
-    if [ $1 != "MGC" ]; then
-       for d in $(lctl get_param -N ldlm.namespaces.*.lru_size |
-                egrep -i $1); do
-           $LCTL set_param -n $d=clear
-       done
-       $LCTL get_param ldlm.namespaces.*.lock_unused_count | egrep -i $1 |
-               grep -v '=0'
-    else
-       for d in $(find \
-               /{proc,sys}/fs/lustre/ldlm/namespaces/*$1*/lru_size \
-               2> /dev/null); do
-           echo "clear" > $d
-       done
-
-       for d in $(find \
-               /{proc,sys}/fs/lustre/ldlm/namespaces/*$1*/lock_unused_count \
-               2> /dev/null); do
-           if [ $(cat $d) != 0 ]; then
-               echo "ldlm.namespaces.$(echo "$d" |
-                       cut -f 7 -d'/').lock_unused_count=$(cat $d)"
-           fi
-       done
-    fi
-
-    $LCTL mark "cancel_lru_locks $1 stop"
+       #$LCTL mark "cancel_lru_locks $1 start"
+       $LCTL set_param -n ldlm.namespaces.*$1*.lru_size=clear
+       $LCTL get_param ldlm.namespaces.*$1*.lock_unused_count | grep -v '=0'
+       #$LCTL mark "cancel_lru_locks $1 stop"
 }
 
 default_lru_size()
@@ -4784,6 +4687,9 @@ error_noexit() {
                        echo "$@" > $LOGDIR/err
                fi
        fi
+
+       # cleanup the env for failed tests
+       reset_fail_loc
 }
 
 exit_status () {
@@ -5026,6 +4932,18 @@ banner() {
     log "$msg== $(date +"%H:%M:%S (%s)")"
 }
 
+check_dmesg_for_errors() {
+       local res
+       local errors="VFS: Busy inodes after unmount of\|\
+ldiskfs_check_descriptors: Checksum for group 0 failed\|\
+group descriptors corrupted"
+
+       res=$(do_nodes $(comma_list $(nodes_list)) "dmesg" | grep "$errors")
+       [ -z "$res" ] && return 0
+       echo "Kernel error detected: $res"
+       return 1
+}
+
 #
 # Run a single test function and cleanup after it.
 #
@@ -5047,6 +4965,7 @@ run_one() {
        reset_fail_loc
        check_grant ${testnum} || error "check_grant $testnum failed with $?"
        check_catastrophe || error "LBUG/LASSERT detected"
+       check_dmesg_for_errors || error "Error in dmesg detected"
        if [ "$PARALLEL" != "yes" ]; then
                ps auxww | grep -v grep | grep -q multiop &&
                                        error "multiop still running"
@@ -6167,19 +6086,21 @@ create_pool() {
 }
 
 add_pool_to_list () {
-    local fsname=${1%%.*}
-    local poolname=${1##$fsname.}
+       local fsname=${1%%.*}
+       local poolname=${1##$fsname.}
 
-    local listvar=${fsname}_CREATED_POOLS
-    eval export ${listvar}=$(expand_list ${!listvar} $poolname)
+       local listvar=${fsname}_CREATED_POOLS
+       local temp=${listvar}=$(expand_list ${!listvar} $poolname)
+       eval export $temp
 }
 
 remove_pool_from_list () {
-    local fsname=${1%%.*}
-    local poolname=${1##$fsname.}
+       local fsname=${1%%.*}
+       local poolname=${1##$fsname.}
 
-    local listvar=${fsname}_CREATED_POOLS
-    eval export ${listvar}=$(exclude_items_from_list ${!listvar} $poolname)
+       local listvar=${fsname}_CREATED_POOLS
+       local temp=${listvar}=$(exclude_items_from_list ${!listvar} $poolname)
+       eval export $temp
 }
 
 destroy_pool_int() {
@@ -6316,6 +6237,31 @@ max_recovery_time() {
        echo -n $service_time
 }
 
+recovery_time_min() {
+       local connection_switch_min=5
+       local connection_switch_inc=5
+       local connection_switch_max
+       local reconnect_delay_max
+       local initial_connect_timeout
+       local max
+       local timout_20
+
+       #connection_switch_max=min(50, max($connection_switch_min,$TIMEOUT)
+       (($connection_switch_min > $TIMEOUT)) &&
+               max=$connection_switch_min || max=$TIMEOUT
+       (($max < 50)) && connection_switch_max=$max || connection_switch_max=50
+
+       #initial_connect_timeout = max(connection_switch_min, obd_timeout/20)
+       timeout_20=$((TIMEOUT/20))
+       (($connection_switch_min > $timeout_20)) &&
+               initial_connect_timeout=$connection_switch_min ||
+               initial_connect_timeout=$timeout_20
+
+       reconnect_delay_max=$((connection_switch_max + connection_switch_inc + \
+                              initial_connect_timeout))
+       echo $((2 * reconnect_delay_max))
+}
+
 get_clients_mount_count () {
     local clients=${CLIENTS:-`hostname`}