Whamcloud - gitweb
b=13766
[fs/lustre-release.git] / lustre / tests / test-framework.sh
index 924fafc..0fa6898 100644 (file)
@@ -13,6 +13,7 @@ export CATASTROPHE=${CATASTROPHE:-/proc/sys/lnet/catastrophe}
 export GSS=false
 export GSS_KRB5=false
 export GSS_PIPEFS=false
+export IDENTITY_UPCALL=false
 #export PDSH="pdsh -S -Rssh -w"
 
 # eg, assert_env LUSTRE MDSNODES OSTNODES CLIENTS
@@ -35,29 +36,34 @@ usage() {
 }
 
 print_summary () {
+    [ "$TESTSUITE" == "lfscktest" ] && return 0
     [ -n "$ONLY" ] && echo "WARNING: ONLY is set to ${ONLY}."
     local form="%-13s %-17s %s\n"
-    echo "$(printf "$form" "status" "script" "skipped tests")"
+    printf "$form" "status" "script" "skipped tests E(xcluded) S(low)"
     echo "------------------------------------------------------------------------------------"
     for O in $TESTSUITE_LIST; do
         local skipped=""
+        local slow=""
         local o=$(echo $O | tr "[:upper:]" "[:lower:]")
         o=${o//_/-}
         o=${o//tyn/tyN}
-        local log=${TMP}/${o}.log 
-        [ -f $log ] && skipped=$(cat $log | awk '{ printf " %s", $3 }' | sed 's/test_//g')
+        local log=${TMP}/${o}.log
+        [ -f $log ] && skipped=$(grep excluded $log | awk '{ printf " %s", $3 }' | sed 's/test_//g')
+        [ -f $log ] && slow=$(grep SLOW $log | awk '{ printf " %s", $3 }' | sed 's/test_//g')
         [ "${!O}" = "done" ] && \
-            echo "$(printf "$form" "Done" "$O" "$skipped")"
+            printf "$form" "Done" "$O" "E=$skipped" && \
+            [ -n "$slow" ] && printf "$form" "-" "-" "S=$slow"
+
     done
 
     for O in $TESTSUITE_LIST; do
         [ "${!O}" = "no" ] && \
-            echo "$(printf "$form" "Skipped" "$O" "")"
+            printf "$form" "Skipped" "$O" ""
     done
 
     for O in $TESTSUITE_LIST; do
         [ "${!O}" = "done" -o "${!O}" = "no" ] || \
-            echo "$(printf "$form" "UNFINISHED" "$O" "")"
+            printf "$form" "UNFINISHED" "$O" ""
     done
 }
 
@@ -69,23 +75,34 @@ init_test_env() {
     [ -d /r ] && export ROOT=${ROOT:-/r}
     export TMP=${TMP:-$ROOT/tmp}
     export TESTSUITELOG=${TMP}/${TESTSUITE}.log
+    export HOSTNAME=${HOSTNAME:-`hostname`}
 
     export PATH=:$PATH:$LUSTRE/utils:$LUSTRE/utils/gss:$LUSTRE/tests
     export LCTL=${LCTL:-"$LUSTRE/utils/lctl"}
+    [ ! -f "$LCTL" ] && export LCTL=$(which lctl)
     export LFS=${LFS:-"$LUSTRE/utils/lfs"}
-    [ ! -f "$LCTL" ] && export LCTL=$(which lctl) 
-    export LFS=${LFS:-"$LUSTRE/utils/lfs"}
-    [ ! -f "$LFS" ] && export LFS=$(which lfs) 
+    [ ! -f "$LFS" ] && export LFS=$(which lfs)
+    export L_GETIDENTITY=${L_GETIDENTITY:-"$LUSTRE/utils/l_getidentity"}
+    if [ ! -f "$L_GETIDENTITY" ]; then
+        if `which l_getidentity > /dev/null 2>&1`; then
+            export L_GETIDENTITY=$(which l_getidentity)
+        else
+            export L_GETIDENTITY=NONE
+        fi
+    fi
     export MKFS=${MKFS:-"$LUSTRE/utils/mkfs.lustre"}
-    [ ! -f "$MKFS" ] && export MKFS=$(which mkfs.lustre) 
+    [ ! -f "$MKFS" ] && export MKFS=$(which mkfs.lustre)
     export TUNEFS=${TUNEFS:-"$LUSTRE/utils/tunefs.lustre"}
-    [ ! -f "$TUNEFS" ] && export TUNEFS=$(which tunefs.lustre) 
+    [ ! -f "$TUNEFS" ] && export TUNEFS=$(which tunefs.lustre)
     export CHECKSTAT="${CHECKSTAT:-"checkstat -v"} "
     export FSYTPE=${FSTYPE:-"ldiskfs"}
     export NAME=${NAME:-local}
     export LPROC=/proc/fs/lustre
     export LGSSD=${LGSSD:-"$LUSTRE/utils/gss/lgssd"}
+    [ "$GSS_PIPEFS" = "true" ] && [ ! -f "$LGSSD" ] && \
+        export LGSSD=$(which lgssd)
     export LSVCGSSD=${LSVCGSSD:-"$LUSTRE/utils/gss/lsvcgssd"}
+    [ ! -f "$LSVCGSSD" ] && export LSVCGSSD=$(which lsvcgssd)
     export KRB5DIR=${KRB5DIR:-"/usr/kerberos"}
     export DIR2
 
@@ -101,14 +118,23 @@ init_test_env() {
             ;;
     esac
 
-    # Paths on remote nodes, if different 
+    case "x$ID" in
+        xtrue)
+            IDENTITY_UPCALL=true
+            ;;
+        xfalse)
+            IDENTITY_UPCALL=false
+            ;;
+    esac
+
+    # Paths on remote nodes, if different
     export RLUSTRE=${RLUSTRE:-$LUSTRE}
     export RPWD=${RPWD:-$PWD}
     export I_MOUNTED=${I_MOUNTED:-"no"}
 
     # command line
-    
-    while getopts "rvf:" opt $*; do 
+
+    while getopts "rvf:" opt $*; do
         case $opt in
             f) CONFIG=$OPTARG;;
             r) REFORMAT=--reformat;;
