Whamcloud - gitweb
LU-8055 ldev: File system label filtering
[fs/lustre-release.git] / lustre / tests / test-framework.sh
index cc573be..7efae3a 100755 (executable)
@@ -142,6 +142,7 @@ init_test_env() {
        export TEST_FAILED=false
        export FAIL_ON_SKIP_ENV=${FAIL_ON_SKIP_ENV:-false}
        export RPC_MODE=${RPC_MODE:-false}
+       export DO_CLEANUP=${DO_CLEANUP:-true}
 
     export MKE2FS=$MKE2FS
     if [ -z "$MKE2FS" ]; then
@@ -293,6 +294,8 @@ init_test_env() {
     export DIR2
     export SAVE_PWD=${SAVE_PWD:-$LUSTRE/tests}
     export AT_MAX_PATH
+    export LDEV=${LDEV:-"$LUSTRE/scripts/ldev"}
+    [ ! -f "$LDEV" ] && export LDEV=$(which ldev 2> /dev/null)
 
     if [ "$ACCEPTOR_PORT" ]; then
         export PORT_OPT="--port $ACCEPTOR_PORT"
@@ -2424,16 +2427,17 @@ client_evicted() {
 }
 
 client_reconnect_try() {
-    uname -n >> $MOUNT/recon
-    if [ -z "$CLIENTS" ]; then
-        df $MOUNT; uname -n >> $MOUNT/recon
-    else
-        do_nodes $CLIENTS "df $MOUNT; uname -n >> $MOUNT/recon" > /dev/null
-    fi
-    echo Connected clients:
-    cat $MOUNT/recon
-    ls -l $MOUNT/recon > /dev/null
-    rm $MOUNT/recon
+       local f=$MOUNT/recon
+
+       uname -n >> $f
+       if [ -z "$CLIENTS" ]; then
+               $LFS df $MOUNT; uname -n >> $f
+       else
+               do_nodes $CLIENTS "$LFS df $MOUNT; uname -n >> $f" > /dev/null
+       fi
+       echo "Connected clients: $(cat $f)"
+       ls -l $f > /dev/null
+       rm $f
 }
 
 client_reconnect() {
@@ -2528,7 +2532,7 @@ obd_name() {
 replay_barrier() {
        local facet=$1
        do_facet $facet "sync; sync; sync"
-       df $MOUNT
+       $LFS df $MOUNT
 
        # make sure there will be no seq change
        local clients=${CLIENTS:-$HOSTNAME}
@@ -2554,8 +2558,8 @@ replay_barrier() {
        # inside fail() and fail_abort().
        #
        do_facet $facet $LCTL --device ${!svc} readonly
-       do_facet $facet $LCTL mark "$HOSTNAME: $facet REPLAY BARRIER on ${!svc}"
-       $LCTL mark "$HOSTNAME: local REPLAY BARRIER on ${!svc}"
+       do_facet $facet $LCTL mark "$facet REPLAY BARRIER on ${!svc}"
+       $LCTL mark "local REPLAY BARRIER on ${!svc}"
 }
 
 replay_barrier_nodf() {
@@ -2565,8 +2569,8 @@ replay_barrier_nodf() {
        echo Replay barrier on ${!svc}
        do_facet $facet $LCTL --device ${!svc} notransno
        do_facet $facet $LCTL --device ${!svc} readonly
-       do_facet $facet $LCTL mark "$HOSTNAME: $facet REPLAY BARRIER on ${!svc}"
-       $LCTL mark "$HOSTNAME: local REPLAY BARRIER on ${!svc}"
+       do_facet $facet $LCTL mark "$facet REPLAY BARRIER on ${!svc}"
+       $LCTL mark "local REPLAY BARRIER on ${!svc}"
 }
 
 replay_barrier_nosync() {
@@ -2575,8 +2579,8 @@ replay_barrier_nosync() {
        echo Replay barrier on ${!svc}
        do_facet $facet $LCTL --device ${!svc} notransno
        do_facet $facet $LCTL --device ${!svc} readonly
-       do_facet $facet $LCTL mark "$HOSTNAME: $facet REPLAY BARRIER on ${!svc}"
-       $LCTL mark "$HOSTNAME: local REPLAY BARRIER on ${!svc}"
+       do_facet $facet $LCTL mark "$facet REPLAY BARRIER on ${!svc}"
+       $LCTL mark "local REPLAY BARRIER on ${!svc}"
 }
 
 #
@@ -2613,7 +2617,7 @@ fail() {
 
        facet_failover $* || error "failover: $?"
        wait_clients_import_state "$clients" "$facets" FULL
-       clients_up || error "post-failover df: $?"
+       clients_up || error "post-failover stat: $?"
 }
 
 fail_nodf() {
@@ -2627,8 +2631,8 @@ fail_abort() {
        change_active $facet
        wait_for_facet $facet
        mount_facet $facet -o abort_recovery
-       clients_up || echo "first df failed: $?"
-       clients_up || error "post-failover df: $?"
+       clients_up || echo "first stat failed: $?"
+       clients_up || error "post-failover stat: $?"
 }
 
 do_lmc() {
@@ -2891,26 +2895,26 @@ change_active() {
 }
 
 do_node() {
-       local verbose=false
-       # do not stripe off hostname if verbose, bug 19215
-       if [ x$1 = x--verbose ]; then
-               shift
-               verbose=true
-       fi
+    local verbose=false
+    # do not stripe off hostname if verbose, bug 19215
+    if [ x$1 = x--verbose ]; then
+        shift
+        verbose=true
+    fi
 
-       local HOST=$1
-       shift
-       local myPDSH=$PDSH
-       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
-               $myPDSH $HOST "$LCTL mark \"$HOSTNAME: $@\"" &>/dev/null || :
-       fi
+    local HOST=$1
+    shift
+    local myPDSH=$PDSH
+    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
+        $myPDSH $HOST "$LCTL mark \"$@\"" > /dev/null 2>&1 || :
+    fi
 
     if [ "$myPDSH" = "rsh" ]; then
 # we need this because rsh does not return exit code of an executed command
@@ -3006,18 +3010,17 @@ do_nodes() {
         return $?
     fi
 
-       # This is part from do_node
-       local myPDSH=$PDSH
+    # This is part from do_node
+    local myPDSH=$PDSH
 
-       [ -z "$myPDSH" -o "$myPDSH" = "no_dsh" -o "$myPDSH" = "rsh" ] &&
-               echo "cannot run remote command on $rnodes with $myPDSH" &&
-               return 128
+    [ -z "$myPDSH" -o "$myPDSH" = "no_dsh" -o "$myPDSH" = "rsh" ] && \
+        echo "cannot run remote command on $rnodes with $myPDSH" && return 128
 
-       export FANOUT=$(get_node_count "${rnodes//,/ }")
-       if $VERBOSE; then
-               echo "CMD: $rnodes $@" >&2
-               $myPDSH $rnodes "$LCTL mark \"$HOSTNAME: $@\"" &>/dev/null || :
-       fi
+    export FANOUT=$(get_node_count "${rnodes//,/ }")
+    if $VERBOSE; then
+        echo "CMD: $rnodes $@" >&2
+        $myPDSH $rnodes "$LCTL mark \"$@\"" > /dev/null 2>&1 || :
+    fi
 
     # do not replace anything from pdsh output if -N is used
     # -N     Disable hostname: prefix on lines of output.
@@ -3847,7 +3850,7 @@ set_conf_param_and_check() {
        do_facet mgs "$LCTL conf_param $PARAM='$FINAL'" ||
                error "conf_param $PARAM failed"
 
-       wait_update $(facet_host $myfacet) "$TEST" "$FINAL" ||
+       wait_update_facet $myfacet "$TEST" "$FINAL" ||
                error "check $PARAM failed!"
 }
 
@@ -4307,8 +4310,12 @@ check_and_cleanup_lustre() {
        fi
 
        if is_mounted $MOUNT; then
-               [ -n "$DIR" ] && rm -rf $DIR/[Rdfs][0-9]* ||
-                       error "remove sub-test dirs failed"
+               if $DO_CLEANUP; then
+                       [ -n "$DIR" ] && rm -rf $DIR/[Rdfs][0-9]* ||
+                               error "remove sub-test dirs failed"
+               else
+                       echo "skip cleanup"
+               fi
                [ "$ENABLE_QUOTA" ] && restore_quota || true
        fi
 
@@ -4631,14 +4638,15 @@ clear_failloc() {
 }
 
 set_nodes_failloc () {
-       do_nodes $(comma_list $1)  lctl set_param fail_val=0 fail_loc=$2
+       local fv=${3:-0}
+       do_nodes $(comma_list $1)  lctl set_param fail_val=$fv fail_loc=$2
 }
 
 cancel_lru_locks() {
-       #$LCTL mark "$HOSTNAME: cancel_lru_locks $1 start"
+       #$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 "$HOSTNAME: cancel_lru_locks $1 stop"
+       #$LCTL mark "cancel_lru_locks $1 stop"
 }
 
 default_lru_size()
@@ -4936,18 +4944,17 @@ log() {
        echo "$*" >&2
        load_module ../libcfs/libcfs/libcfs
 
-       local MSG="$HOSTNAME: $*"
-       # Get rid of '
-       MSG=${MSG//\'/\\\'}
-       MSG=${MSG//\(/\\\(}
-       MSG=${MSG//\)/\\\)}
-       MSG=${MSG//\;/\\\;}
-       MSG=${MSG//\|/\\\|}
-       MSG=${MSG//\>/\\\>}
-       MSG=${MSG//\</\\\<}
-       MSG=${MSG//\//\\\/}
-       do_nodes $(comma_list $(nodes_list)) $LCTL mark "$MSG" 2> /dev/null ||
-               true
+    local MSG="$*"
+    # Get rid of '
+    MSG=${MSG//\'/\\\'}
+    MSG=${MSG//\(/\\\(}
+    MSG=${MSG//\)/\\\)}
+    MSG=${MSG//\;/\\\;}
+    MSG=${MSG//\|/\\\|}
+    MSG=${MSG//\>/\\\>}
+    MSG=${MSG//\</\\\<}
+    MSG=${MSG//\//\\\/}
+    do_nodes $(comma_list $(nodes_list)) $LCTL mark "$MSG" 2> /dev/null || true
 }
 
 trace() {