Whamcloud - gitweb
LU-8132 tests: do not truncate fsname from paths to ost/mdt
[fs/lustre-release.git] / lustre / tests / test-framework.sh
index 27b0c10..b143748 100755 (executable)
@@ -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
-
-    while getopts "rvwf:" opt $*; do
-        case $opt in
-            f) CONFIG=$OPTARG;;
-            r) REFORMAT=--reformat;;
-            v) VERBOSE=true;;
-            w) WRITECONF=writeconf;;
-            \?) usage;;
-        esac
-    done
+       # command line
 
-    shift $((OPTIND - 1))
-    ONLY=${ONLY:-$*}
+       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:-$*}
 
        # print the durations of each test if "true"
        DDETAILS=${DDETAILS:-false}
@@ -1190,6 +1190,15 @@ set_default_debug_facet () {
     set_default_debug_nodes $node
 }
 
+set_hostid () {
+    local hostid=${1:-$(hostid)}
+
+    if [ ! -s /etc/hostid ]; then
+       printf $(echo -n $hostid |
+           sed 's/\(..\)\(..\)\(..\)\(..\)/\\x\4\\x\3\\x\2\\x\1/') >/etc/hostid
+    fi
+}
+
 # Facet functions
 mount_facets () {
        local facets=${1:-$(get_facets)}
@@ -1276,6 +1285,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 +2556,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 +2567,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 +2577,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 +2893,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 +3008,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.
@@ -3223,7 +3238,7 @@ facet_mntpt () {
     [[ $facet = mgs ]] && combined_mgs_mds && facet="mds1"
 
     local var=${facet}_MOUNT
-    eval mntpt=${!var:-${MOUNT%/*}/$facet}
+    eval mntpt=${!var:-${MOUNT}-$facet}
 
     echo -n $mntpt
 }
@@ -3531,6 +3546,9 @@ format_ost() {
 
 formatall() {
        stopall
+       # Set hostid for ZFS/SPL zpool import protection
+       do_rpc_nodes "$(comma_list $(remote_nodes_list))" set_hostid
+
        # We need ldiskfs here, may as well load them all
        load_modules
        [ "$CLIENTONLY" ] && return
@@ -3995,15 +4013,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 +4637,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 +4938,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() {