@@ -156,17 +182,17 @@ load_modules() {
 
     echo Loading modules from $LUSTRE
     load_module ../lnet/libcfs/libcfs
-    [ -z "$LNETOPTS" ] && \
-        LNETOPTS=$(awk '/^options lnet/ { print $0}' /etc/modprobe.conf | sed 's/^options lnet //g')
+    [ -f /etc/modprobe.conf ] && MODPROBECONF=/etc/modprobe.conf
+    [ -f /etc/modprobe.d/Lustre ] && MODPROBECONF=/etc/modprobe.d/Lustre
+    [ -z "$LNETOPTS" -a -n "$MODPROBECONF" ] && \
+        LNETOPTS=$(awk '/^options lnet/ { print $0}' $MODPROBECONF | sed 's/^options lnet //g')
     echo "lnet options: '$LNETOPTS'"
     # note that insmod will ignore anything in modprobe.conf
     load_module ../lnet/lnet/lnet $LNETOPTS
     LNETLND=${LNETLND:-"socklnd/ksocklnd"}
     load_module ../lnet/klnds/$LNETLND
-    [ "$FSTYPE" = "ldiskfs" ] && load_module ../ldiskfs/ldiskfs/ldiskfs
     load_module lvfs/lvfs
     load_module obdclass/obdclass
-    load_module lvfs/fsfilt_$FSTYPE
     load_module ptlrpc/ptlrpc
     load_module ptlrpc/gss/ptlrpc_gss
     # Now, some modules depend on lquota without USE_QUOTA check,
@@ -179,19 +205,27 @@ load_modules() {
     load_module mdc/mdc
     load_module osc/osc
     load_module lov/lov
-    load_module mds/mds
-    load_module mdd/mdd
-    load_module mdt/mdt
-    load_module cmm/cmm
-    load_module osd/osd
-    load_module ost/ost
-    load_module obdfilter/obdfilter
+    load_module mgc/mgc
+    if [ -z "$CLIENTONLY" ]; then
+        [ "$FSTYPE" = "ldiskfs" ] && load_module ../ldiskfs/ldiskfs/ldiskfs
+        load_module mgs/mgs
+        load_module mds/mds
+        load_module mdd/mdd
+        load_module mdt/mdt
+        load_module lvfs/fsfilt_$FSTYPE
+        load_module cmm/cmm
+        load_module osd/osd
+        load_module ost/ost
+        load_module obdfilter/obdfilter
+    fi
+
     load_module llite/lustre
     load_module llite/llite_lloop
-    load_module mgc/mgc
-    load_module mgs/mgs
-    rm -f $TMP/ogdb-`hostname`
-    $LCTL modules > $TMP/ogdb-`hostname`
+    rm -f $TMP/ogdb-$HOSTNAME
+    OGDB=$TMP
+    [ -d /r ] && OGDB="/r/tmp"
+    $LCTL modules > $OGDB/ogdb-$HOSTNAME
+
     # 'mount' doesn't look in $PATH, just sbin
     [ -f $LUSTRE/utils/mount.lustre ] && cp $LUSTRE/utils/mount.lustre /sbin/. || true
 }
@@ -236,7 +270,7 @@ unload_modules() {
     MODULES=$($LCTL modules | awk '{ print $2 }')
     if [ -n "$MODULES" ]; then
     echo "Modules still loaded: "
-    echo $MODULES 
+    echo $MODULES
     if [ -e $LPROC ]; then
         echo "Lustre still loaded"
         cat $LPROC/devices || true
@@ -329,18 +363,13 @@ stop_gss_daemons() {
     send_sigint client lgssd
 }
 
-init_krb5_env() {
-    if [ ! -z $SEC ]; then
-        MDS_MOUNT_OPTS=$MDS_MOUNT_OPTS,sec=$SEC
-        OST_MOUNT_OPTS=$OST_MOUNT_OPTS,sec=$SEC
-    fi
-
+init_gss() {
     if $GSS; then
         start_gss_daemons
     fi
 }
 
-cleanup_krb5_env() {
+cleanup_gss() {
     if $GSS; then
         stop_gss_daemons
         # maybe cleanup credential cache?
@@ -362,7 +391,7 @@ ostdevlabel() {
 }
 
 # Facet functions
-# start facet device options 
+# start facet device options
 start() {
     facet=$1
     shift
@@ -370,12 +399,12 @@ start() {
     shift
     echo "Starting ${facet}: $@ ${device} ${MOUNT%/*}/${facet}"
     do_facet ${facet} mkdir -p ${MOUNT%/*}/${facet}
-    do_facet ${facet} mount -t lustre $@ ${device} ${MOUNT%/*}/${facet} 
+    do_facet ${facet} mount -t lustre $@ ${device} ${MOUNT%/*}/${facet}
     RC=${PIPESTATUS[0]}
     if [ $RC -ne 0 ]; then
-        echo mount -t lustre $@ ${device} ${MOUNT%/*}/${facet} 
+        echo mount -t lustre $@ ${device} ${MOUNT%/*}/${facet}
         echo Start of ${device} on ${facet} failed ${RC}
-    else 
+    else
         do_facet ${facet} "sysctl -w lnet.debug=$PTLDEBUG; \
         sysctl -w lnet.subsystem_debug=${SUBSYSTEM# }; \
         sysctl -w lnet.debug_mb=${DEBUG_SIZE}"
@@ -423,14 +452,14 @@ zconf_mount() {
         exit 1
     fi
 
-    echo "Starting client: $OPTIONS $device $mnt" 
+    echo "Starting client: $OPTIONS $device $mnt"
     do_node $client mkdir -p $mnt
     do_node $client mount -t lustre $OPTIONS $device $mnt || return 1
 
     do_node $client "sysctl -w lnet.debug=$PTLDEBUG;
         sysctl -w lnet.subsystem_debug=${SUBSYSTEM# };
         sysctl -w lnet.debug_mb=${DEBUG_SIZE}"
-    [ -d /r ] && $LCTL modules > /r/tmp/ogdb-`hostname`
+    [ -d /r ] && $LCTL modules > /r/tmp/ogdb-$HOSTNAME
     return 0
 }
 
@@ -441,6 +470,7 @@ zconf_umount() {
     local running=$(do_node $client "grep -c $mnt' ' /proc/mounts") || true
     if [ $running -ne 0 ]; then
         echo "Stopping client $mnt (opts:$force)"
+        lsof | grep "$mnt" || true
         do_node $client umount $force $mnt
     fi
 }
@@ -449,7 +479,7 @@ shutdown_facet() {
     facet=$1
     if [ "$FAILURE_MODE" = HARD ]; then
         $POWER_DOWN `facet_active_host $facet`
-        sleep 2 
+        sleep 2
     elif [ "$FAILURE_MODE" = SOFT ]; then
         stop $facet
     fi
@@ -540,7 +570,7 @@ wait_mds_recovery_done () {
         echo "Waiting $(($MAX - $WAIT)) secs for MDS recovery done"
     done
     echo "MDS recovery not done in $MAX sec"
-    return 1            
+    return 1
 }
 
 wait_exit_ST () {
@@ -638,6 +668,11 @@ fail() {
     df $MOUNT || error "post-failover df: $?"
 }
 
+fail_nodf() {
+        local facet=$1
+        facet_failover $facet
+}
+
 fail_abort() {
     local facet=$1
     stop $facet
@@ -666,7 +701,7 @@ h2gm () {
 
 h2name_or_ip() {
     if [ "$1" = "client" -o "$1" = "'*'" ]; then echo \'*\'; else
-        echo $1"@$2" 
+        echo $1"@$2"
     fi
 }
 
@@ -729,7 +764,7 @@ facet_active() {
     fi
 
     active=${!activevar}
-    if [ -z "$active" ] ; then 
+    if [ -z "$active" ] ; then
         echo -n ${facet}
     else
         echo -n ${active}
@@ -740,7 +775,7 @@ facet_active_host() {
     local facet=$1
     local active=`facet_active $facet`
     if [ "$facet" == client ]; then
-        hostname
+        echo $HOSTNAME
     else
         echo `facet_host $active`
     fi
@@ -748,7 +783,7 @@ facet_active_host() {
 
 change_active() {
     local facet=$1
-    failover=${facet}failover 
+    failover=${facet}failover
     host=`facet_host $failover`
     [ -z "$host" ] && return
     curactive=`facet_active $facet`
@@ -766,8 +801,11 @@ do_node() {
     HOST=$1
     shift
     local myPDSH=$PDSH
-    if [ "$HOST" = "$(hostname)" ]; then
+    if [ "$HOST" = "$HOSTNAME" ]; then
         myPDSH="no_dsh"
+    elif [ -z "$myPDSH" -o "$myPDSH" = "no_dsh" ]; then
+        echo "cannot run remote command on $HOST with $myPDSH"
+        return 128
     fi
     if $VERBOSE; then
         echo "CMD: $HOST $@" >&2
@@ -820,10 +858,11 @@ stopall() {
     if [ $activemds != "mds1" ]; then
         fail mds1
     fi
-    
-    # assume client mount is local 
-    grep " $MOUNT " /proc/mounts && zconf_umount `hostname` $MOUNT $*
-    grep " $MOUNT2 " /proc/mounts && zconf_umount `hostname` $MOUNT2 $*
+
+    # assume client mount is local
+    grep " $MOUNT " /proc/mounts && zconf_umount $HOSTNAME $MOUNT $*
+    grep " $MOUNT2 " /proc/mounts && zconf_umount $HOSTNAME $MOUNT2 $*
+    [ "$CLIENTONLY" ] && return
     for num in `seq $MDSCOUNT`; do
         stop mds$num -f
     done
@@ -836,7 +875,7 @@ stopall() {
 cleanupall() {
     stopall $*
     unload_modules
-    cleanup_krb5_env
+    cleanup_gss
 }
 
 mdsmkfsopts()
@@ -848,6 +887,11 @@ mdsmkfsopts()
 formatall() {
     [ "$FSTYPE" ] && FSTYPE_OPT="--backfstype $FSTYPE"
 
+    if [ ! -z $SEC ]; then
+        MDS_MKFS_OPTS="$MDS_MKFS_OPTS --param srpc.flavor.default=$SEC"
+        OST_MKFS_OPTS="$OST_MKFS_OPTS --param srpc.flavor.default=$SEC"
+    fi
+
     stopall
     # We need ldiskfs here, may as well load them all
     load_modules
@@ -873,12 +917,43 @@ formatall() {
 }
 
 mount_client() {
-    grep " $1 " /proc/mounts || zconf_mount `hostname` $*
+    grep " $1 " /proc/mounts || zconf_mount $HOSTNAME $*
+}
+
+# return value:
+# 0: success, the old identity set already.
+# 1: success, the old identity does not set.
+# 2: fail.
+switch_identity() {
+    local num=$1
+    local switch=$2
+    local j=`expr $num - 1`
+    local MDT="`do_facet mds$num ls -l $LPROC/mdt/ 2>/dev/null | grep MDT | awk '{print $9}' | grep $j$`"
+
+    if [ -z "$MDT" ]; then
+        return 2
+    fi
+
+    local old="`do_facet mds$num cat $LPROC/mdt/$MDT/identity_upcall`"
+
+    if [ $switch ]; then
+        do_facet mds$num "echo \"$L_GETIDENTITY\" > $LPROC/mdt/$MDT/identity_upcall"
+    else
+        do_facet mds$num "echo \"NONE\" > $LPROC/mdt/$MDT/identity_upcall"
+    fi
+
+    do_facet mds$num "echo \"-1\" > $LPROC/mdt/$MDT/identity_flush"
+
+    if [ $old = "NONE" ]; then
+        return 1
+    else
+        return 0
+    fi
 }
 
 setupall() {
     load_modules
-    init_krb5_env
+    init_gss
     if [ -z "$CLIENTONLY" ]; then
         echo "Setup mdts, osts"
         for num in `seq $MDSCOUNT`; do
@@ -886,6 +961,7 @@ setupall() {
             echo $REFORMAT | grep -q "reformat" \
             || do_facet mds$num "$TUNEFS --writeconf $DEVNAME"
             start mds$num $DEVNAME $MDS_MOUNT_OPTS
+            switch_identity $num $IDENTITY_UPCALL
         done
         for num in `seq $OSTCOUNT`; do
             DEVNAME=$(ostdevname $num)
@@ -922,7 +998,7 @@ cleanup_and_setup_lustre() {
     if [ "$ONLY" == "cleanup" -o "`mount | grep $MOUNT`" ]; then
         sysctl -w lnet.debug=0 || true
         cleanupall
-        if [ "$ONLY" == "cleanup" ]; then 
+        if [ "$ONLY" == "cleanup" ]; then
            exit 0
         fi
     fi
@@ -931,8 +1007,7 @@ cleanup_and_setup_lustre() {
 
 check_and_cleanup_lustre() {
     if [ "`mount | grep $MOUNT`" ]; then
-        rm -rf $DIR/[Rdfs][1-9]*
-        rm -f $DIR/${TESTSUITE}/[Rdfs][1-9]*
+        [ -n "$DIR" ] && rm -rf $DIR/[Rdfs][0-9]*
     fi
     if [ "$I_MOUNTED" = "yes" ]; then
         cleanupall -f || error "cleanup failed"
@@ -940,7 +1015,7 @@ check_and_cleanup_lustre() {
     unset I_MOUNTED
 }
 
-####### 
+#######
 # General functions
 
 check_network() {
@@ -1067,6 +1142,35 @@ cancel_lru_locks() {
     $LCTL mark "cancel_lru_locks $1 stop"
 }
 
+default_lru_size()
+{
+        NR_CPU=$(grep -c "processor" /proc/cpuinfo)
+        DEFAULT_LRU_SIZE=$((100 * NR_CPU))
+        echo "$DEFAULT_LRU_SIZE"
+}
+
+lru_resize_enable()
+{
+        NS=$1
+        test "x$NS" = "x" && NS="mdc"
+        for F in $LPROC/ldlm/namespaces/*$NS*/lru_size; do
+                D=$(dirname $F)
+                log "Enable lru resize for $(basename $D)"
+                echo "0" > $F
+        done
+}
+
+lru_resize_disable()
+{
+        NS=$1
+        test "x$NS" = "x" && NS="mdc"
+        for F in $LPROC/ldlm/namespaces/*$NS*/lru_size; do
+                D=$(dirname $F)
+                log "Disable lru resize for $(basename $D)"
+                DEFAULT_LRU_SIZE=$(default_lru_size)
+                echo "$DEFAULT_LRU_SIZE" > $F
+        done
+}
 
 pgcache_empty() {
     for a in /proc/fs/lustre/llite/*/dump_page_cache; do
@@ -1089,7 +1193,7 @@ debugrestore() {
 }
 
 ##################################
-# Test interface 
+# Test interface
 ##################################
 
 error() {
@@ -1131,9 +1235,14 @@ build_test_filter() {
     done
     [ "$EXCEPT$ALWAYS_EXCEPT" ] && \
         log "skipping tests: `echo $EXCEPT $ALWAYS_EXCEPT`"
+    [ "$EXCEPT_SLOW" ] && \
+        log "skipping tests SLOW=no: `echo $EXCEPT_SLOW`"
     for E in $EXCEPT $ALWAYS_EXCEPT; do
         eval EXCEPT_${E}=true
     done
+    for E in $EXCEPT_SLOW; do
+        eval EXCEPT_SLOW_${E}=true
+    done
     for G in $GRANT_CHECK_LIST; do
         eval GCHECK_ONLY_${G}=true
        done
@@ -1173,8 +1282,19 @@ run_test() {
         TESTNAME=test_$1 skip "skipping excluded test $1 (base $base)"
         return 0
     fi
+    testname=EXCEPT_SLOW_$1
+    if [ ${!testname}x != x ]; then
+        TESTNAME=test_$1 skip "skipping SLOW test $1"
+        return 0
+    fi
+    testname=EXCEPT_SLOW_$base
+    if [ ${!testname}x != x ]; then
+        TESTNAME=test_$1 skip "skipping SLOW test $1 (base $base)"
+        return 0
+    fi
+
     run_one $1 "$2"
-    
+
     return $?
 }
 
@@ -1197,6 +1317,9 @@ log() {
     MSG=${MSG//\(/\\\(}
     MSG=${MSG//\)/\\\)}
     MSG=${MSG//\;/\\\;}
+    MSG=${MSG//\|/\\\|}
+    MSG=${MSG//\>/\\\>}
+    MSG=${MSG//\</\\\<}
     local NODES=$(nodes_list)
     for NODE in $NODES; do
         do_node $NODE $LCTL mark "$MSG" 2> /dev/null || true
@@ -1221,11 +1344,20 @@ check_mds() {
     [ $FFREE -ge $FTOTAL ] && error "files free $FFREE > total $FTOTAL" || true
 }
 
+reset_fail_loc () {
+    local myNODES=$(nodes_list)
+    local NODE
+
+    for NODE in $myNODES; do
+        do_node $NODE sysctl -w lustre.fail_loc=0 || true
+    done
+}
+
 run_one() {
     testnum=$1
     message=$2
     tfile=f${testnum}
-    export tdir=d${TESTSUITE}/d${base}
+    export tdir=d0.${TESTSUITE}/d${base}
     local SAVE_UMASK=`umask`
     umask 0022
     mkdir -p $DIR/$tdir
@@ -1236,6 +1368,7 @@ run_one() {
     export TESTNAME=test_$testnum
     test_${testnum} || error "test_$testnum failed with $?"
     #check_mds
+    reset_fail_loc
     check_grant ${testnum} || error "check_grant $testnum failed with $?"
     [ -f $CATASTROPHE ] && [ `cat $CATASTROPHE` -ne 0 ] && \
         error "LBUG/LASSERT detected"
@@ -1253,8 +1386,8 @@ canonical_path() {
 }
 
 sync_clients() {
-    [ -d $DIR1 ] && cd $DIR1 && sync; sleep 1; sync 
-    [ -d $DIR2 ] && cd $DIR2 && sync; sleep 1; sync 
+    [ -d $DIR1 ] && cd $DIR1 && sync; sleep 1; sync
+    [ -d $DIR2 ] && cd $DIR2 && sync; sleep 1; sync
        cd $SAVE_PWD
 }
 
@@ -1270,16 +1403,16 @@ check_grant() {
        # write some data to sync client lost_grant
        rm -f $DIR1/${tfile}_check_grant_* 2>&1
        for i in `seq $OSTCOUNT`; do
-               $LFS setstripe $DIR1/${tfile}_check_grant_$i 0 $(($i -1)) 1
+               $LFS setstripe $DIR1/${tfile}_check_grant_$i -i $(($i -1)) -c 1
                dd if=/dev/zero of=$DIR1/${tfile}_check_grant_$i bs=4k \
-                                             count=1 > /dev/null 2>&1 
+                                             count=1 > /dev/null 2>&1
        done
        # sync all the data and make sure no pending data on server
        sync_clients
        
-       #get client grant and server grant 
+       #get client grant and server grant
        client_grant=0
-    for d in ${LPROC}/osc/*/cur_grant_bytes; do 
+    for d in ${LPROC}/osc/*/cur_grant_bytes; do
                client_grant=$((client_grant + `cat $d`))
        done
        server_grant=0
@@ -1292,7 +1425,7 @@ check_grant() {
                rm $DIR1/${tfile}_check_grant_$i
        done
 
-       #check whether client grant == server grant 
+       #check whether client grant == server grant
        if [ $client_grant != $server_grant ]; then
                echo "failed: client:${client_grant} server: ${server_grant}"
                return 1
@@ -1319,13 +1452,24 @@ remote_mds ()
     [ ! -e /proc/fs/lustre/mdt/*MDT* ]
 }
 
+remote_mds_nodsh()
+{
+    remote_mds && [ "$PDSH" = "no_dsh" -o -z "$PDSH" -o -z "$mds_HOST" ]
+}
+
 remote_ost ()
 {
     [ $(grep -c obdfilter $LPROC/devices) -eq 0 ]
 }
 
+remote_ost_nodsh()
+{
+    remote_ost && [ "$PDSH" = "no_dsh" -o -z "$PDSH" -o -z "$ost_HOST" ]
+}
+
 mdts_nodes () {
     local MDSNODES=$(facet_host $SINGLEMDS)
+    local NODES_sort
 
     # FIXME: Currenly we use only $SINGLEMDS,
     # should be fixed when we will start to test cmd.
@@ -1334,42 +1478,55 @@ mdts_nodes () {
 
     for num in `seq $MDSCOUNT`; do
         local myMDS=$(facet_host mds$num)
-        [[ ! '\ '"$MDSNODES"'\ ' = *'\ '"$myMDS"'\ '* ]] && MDSNODES="$MDSNODES $myMDS"
+        MDSNODES="$MDSNODES $myMDS"
     done
+    NODES_sort=$(for i in $MDSNODES; do echo $i; done | sort -u)
 
-    echo $MDSNODES
+    echo $NODES_sort
 }
 
 osts_nodes () {
     local OSTNODES=$(facet_host ost1)
+    local NODES_sort
 
     for num in `seq $OSTCOUNT`; do
         local myOST=$(facet_host ost$num)
-        [[ ! '\ '"$OSTNODES"'\ ' = *'\ '"$myOST"'\ '* ]] && OSTNODES="$OSTNODES $myOST"
+        OSTNODES="$OSTNODES $myOST"
     done
+    NODES_sort=$(for i in $OSTNODES; do echo $i; done | sort -u)
 
-    echo $OSTNODES
+    echo $NODES_sort
 }
 
 nodes_list () {
     # FIXME. We need a list of clients
-    local myNODES=`hostname`
+    local myNODES=$HOSTNAME
+    local myNODES_sort
 
-    local OSTNODES=$(osts_nodes)
-    local myOSTNODES=`echo ' '"$OSTNODES"' ' | sed -e s/[\ ]$(hostname)[\ ]/\ /`
-    [ -n "$myOSTNODES" ] && myNODES="$myNODES $myOSTNODES"
+    if [ "$PDSH" -a "$PDSH" != "no_dsh" ]; then
+        myNODES="$myNODES $(osts_nodes) $(mdts_nodes)"
+    fi
 
-    local myNODES=${myNODES% } 
-    # Add to list only not listed mds nodes
-    local MDSNODES=$(mdts_nodes)
-    for myMDS in $MDSNODES; do
-        [[ ! "'\ '$myNODES'\ '" = *'\ '"$myMDS"'\ '* ]] && myNODES="$myNODES $myMDS"
-    done
+    myNODES_sort=$(for i in $myNODES; do echo $i; done | sort -u)
 
-    echo $myNODES
+    echo $myNODES_sort
 }
 
 is_patchless ()
 {
     grep -q patchless $LPROC/version
 }
+
+check_runas_id() {
+    local myRUNAS_ID=$1
+    shift
+    local myRUNAS=$@
+    mkdir $DIR/d0_runas_test
+    chmod 0755 $DIR
+    chown $myRUNAS_ID:$myRUNAS_ID $DIR/d0_runas_test
+    $myRUNAS touch $DIR/d0_runas_test/f$$ || \
+        error "unable to write to $DIR/d0_runas_test as UID $myRUNAS_ID.
+        Please set RUNAS_ID to some UID which exists on MDS and client or
+        add user $myRUNAS_ID:$myRUNAS_ID on these nodes."
+    rm -rf $DIR/d0_runas_test
+}