Whamcloud - gitweb
LU-819 utils: Fix lfs getstripe -M
[fs/lustre-release.git] / lustre / tests / test-framework.sh
index 0016a50..ad6ad36 100644 (file)
@@ -130,13 +130,6 @@ init_test_env() {
     export LFSCK_ALWAYS=${LFSCK_ALWAYS:-"no"} # check fs after each test suite
     export FSCK_MAX_ERR=4   # File system errors left uncorrected
 
-    # This is used by a small number of tests to share state between the client
-    # running the tests, or in some cases between the servers (e.g. lfsck.sh).
-    # It needs to be a non-lustre filesystem that is available on all the nodes.
-    export SHARED_DIRECTORY=${SHARED_DIRECTORY:-"/tmp"}
-    export MDSDB=${MDSDB:-$SHARED_DIRECTORY/mdsdb}
-    export OSTDB=${OSTDB:-$SHARED_DIRECTORY/ostdb}
-
     #[ -d /r ] && export ROOT=${ROOT:-/r}
     export TMP=${TMP:-$ROOT/tmp}
     export TESTSUITELOG=${TMP}/${TESTSUITE}.log
@@ -376,10 +369,15 @@ load_modules_local() {
     load_module lov/lov
     load_module mgc/mgc
     if ! client_only; then
-        grep -q crc16 /proc/kallsyms || { modprobe crc16 2>/dev/null || true; }
-        grep -q -w jbd /proc/kallsyms || { modprobe jbd 2>/dev/null || true; }
-        grep -q -w jbd2 /proc/kallsyms || { modprobe jbd2 2>/dev/null || true; }
-        [ "$FSTYPE" = "ldiskfs" ] && load_module ../ldiskfs/ldiskfs/ldiskfs
+        SYMLIST=/proc/kallsyms
+        grep -q crc16 $SYMLIST || { modprobe crc16 2>/dev/null || true; }
+        grep -q -w jbd $SYMLIST || { modprobe jbd 2>/dev/null || true; }
+        grep -q -w jbd2 $SYMLIST || { modprobe jbd2 2>/dev/null || true; }
+        if [ "$FSTYPE" = "ldiskfs" ]; then
+            grep -q exportfs_decode_fh $SYMLIST ||
+                { modprobe exportfs 2> /dev/null || true; }
+            load_module ../ldiskfs/ldiskfs/ldiskfs
+        fi
         load_module mgs/mgs
         load_module mds/mds
         load_module mdd/mdd
@@ -1261,7 +1259,8 @@ wait_update () {
         while [ true ]; do
             RESULT=$(do_node $node "$TEST")
             if [ "$RESULT" == "$FINAL" ]; then
-                echo "Updated after $WAIT sec: wanted '$FINAL' got '$RESULT'"
+                [ -z "$RESULT" -o $WAIT -le $sleep ] ||
+                    echo "Updated after ${WAIT}s: wanted '$FINAL' got '$RESULT'"
                 return 0
             fi
             [ $WAIT -ge $MAX ] && break
@@ -1269,7 +1268,7 @@ wait_update () {
             WAIT=$((WAIT + sleep))
             sleep $sleep
         done
-        echo "Update not seen after $MAX sec: wanted '$FINAL' got '$RESULT'"
+        echo "Update not seen after ${MAX}s: wanted '$FINAL' got '$RESULT'"
         return 3
 }
 
@@ -2638,24 +2637,29 @@ run_e2fsck() {
     return 0
 }
 
+# verify a directory is shared among nodes.
+check_shared_dir() {
+    local dir=$1
+
+    [ -z "$dir" ] && return 1
+    do_rpc_nodes $(comma_list $(nodes_list)) check_logdir $dir
+    check_write_access $dir || return 1
+    return 0
+}
+
 # Run e2fsck on MDT and OST(s) to generate databases used for lfsck.
 generate_db() {
     local i
     local ostidx
     local dev
-    local tmp_file
 
-    [ $MDSCOUNT -eq 1 ] || error "CMD is not supported"
-    tmp_file=$(mktemp -p $SHARED_DIRECTORY || 
-        error "fail to create file in $SHARED_DIRECTORY")
+    check_shared_dir $SHARED_DIRECTORY ||
+        error "$SHARED_DIRECTORY isn't a shared directory"
 
-    # make sure everything gets to the backing store
-    local list=$(comma_list $CLIENTS $(facet_host $SINGLEMDS) $(osts_nodes))
-    do_nodes $list "sync; sleep 2; sync"
+    export MDSDB=$SHARED_DIRECTORY/mdsdb
+    export OSTDB=$SHARED_DIRECTORY/ostdb
 
-    do_nodes $list ls $tmp_file || \
-        error "$SHARED_DIRECTORY is not a shared directory"
-    rm $tmp_file
+    [ $MDSCOUNT -eq 1 ] || error "CMD is not supported"
 
     run_e2fsck $(mdts_nodes) $MDTDEV "--mdsdb $MDSDB"
 
@@ -3057,7 +3061,7 @@ error_noexit() {
 
     # We need to dump the logs on all nodes
     if $dump; then
-        gather_logs $(comma_list $(nodes_list))
+        gather_logs $(comma_list $(nodes_list)) 0
     fi
 
     debugrestore
@@ -3336,7 +3340,7 @@ run_one_logged() {
 
     echo
     log_sub_test_begin test_${1}
-    (run_one $1 "$2") 2>&1 | tee $test_log
+    (run_one $1 "$2") 2>&1 | tee -i $test_log
     local RC=${PIPESTATUS[0]}
 
     [ $RC -ne 0 ] && [ ! -f $LOGDIR/err ] && \
@@ -3435,6 +3439,11 @@ index_from_ostuuid()
     $LFS osts $2 | sed -ne "/${1}/s/\(.*\): .* .*$/\1/p"
 }
 
+mdtuuid_from_index()
+{
+    $LFS mdts $2 | awk '/^'$1'/ { print $2 }'
+}
+
 remote_node () {
     local node=$1
     [ "$node" != "$(hostname)" ]
@@ -4231,6 +4240,7 @@ cleanup_pools () {
 
 gather_logs () {
     local list=$1
+    local tar_logs=$2
 
     local ts=$(date +%s)
     local docp=true
@@ -4256,10 +4266,12 @@ gather_logs () {
         do_nodes $list rsync -az "${prefix}.*.${suffix}" $HOSTNAME:$LOGDIR
       fi
 
-    local archive=$LOGDIR/${TESTSUITE}-$ts.tar.bz2
-    tar -jcf $archive $LOGDIR/*$ts* $LOGDIR/*${TESTSUITE}*
+    if [ $tar_logs == 1 ]; then
+        local archive=$LOGDIR/${TESTSUITE}-$ts.tar.bz2
+        tar -jcf $archive $LOGDIR/*$ts* $LOGDIR/*${TESTSUITE}*
 
-    echo $archive
+        echo $archive
+    fi
 }
 
 cleanup_logs () {
@@ -4541,7 +4553,7 @@ wait_flavor()
         echo -n "checking $dir..."
         res=$(do_check_flavor $dir $flavor)
         echo "found $res/$expect $flavor connections"
-        [ $res -eq $expect ] && return 0
+        [ $res -ge $expect ] && return 0
         sleep 4
     done
 
@@ -4623,6 +4635,7 @@ check_write_access() {
             return 1
         fi
     done
+    rm -f $dir/node.*.yml
     return 0
 }
 
@@ -4637,8 +4650,7 @@ init_logging() {
     mkdir -p $LOGDIR
     init_clients_lists
 
-    do_rpc_nodes $(comma_list $(nodes_list)) check_logdir $LOGDIR
-    if check_write_access $LOGDIR; then
+    if check_shared_dir $LOGDIR; then
         touch $LOGDIR/shared
         echo "Logging to shared log directory: $LOGDIR"
     else