Whamcloud - gitweb
LU-5810 tests: add client hostname to lctl mark
[fs/lustre-release.git] / lustre / tests / test-framework.sh
index 711d394..b323882 100755 (executable)
@@ -59,7 +59,7 @@ sanitize_parameters() {
        do
                local path=${!i}
                if [ -d "$path" ]; then
-                       eval export $i=$(echo $path | sed -E 's/\/+$//g')
+                       eval export $i=$(echo $path | sed -r 's/\/+$//g')
                fi
        done
 }
@@ -333,20 +333,20 @@ init_test_env() {
        export SHUTDOWN_ATTEMPTS=${SHUTDOWN_ATTEMPTS:-3}
        export OSD_TRACK_DECLARES_LBUG=${OSD_TRACK_DECLARES_LBUG:-"yes"}
 
-    # command line
+       # command line
 
-    while getopts "rvwf:" opt $*; do
-        case $opt in
-            f) CONFIG=$OPTARG;;
-            r) REFORMAT=--reformat;;
-            v) VERBOSE=true;;
-            w) WRITECONF=writeconf;;
-            \?) usage;;
-        esac
-    done
+       while getopts "rvwf:" opt $*; do
+               case $opt in
+                       f) CONFIG=$OPTARG;;
+                       r) REFORMAT=yes;;
+                       v) VERBOSE=true;;
+                       w) WRITECONF=writeconf;;
+                       \?) usage;;
+               esac
+       done
 
-    shift $((OPTIND - 1))
-    ONLY=${ONLY:-$*}
+       shift $((OPTIND - 1))
+       ONLY=${ONLY:-$*}
 
        # print the durations of each test if "true"
        DDETAILS=${DDETAILS:-false}
@@ -1276,6 +1276,11 @@ mount_facet() {
                return $RC
        fi
 
+       health=$(do_facet ${facet} "$LCTL get_param -n health_check")
+       if [[ "$health" != "healthy" ]]; then
+               error "$facet is in a unhealthy state"
+       fi
+
        set_default_debug_facet $facet
 
        if [[ $facet == mds* ]]; then
@@ -2542,8 +2547,8 @@ replay_barrier() {
        # inside fail() and fail_abort().
        #
        do_facet $facet $LCTL --device ${!svc} readonly
-       do_facet $facet $LCTL mark "$facet REPLAY BARRIER on ${!svc}"
-       $LCTL mark "local REPLAY BARRIER on ${!svc}"
+       do_facet $facet $LCTL mark "$HOSTNAME: $facet REPLAY BARRIER on ${!svc}"
+       $LCTL mark "$HOSTNAME: local REPLAY BARRIER on ${!svc}"
 }
 
 replay_barrier_nodf() {
@@ -2553,8 +2558,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 "$facet REPLAY BARRIER on ${!svc}"
-       $LCTL mark "local REPLAY BARRIER on ${!svc}"
+       do_facet $facet $LCTL mark "$HOSTNAME: $facet REPLAY BARRIER on ${!svc}"
+       $LCTL mark "$HOSTNAME: local REPLAY BARRIER on ${!svc}"
 }
 
 replay_barrier_nosync() {
@@ -2563,8 +2568,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 "$facet REPLAY BARRIER on ${!svc}"
-       $LCTL mark "local REPLAY BARRIER on ${!svc}"
+       do_facet $facet $LCTL mark "$HOSTNAME: $facet REPLAY BARRIER on ${!svc}"
+       $LCTL mark "$HOSTNAME: local REPLAY BARRIER on ${!svc}"
 }
 
 #
@@ -2879,26 +2884,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 \"$@\"" > /dev/null 2>&1 || :
-    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
 
     if [ "$myPDSH" = "rsh" ]; then
 # we need this because rsh does not return exit code of an executed command
@@ -2994,17 +2999,18 @@ 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 \"$@\"" > /dev/null 2>&1 || :
-    fi
+       export FANOUT=$(get_node_count "${rnodes//,/ }")
+       if $VERBOSE; then
+               echo "CMD: $rnodes $@" >&2
+               $myPDSH $rnodes "$LCTL mark \"$HOSTNAME: $@\"" &>/dev/null || :
+       fi
 
     # do not replace anything from pdsh output if -N is used
     # -N     Disable hostname: prefix on lines of output.
@@ -3995,15 +4001,15 @@ check_and_setup_lustre() {
        local MOUNTED=$(mounted_lustre_filesystems)
 
        local do_check=true
-    # 1.
-    # both MOUNT and MOUNT2 are not mounted
-    if ! is_mounted $MOUNT && ! is_mounted $MOUNT2; then
-        [ "$REFORMAT" ] && formatall
-        # setupall mounts both MOUNT and MOUNT2 (if MOUNT_2 is set)
-        setupall
-        is_mounted $MOUNT || error "NAME=$NAME not mounted"
-        export I_MOUNTED=yes
-        do_check=false
+       # 1.
+       # both MOUNT and MOUNT2 are not mounted
+       if ! is_mounted $MOUNT && ! is_mounted $MOUNT2; then
+               [ "$REFORMAT" = "yes" ] && formatall
+               # setupall mounts both MOUNT and MOUNT2 (if MOUNT_2 is set)
+               setupall
+               is_mounted $MOUNT || error "NAME=$NAME not mounted"
+               export I_MOUNTED=yes
+               do_check=false
     # 2.
     # MOUNT2 is mounted
     elif is_mounted $MOUNT2; then
@@ -4619,10 +4625,10 @@ set_nodes_failloc () {
 }
 
 cancel_lru_locks() {
-       #$LCTL mark "cancel_lru_locks $1 start"
+       #$LCTL mark "$HOSTNAME: 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"
+       #$LCTL mark "$HOSTNAME: cancel_lru_locks $1 stop"
 }
 
 default_lru_size()
@@ -4920,17 +4926,18 @@ log() {
        echo "$*" >&2
        load_module ../libcfs/libcfs/libcfs
 
-    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
+       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
 }
 
 trace() {