Whamcloud - gitweb
b=22225 Pad all test descriptions with "=" characters.
[fs/lustre-release.git] / lustre / tests / test-framework.sh
index 371e5e2..6925483 100644 (file)
@@ -1563,9 +1563,9 @@ do_nodes() {
 
     if single_local_node $rnodes; then
         if $verbose; then
-           do_node --verbose $rnodes $@
+           do_node --verbose $rnodes "$@"
         else
-           do_node $rnodes $@
+           do_node $rnodes "$@"
         fi
         return $?
     fi
@@ -1653,6 +1653,10 @@ stopall() {
         rm -f $TMP/ost${num}active
     done
 
+    if ! combined_mgs_mds ; then
+        stop mgs
+    fi
+
     return 0
 }
 
@@ -1670,6 +1674,10 @@ mdsmkfsopts()
     test $nr = 1 && echo -n $MDS_MKFS_OPTS || echo -n $MDSn_MKFS_OPTS
 }
 
+combined_mgs_mds () {
+    [[ $MDSDEV1 = $MGSDEV ]] && [[ $mds1_HOST = $mgs_HOST ]]
+}
+
 formatall() {
     if [ "$IAMDIR" == "yes" ]; then
         MDS_MKFS_OPTS="$MDS_MKFS_OPTS --iam-dir"
@@ -1683,7 +1691,7 @@ formatall() {
     load_modules
     [ "$CLIENTONLY" ] && return
     echo Formatting mgs, mds, osts
-    if [[ $MDSDEV1 != $MGSDEV ]] || [[ $mds1_HOST != $mgs_HOST ]]; then
+    if ! combined_mgs_mds ; then
         add mgs $mgs_MKFS_OPTS $FSTYPE_OPT --reformat $MGSDEV || exit 10
     fi
 
@@ -1782,7 +1790,7 @@ setupall() {
         echo Setup mgs, mdt, osts
         echo $WRITECONF | grep -q "writeconf" && \
             writeconf_all
-        if [[ $mds1_HOST != $mgs_HOST ]] || [[ $MDSDEV1 != $MGSDEV ]]; then
+        if ! combined_mgs_mds ; then
             start mgs $MGSDEV $mgs_MOUNT_OPTS
         fi
 
@@ -2403,10 +2411,6 @@ pgcache_empty() {
             return 1
         fi
     done
-    if [[ $MDSDEV1 != $MGSDEV ]]; then
-        stop mgs 
-    fi
-
     return 0
 }
 
@@ -2533,6 +2537,14 @@ basetest() {
 
 # print a newline if the last test was skipped
 export LAST_SKIPPED=
+#
+# Main entry into test-framework. This is called with the name and
+# description of a test. The name is used to find the function to run
+# the test using "test_$name".
+#
+# This supports a variety of methods of specifying specific test to
+# run or not run.  These need to be documented...
+#
 run_test() {
     assert_DIR
 
@@ -2641,17 +2653,41 @@ reset_fail_loc () {
     echo done.
 }
 
+
+#
+# Log a message (on all nodes) padded with "=" before and after. 
+# Also appends a timestamp and prepends the testsuite name.
+# 
+banner() {
+    msg="== ${TESTSUITE} $*"
+    # pad the message out to 70 with "="
+    last=${msg: -1:1}
+    [[ $last != "=" && $last != " " ]] && msg+=" "
+    for i in $(seq $((68 - ${#msg})) ); do
+       msg+="="
+    done
+    # always include at least == after the message
+    msg+="=="
+
+    log "$msg $(date +"%H:%M:%S (%s)")"
+}
+
+#
+# Run a single test function and cleanup after it.  
+#
+# This function should be run in a subshell so the test func can
+# exit() without stopping the whole script.
+#
 run_one() {
     local testnum=$1
     local message=$2
-    local start_tm=$3
     tfile=f${testnum}
     export tdir=d0.${TESTSUITE}/d${base}
     export TESTNAME=test_$testnum
     local SAVE_UMASK=`umask`
     umask 0022
 
-    log "== test $testnum: $message == `date +%H:%M:%S` ($start_tm)"
+    banner "test $testnum: $message"
     test_${testnum} || error "test_$testnum failed with $?"
     cd $SAVE_PWD
     reset_fail_loc
@@ -2664,6 +2700,12 @@ run_one() {
     return 0
 }
 
+#
+# Wrapper around run_one to ensure:
+#  - test runs in subshell
+#  - output of test is saved to separate log file for error reporting
+#  - test result is saved to data file
+#
 run_one_logged() {
     local BEFORE=`date +%s`
     local TEST_ERROR
@@ -2672,7 +2714,7 @@ run_one_logged() {
     rm -rf $LOGDIR/err
 
     echo
-    run_one $1 "$2" $BEFORE 2>&1 | tee $test_log
+    run_one $1 "$2" 2>&1 | tee $test_log
     local RC=${PIPESTATUS[0]}
 
     [ $RC -ne 0 ] && [ ! -f $LOGDIR/err ] && \
@@ -2950,6 +2992,17 @@ get_stripe () {
     rm -f $file
 }
 
+setstripe_nfsserver () {
+    local dir=$1
+
+    local nfsserver=$(awk '"'$dir'" ~ $2 && $3 ~ "nfs" && $2 != "/" \
+                { print $1 }' /proc/mounts | cut -f 1 -d : | head -1)
+
+    [ -z $nfsserver ] && echo "$dir is not nfs mounted" && return 1
+
+    do_node --verbose $nfsserver lfs setstripe "$@"
+}
+
 check_runas_id_ret() {
     local myRC=0
     local myRUNAS_UID=$1