Whamcloud - gitweb
LU-6966 test: Dash in FSNAME causes warning in testframework
[fs/lustre-release.git] / lustre / tests / test-framework.sh
index baaaae9..48795c0 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 () {
@@ -1224,6 +1224,8 @@ mount_facet() {
        local mntpt=$(facet_mntpt $facet)
        local opts="${!opt} $@"
 
+       module_loaded lustre || load_modules
+
        if [ $(facet_fstype $facet) == ldiskfs ] &&
           ! do_facet $facet test -b ${!dev}; then
                opts=$(csa_add "$opts" -o loop)
@@ -1287,19 +1289,19 @@ mount_facet() {
 
 # start facet device options
 start() {
-    local facet=$1
-    shift
-    local device=$1
-    shift
-    eval export ${facet}_dev=${device}
-    eval export ${facet}_opt=\"$@\"
+       local facet=$1
+       shift
+       local device=$1
+       shift
+       eval export ${facet}_dev=${device}
+       eval export ${facet}_opt=\"$@\"
 
-    local varname=${facet}failover_dev
-    if [ -n "${!varname}" ] ; then
-        eval export ${facet}failover_dev=${!varname}
-    else
-        eval export ${facet}failover_dev=$device
-    fi
+       local varname=${facet}failover_dev
+       if [ -n "${!varname}" ] ; then
+               eval export ${facet}failover_dev=${!varname}
+       else
+               eval export ${facet}failover_dev=$device
+       fi
 
        local mntpt=$(facet_mntpt $facet)
        do_facet ${facet} mkdir -p $mntpt
@@ -1380,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
@@ -1461,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
@@ -1501,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
@@ -4634,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()
@@ -4782,6 +4687,9 @@ error_noexit() {
                        echo "$@" > $LOGDIR/err
                fi
        fi
+
+       # cleanup the env for failed tests
+       reset_fail_loc
 }
 
 exit_status () {
@@ -6165,19 +6073,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() {
@@ -6314,6 +6224,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`}