Whamcloud - gitweb
LU-1458 tests: wait for dbench to start
[fs/lustre-release.git] / lustre / tests / lustre-rsync-test.sh
index 6566850..84050d5 100644 (file)
@@ -1,4 +1,6 @@
 #!/bin/bash
+# -*- mode: Bash; tab-width: 4; indent-tabs-mode: t; -*-
+# vim:shiftwidth=4:softtabstop=4:tabstop=4:
 #
 # Run select tests by setting ONLY, or as arguments to the script.
 # Skip specific tests by setting EXCEPT.
@@ -10,13 +12,14 @@ SRCDIR=`dirname $0`
 export PATH=$PWD/$SRCDIR:$SRCDIR:$PWD/$SRCDIR/../utils:$PATH:/sbin
 
 ONLY=${ONLY:-"$*"}
-[ -n "$ONLY" ] && SLOW=yes
 ALWAYS_EXCEPT="$LRSYNC_EXCEPT"
 # bug number for skipped test:
 # UPDATE THE COMMENT ABOVE WITH BUG NUMBERS WHEN CHANGING ALWAYS_EXCEPT!
 
-[ "$ALWAYS_EXCEPT$EXCEPT" ] && \
-        echo "Skipping tests: `echo $ALWAYS_EXCEPT $EXCEPT`"
+[ "$SLOW" = "no" ] && EXCEPT_SLOW=""
+
+[ "$ALWAYS_EXCEPT$EXCEPT" ] &&
+       echo "Skipping tests: `echo $ALWAYS_EXCEPT $EXCEPT`"
 
 KILL=/bin/kill
 
@@ -30,10 +33,6 @@ init_test_env $@
 . ${CONFIG:=$LUSTRE/tests/cfg/$NAME.sh}
 init_logging
 
-REPLLOG=${TESTSUITELOG:-$TMP/$(basename $0 .sh).log}
-
-[ "$REPLLOG" ] && rm -f $REPLLOG || true
-
 check_and_setup_lustre
 
 DIR=${DIR:-$MOUNT}
@@ -44,7 +43,7 @@ build_test_filter
 
 export LRSYNC=${LRSYNC:-"$LUSTRE/utils/lustre_rsync"}
 [ ! -f "$LRSYNC" ] && export LRSYNC=$(which lustre_rsync)
-export LRSYNC="$LRSYNC -v" # -a
+export LRSYNC="$LRSYNC -v -c no -d 2"
 
 # control the time of tests
 DBENCH_TIME=${DBENCH_TIME:-60}  # No of seconds to run dbench
@@ -86,33 +85,47 @@ fini_changelog() {
     do_facet $SINGLEMDS lctl --device $MDT0 changelog_deregister $CL_USER
 }
 
+# Check whether the filesystem supports xattr or not.
+# Return value:
+# "large" - large xattr is supported
+# "small" - large xattr is unsupported but small xattr is supported
+# "no"    - xattr is unsupported
 check_xattr() {
     local tgt=$1
-    local xattr="yes"
+    local xattr="no"
+
     touch $tgt
-    setfattr -n user.foo -v 'bar' $tgt 2> /dev/null
-    if [ $? -ne 0 ]; then
-       xattr="no"
+
+    local val="$(generate_string $(max_xattr_size))"
+    if large_xattr_enabled &&
+       setfattr -n user.foo -v $val $tgt 2>/dev/null; then
+            xattr="large"
+    else
+        setfattr -n user.foo -v bar $tgt 2>/dev/null && xattr="small"
     fi
+
     rm -f $tgt
     echo $xattr
 }
 
 check_diff() {
-    if [ -e $1 -o -e $2 ]; then 
-        diff -rq -x "dev1" $1 $2
-        local RC=$?
-        if [ $RC -ne 0 ]; then
-            error "Failure in replication; differences found."
-        fi
-    fi
+       local changelog_file=$(generate_logname "changelog")
+
+       if [ -e $1 -o -e $2 ]; then
+               diff -rq -x "dev1" $1 $2
+               local RC=$?
+               if [ $RC -ne 0 ]; then
+                       $LFS changelog $MDT0 > $changelog_file
+                       error "Failure in replication; differences found."
+               fi
+       fi
 }
 
 # Test 1 - test basic operations
 test_1() {
     init_src
     init_changelog
-    local xattr=`check_xattr $TGT/foo`
+    local xattr=$(check_xattr $TGT/foo)
 
     # Directory create
     mkdir $DIR/$tdir/d1
@@ -143,47 +156,50 @@ test_1() {
     # Device files
     #mknod $DIR/$tdir/dev1 b 8 1
 
-    # Replicate
-    echo "Replication #1"
-    $LRSYNC -s $DIR -t $TGT -t $TGT2 -m $MDT0 -u $CL_USER -l $LREPL_LOG
+       # Replicate
+       local LRSYNC_LOG=$(generate_logname "lrsync_log")
+       echo "Replication #1"
+       $LRSYNC -s $DIR -t $TGT -t $TGT2 -m $MDT0 -u $CL_USER -l $LREPL_LOG \
+               -D $LRSYNC_LOG
 
     # Set attributes
     chmod 000 $DIR/$tdir/d2/file3
     chown nobody:nobody $DIR/$tdir/d2/file3
 
     # Set xattrs
-    if [ "$xattr" == "yes" ]; then
-       touch $DIR/$tdir/file5
-       setfattr -n user.foo -v 'bar' $DIR/$tdir/file5
+    if [[ "$xattr" != "no" ]]; then
+        local value
+        touch $DIR/$tdir/file5
+        [[ "$xattr" = "large" ]] &&
+            value="$(generate_string $(max_xattr_size))" || value="bar"
+        setfattr -n user.foo -v $value $DIR/$tdir/file5
     fi
 
-    echo "Replication #2"
-    $LRSYNC -l $LREPL_LOG
+       echo "Replication #2"
+       $LRSYNC -l $LREPL_LOG -D $LRSYNC_LOG
 
-    if [ "$xattr" == "yes" ]; then
-       local xval1=$(getfattr -n user.foo --absolute-names --only-values \
-           $TGT/$tdir/file5)
-       local xval2=$(getfattr -n user.foo --absolute-names --only-values \
-           $TGT2/$tdir/file5)
+    if [[ "$xattr" != "no" ]]; then
+        local xval1=$(get_xattr_value user.foo $TGT/$tdir/file5)
+        local xval2=$(get_xattr_value user.foo $TGT2/$tdir/file5)
     fi
 
     RC=0
 
     # fid2path and path2fid aren't implemented for block devices
     #if [[ ! -b $TGT/$tdir/dev1 ]] || [[ ! -b $TGT2/$tdir/dev1 ]]; then
-    #  ls -l $DIR/$tdir/dev1 $TGT/$tdir/dev1 $TGT2/$tdir/dev1
+    #   ls -l $DIR/$tdir/dev1 $TGT/$tdir/dev1 $TGT2/$tdir/dev1
     #   error "Error replicating block devices"
     #   RC=1
 
-    if [[ "$xattr" == "yes" ]] &&
-       [[ "$xval1" != "bar" || "$xval2" != "bar" ]]; then
-        error "Error in replicating xattrs. $xval1, $xval2"
+    if [[ "$xattr" != "no" ]] &&
+       [[ "$xval1" != "$value" || "$xval2" != "$value" ]]; then
+        error "Error in replicating xattrs."
         RC=1
     fi
 
-    # Use diff to compare the source and the destination
-    check_diff $DIR/$tdir $TGT/$tdir
-    check_diff $DIR/$tdir $TGT2/$tdir
+       # Use diff to compare the source and the destination
+       check_diff $DIR/$tdir $TGT/$tdir
+       check_diff $DIR/$tdir $TGT2/$tdir
 
     fini_changelog
     cleanup_src_tgt
@@ -191,48 +207,52 @@ test_1() {
 }
 run_test 1 "Simple Replication"
 
-# Test 2a - Replicate files created by dbench 
+# Test 2a - Replicate files created by dbench
 test_2a() {
-    [ "$SLOW" = "no" ] && skip "Skipping slow test" && return
-    init_src
-    init_changelog
+       init_src
+       init_changelog
 
-    # Run dbench
-    sh rundbench -C -D $DIR/$tdir 2 -t $DBENCH_TIME || error "dbench failed!"
+       # Run dbench
+       sh rundbench -C -D $DIR/$tdir 2 -t $DBENCH_TIME || error "dbench failed"
 
-    # Replicate the changes to $TGT
-    $LRSYNC -s $DIR -t $TGT -t $TGT2 -m $MDT0 -u $CL_USER -l $LREPL_LOG
+       local LRSYNC_LOG=$(generate_logname "lrsync_log")
+       # Replicate the changes to $TGT
+       $LRSYNC -s $DIR -t $TGT -t $TGT2 -m $MDT0 -u $CL_USER -l $LREPL_LOG \
+               -D $LRSYNC_LOG
 
-    # Use diff to compare the source and the destination
-    check_diff $DIR/$tdir $TGT/$tdir
-    check_diff $DIR/$tdir $TGT2/$tdir
+       # Use diff to compare the source and the destination
+       check_diff $DIR/$tdir $TGT/$tdir
+       check_diff $DIR/$tdir $TGT2/$tdir
 
-    fini_changelog
-    cleanup_src_tgt
-    return 0
+       fini_changelog
+       cleanup_src_tgt
+       return 0
 }
 run_test 2a "Replicate files created by dbench."
 
 
 # Test 2b - Replicate files changed by dbench.
 test_2b() {
-    [ "$SLOW" = "no" ] && skip "Skipping slow test" && return
-
-    init_src
-    init_changelog
-
-    # Run dbench
-    sh rundbench -C -D $DIR/$tdir 2 -t $DBENCH_TIME &
-    sleep 20
-
-    local child_pid=$(pgrep dbench)
-    echo PIDs: $child_pid
-    echo Stopping dbench
-    $KILL -SIGSTOP $child_pid
-
-    echo Starting replication
-    $LRSYNC -s $DIR -t $TGT -t $TGT2 -m $MDT0 -u $CL_USER -l $LREPL_LOG
-    check_diff $DIR/$tdir $TGT/$tdir
+       local child_pid
+       init_src
+       init_changelog
+
+       # Run dbench
+       sh rundbench -C -D $DIR/$tdir 2 -t $DBENCH_TIME &
+       # wait for dbench to start
+       wait_for_function 'child_pid=$(pgrep dbench)' 360
+       # let dbench run for a bit
+       sleep 10
+
+       echo PIDs: $child_pid
+       echo Stopping dbench
+       $KILL -SIGSTOP $child_pid
+
+       local LRSYNC_LOG=$(generate_logname "lrsync_log")
+       echo Starting replication
+       $LRSYNC -s $DIR -t $TGT -t $TGT2 -m $MDT0 -u $CL_USER -l $LREPL_LOG \
+               -D $LRSYNC_LOG
+       check_diff $DIR/$tdir $TGT/$tdir
 
     echo Resuming dbench
     $KILL -SIGCONT $child_pid
@@ -241,20 +261,20 @@ test_2b() {
     echo Stopping dbench
     $KILL -SIGSTOP $child_pid
 
-    echo Starting replication
-    $LRSYNC -l $LREPL_LOG
-    check_diff $DIR/$tdir $TGT/$tdir
+       echo Starting replication
+       $LRSYNC -l $LREPL_LOG -D $LRSYNC_LOG
+       check_diff $DIR/$tdir $TGT/$tdir
 
     echo "Wait for dbench to finish"
     $KILL -SIGCONT $child_pid
     wait
 
-    # Replicate the changes to $TGT
-    echo Starting replication
-    $LRSYNC -l $LREPL_LOG
+       # Replicate the changes to $TGT
+       echo Starting replication
+       $LRSYNC -l $LREPL_LOG -D $LRSYNC_LOG
 
-    check_diff $DIR/$tdir $TGT/$tdir
-    check_diff $DIR/$tdir $TGT2/$tdir
+       check_diff $DIR/$tdir $TGT/$tdir
+       check_diff $DIR/$tdir $TGT2/$tdir
 
     fini_changelog
     cleanup_src_tgt
@@ -262,110 +282,110 @@ test_2b() {
 }
 run_test 2b "Replicate files changed by dbench."
 
-# Test 2c - Replicate files while dbench is running 
+# Test 2c - Replicate files while dbench is running
 test_2c() {
-    [ "$SLOW" = "no" ] && skip "Skipping slow test" && return
-    init_src
-    init_changelog
-
-    # Run dbench
-    sh rundbench -C -D $DIR/$tdir 2 -t $DBENCH_TIME &
-
-    # Replicate the changes to $TGT
-    sleep 10 # give dbench a headstart
-    local quit=0
-    while [ $quit -le 1 ];
-    do
-        echo "Running lustre_rsync"
-        $LRSYNC -s $DIR -t $TGT -t $TGT2 -m ${mds1_svc} -u $CL_USER -l $LREPL_LOG
-        sleep 5
-        pgrep dbench
-        if [ $? -ne 0 ]; then
-            quit=$(expr $quit + 1)
-        fi
-    done
-
-    # Use diff to compare the source and the destination
-    check_diff $DIR/$tdir $TGT/$tdir
-    check_diff $DIR/$tdir $TGT2/$tdir
-
-    fini_changelog
-    cleanup_src_tgt
-    return 0
+       init_src
+       init_changelog
+
+       # Run dbench
+       sh rundbench -C -D $DIR/$tdir 2 -t $DBENCH_TIME &
+
+       local LRSYNC_LOG=$(generate_logname "lrsync_log")
+       # Replicate the changes to $TGT
+       sleep 10 # give dbench a headstart
+       local quit=0
+       while [ $quit -le 1 ];
+       do
+               echo "Running lustre_rsync"
+               $LRSYNC -s $DIR -t $TGT -t $TGT2 -m ${mds1_svc} -u $CL_USER \
+                       -l $LREPL_LOG -D $LRSYNC_LOG
+               sleep 5
+               pgrep dbench
+               if [ $? -ne 0 ]; then
+                       quit=$(expr $quit + 1)
+               fi
+       done
+
+       # Use diff to compare the source and the destination
+       check_diff $DIR/$tdir $TGT/$tdir
+       check_diff $DIR/$tdir $TGT2/$tdir
+
+       fini_changelog
+       cleanup_src_tgt
+       return 0
 }
 run_test 2c "Replicate files while dbench is running."
 
 # Test 3a - Replicate files created by createmany
 test_3a() {
-    [ "$SLOW" = "no" ] && skip "Skipping slow test" && return
-
-    init_src
-    init_changelog
-
-    local numfiles=1000
-    createmany -o $DIR/$tdir/$tfile $numfiles || error "createmany failed!"
-
-    # Replicate the changes to $TGT
-    $LRSYNC -s $DIR -t $TGT -t $TGT2 -m $MDT0 -u $CL_USER -l $LREPL_LOG
-    check_diff $DIR/$tdir $TGT/$tdir   
-    check_diff $DIR/$tdir $TGT2/$tdir
-
-    fini_changelog
-    cleanup_src_tgt
-    return 0
+       init_src
+       init_changelog
+
+       local numfiles=1000
+       createmany -o $DIR/$tdir/$tfile $numfiles || error "createmany failed"
+
+       local LRSYNC_LOG=$(generate_logname "lrsync_log")
+       # Replicate the changes to $TGT
+       $LRSYNC -s $DIR -t $TGT -t $TGT2 -m $MDT0 -u $CL_USER -l $LREPL_LOG \
+               -D $LRSYNC_LOG
+       check_diff $DIR/$tdir $TGT/$tdir
+       check_diff $DIR/$tdir $TGT2/$tdir
+
+       fini_changelog
+       cleanup_src_tgt
+       return 0
 }
 run_test 3a "Replicate files created by createmany"
 
 
 # Test 3b - Replicate files created by writemany
 test_3b() {
-    [ "$SLOW" = "no" ] && skip "Skipping slow test" && return
+       init_src
+       init_changelog
 
-    init_src
-    init_changelog
+       local time=60
+       local threads=5
+       writemany -q -a $DIR/$tdir/$tfile $time $threads ||
+               error "writemany failed"
 
-    local time=60
-    local threads=5
-    writemany -q -a $DIR/$tdir/$tfile $time $threads || error "writemany failed!"
+       local LRSYNC_LOG=$(generate_logname "lrsync_log")
+       # Replicate the changes to $TGT
+       $LRSYNC -s $DIR -t $TGT -t $TGT2 -m $MDT0 -u $CL_USER -l $LREPL_LOG \
+               -D $LRSYNC_LOG
 
-    # Replicate the changes to $TGT
-    $LRSYNC -s $DIR -t $TGT -t $TGT2 -m $MDT0 -u $CL_USER -l $LREPL_LOG
+       check_diff $DIR/$tdir $TGT/$tdir
+       check_diff $DIR/$tdir $TGT2/$tdir
 
-    check_diff $DIR/$tdir $TGT/$tdir   
-    check_diff $DIR/$tdir $TGT2/$tdir
-
-    fini_changelog
-    cleanup_src_tgt
-    return 0
+       fini_changelog
+       cleanup_src_tgt
+       return 0
 }
 run_test 3b "Replicate files created by writemany"
 
 # Test 3c - Replicate files created by createmany/unlinkmany
 test_3c() {
-    [ "$SLOW" = "no" ] && skip "Skipping slow test" && return
-
-    init_src
-    init_changelog
-
-    local numfiles=1000
-    createmany -o $DIR/$tdir/$tfile $numfiles || error "createmany failed!"
-    unlinkmany $DIR/$tdir/$tfile $numfiles || error "unlinkmany failed!"
-
-    # Replicate the changes to $TGT
-    $LRSYNC -s $DIR -t $TGT -t $TGT2 -m $MDT0  -u $CL_USER -l $LREPL_LOG
-    check_diff $DIR/$tdir $TGT/$tdir   
-    check_diff $DIR/$tdir $TGT2/$tdir
-
-    fini_changelog
-    cleanup_src_tgt
-    return 0
+       init_src
+       init_changelog
+
+       local numfiles=1000
+       createmany -o $DIR/$tdir/$tfile $numfiles || error "createmany failed"
+       unlinkmany $DIR/$tdir/$tfile $numfiles || error "unlinkmany failed"
+
+       local LRSYNC_LOG=$(generate_logname "lrsync_log")
+       # Replicate the changes to $TGT
+       $LRSYNC -s $DIR -t $TGT -t $TGT2 -m $MDT0  -u $CL_USER -l $LREPL_LOG \
+               -D $LRSYNC_LOG
+       check_diff $DIR/$tdir $TGT/$tdir
+       check_diff $DIR/$tdir $TGT2/$tdir
+
+       fini_changelog
+       cleanup_src_tgt
+       return 0
 }
 run_test 3c "Replicate files created by createmany/unlinkmany"
 
 # Test 4 - Replicate files created by iozone
 test_4() {
-    [ "$SLOW" = "no" ] && skip "Skipping slow test" && return
-
     which iozone > /dev/null 2>&1
     if [ $? -ne 0 ]; then
        skip "iozone not found. Skipping test"
@@ -381,10 +401,12 @@ test_4() {
     child_pid=$(pgrep iozone)
     $KILL -SIGSTOP $child_pid
 
-    # Replicate the changes to $TGT
-    $LRSYNC -s $DIR -t $TGT -t $TGT2 -m $MDT0  -u $CL_USER -l $LREPL_LOG
-    check_diff $DIR/$tdir $TGT/$tdir
-    check_diff $DIR/$tdir $TGT2/$tdir
+       local LRSYNC_LOG=$(generate_logname "lrsync_log")
+       # Replicate the changes to $TGT
+       $LRSYNC -s $DIR -t $TGT -t $TGT2 -m $MDT0  -u $CL_USER -l $LREPL_LOG \
+               -D $LRSYNC_LOG
+       check_diff $DIR/$tdir $TGT/$tdir
+       check_diff $DIR/$tdir $TGT2/$tdir
 
     $KILL -SIGCONT $child_pid
     sleep 60
@@ -403,9 +425,9 @@ test_4() {
       sleep 1;
     done
 
-    $LRSYNC -l $LREPL_LOG
-    check_diff $DIR/$tdir $TGT/$tdir
-    check_diff $DIR/$tdir $TGT2/$tdir
+       $LRSYNC -l $LREPL_LOG -D $LRSYNC_LOG
+       check_diff $DIR/$tdir $TGT/$tdir
+       check_diff $DIR/$tdir $TGT2/$tdir
 
     fini_changelog
     cleanup_src_tgt
@@ -415,57 +437,55 @@ run_test 4 "Replicate files created by iozone"
 
 # Test 5a - Stop / start lustre_rsync
 test_5a() {
-    [ "$SLOW" = "no" ] && skip "Skipping slow test" && return
-
-    init_src
-    init_changelog
-
-    NUMTEST=2000
-    createmany -o $DIR/$tdir/$tfile $NUMTEST
-
-    # Replicate the changes to $TGT
-    
-    $LRSYNC -s $DIR -t $TGT -t $TGT2 -m $MDT0 -u $CL_USER -l $LREPL_LOG &
-    local child_pid=$!
-    sleep 30
-    $KILL -SIGHUP $child_pid
-    wait
-    $LRSYNC -l $LREPL_LOG
-
-    check_diff $DIR/$tdir $TGT/$tdir   
-    check_diff $DIR/$tdir $TGT2/$tdir
-
-    fini_changelog
-    cleanup_src_tgt
-    return 0
+       init_src
+       init_changelog
+
+       NUMTEST=2000
+       createmany -o $DIR/$tdir/$tfile $NUMTEST
+
+       # Replicate the changes to $TGT
+       local LRSYNC_LOG=$(generate_logname "lrsync_log")
+       $LRSYNC -s $DIR -t $TGT -t $TGT2 -m $MDT0 -u $CL_USER -l $LREPL_LOG \
+               -D $LRSYNC_LOG &
+       local child_pid=$!
+       sleep 30
+       $KILL -SIGHUP $child_pid
+       wait
+       $LRSYNC -l $LREPL_LOG -D $LRSYNC_LOG
+
+       check_diff $DIR/$tdir $TGT/$tdir
+       check_diff $DIR/$tdir $TGT2/$tdir
+
+       fini_changelog
+       cleanup_src_tgt
+       return 0
 }
 run_test 5a "Stop / start lustre_rsync"
 
 # Test 5b - Kill / restart lustre_rsync
 test_5b() {
-    [ "$SLOW" = "no" ] && skip "Skipping slow test" && return
-
-    init_src
-    init_changelog
-
-    NUMTEST=2000
-    createmany -o $DIR/$tdir/$tfile $NUMTEST
-
-    # Replicate the changes to $TGT
-    
-    $LRSYNC -s $DIR -t $TGT -t $TGT2 -m $MDT0 -u $CL_USER -l $LREPL_LOG &
-    local child_pid=$!
-    sleep 30
-    $KILL -SIGKILL $child_pid
-    wait
-    $LRSYNC -l $LREPL_LOG
-
-    check_diff $DIR/$tdir $TGT/$tdir   
-    check_diff $DIR/$tdir $TGT2/$tdir
-
-    fini_changelog
-    cleanup_src_tgt
-    return 0
+       init_src
+       init_changelog
+
+       NUMTEST=2000
+       createmany -o $DIR/$tdir/$tfile $NUMTEST
+
+       # Replicate the changes to $TGT
+       local LRSYNC_LOG=$(generate_logname "lrsync_log")
+       $LRSYNC -s $DIR -t $TGT -t $TGT2 -m $MDT0 -u $CL_USER -l $LREPL_LOG \
+               -D $LRSYNC_LOG &
+       local child_pid=$!
+       sleep 30
+       $KILL -SIGKILL $child_pid
+       wait
+       $LRSYNC -l $LREPL_LOG -D $LRSYNC_LOG
+
+       check_diff $DIR/$tdir $TGT/$tdir
+       check_diff $DIR/$tdir $TGT2/$tdir
+
+       fini_changelog
+       cleanup_src_tgt
+       return 0
 }
 run_test 5b "Kill / restart lustre_rsync"
 
@@ -483,10 +503,12 @@ test_6() {
       i=$(expr $i + 1)
     done
 
-    # Replicate the changes to $TGT
-    $LRSYNC -s $DIR -t $TGT -t $TGT2 -m $MDT0 -u $CL_USER -l $LREPL_LOG
-    check_diff $DIR/$tdir $TGT/$tdir
-    check_diff $DIR/$tdir $TGT2/$tdir
+       local LRSYNC_LOG=$(generate_logname "lrsync_log")
+       # Replicate the changes to $TGT
+       $LRSYNC -s $DIR -t $TGT -t $TGT2 -m $MDT0 -u $CL_USER -l $LREPL_LOG \
+               -D $LRSYNC_LOG
+       check_diff $DIR/$tdir $TGT/$tdir
+       check_diff $DIR/$tdir $TGT2/$tdir
 
     local count1=$(ls -l $TGT/$tdir/link0 | sed -r 's/ +/ /g' | cut -f 2 -d ' ')
     local count2=$(ls -l $TGT/$tdir/link0 | sed -r 's/ +/ /g' | cut -f 2 -d ' ')
@@ -507,29 +529,32 @@ test_7() {
     init_changelog
 
     local NUMFILES=100
-    lfs setstripe -c 2 ${DIR}/$tdir
+    lfs setstripe -c $OSTCOUNT $DIR/$tdir
     createmany -o $DIR/$tdir/$tfile $NUMFILES
 
-    # To simulate replication to another lustre filesystem, replicate
-    # the changes to $DIR/tgt. We can't turn off the changelogs
-    # while we are registered, so lustre_rsync better not try to 
-    # replicate the replication steps.  It seems ok :)
-
-    $LRSYNC -s $DIR -t $DIR/tgt -m $MDT0 -u $CL_USER -l $LREPL_LOG
-    check_diff ${DIR}/$tdir $DIR/tgt/$tdir
-
-    local i=0
-    while [ $i -lt $NUMFILES ];
-    do
-      local count=$(lfs getstripe $DIR/tgt/$tdir/${tfile}$i | awk '/stripe_count/ {print $2}')
-      if [ $count -ne 2 ]; then
-         error "Stripe size not replicated" 
-      fi
-      i=$(expr $i + 1)
-    done
-    fini_changelog
-    cleanup_src_tgt
-    return 0
+       # To simulate replication to another lustre filesystem, replicate
+       # the changes to $DIR/tgt. We can't turn off the changelogs
+       # while we are registered, so lustre_rsync better not try to
+       # replicate the replication steps.  It seems ok :)
+
+       local LRSYNC_LOG=$(generate_logname "lrsync_log")
+       $LRSYNC -s $DIR -t $DIR/tgt -m $MDT0 -u $CL_USER -l $LREPL_LOG \
+               -D $LRSYNC_LOG
+       check_diff ${DIR}/$tdir $DIR/tgt/$tdir
+
+       local i=0
+       while [ $i -lt $NUMFILES ];
+       do
+               local count=$(lfs getstripe $DIR/tgt/$tdir/${tfile}$i | \
+                             awk '/stripe_count/ {print $2}')
+               if [ $count -ne $OSTCOUNT ]; then
+                       error "Stripe size not replicated"
+               fi
+               i=$(expr $i + 1)
+       done
+       fini_changelog
+       cleanup_src_tgt
+       return 0
 }
 run_test 7 "lustre_rsync stripesize"
 
@@ -552,9 +577,11 @@ test_8() {
            mv $DIR/$tdir/d$i $DIR/$tdir/d0$i
     done
 
-    $LRSYNC -s $DIR -t $TGT -m $MDT0 -u $CL_USER -l $LREPL_LOG
+       local LRSYNC_LOG=$(generate_logname "lrsync_log")
+       $LRSYNC -s $DIR -t $TGT -m $MDT0 -u $CL_USER -l $LREPL_LOG \
+               -D $LRSYNC_LOG
 
-    check_diff ${DIR}/$tdir $TGT/$tdir
+       check_diff ${DIR}/$tdir $TGT/$tdir
 
     fini_changelog
     cleanup_src_tgt
@@ -569,15 +596,18 @@ test_9() {
     mkdir $DIR/$tdir/foo
     touch $DIR/$tdir/foo/a1
 
-    $LRSYNC -s $DIR -t $TGT -m $MDT0 -u $CL_USER -l $LREPL_LOG
+       local LRSYNC_LOG=$(generate_logname "lrsync_log")
+       $LRSYNC -s $DIR -t $TGT -m $MDT0 -u $CL_USER -l $LREPL_LOG \
+               -D $LRSYNC_LOG
 
-    check_diff ${DIR}/$tdir $TGT/$tdir
+       check_diff ${DIR}/$tdir $TGT/$tdir
 
-    rm -rf $DIR/$tdir/foo
+       rm -rf $DIR/$tdir/foo
 
-    $LRSYNC -s $DIR -t $TGT -m $MDT0 -u $CL_USER -l $LREPL_LOG
+       $LRSYNC -s $DIR -t $TGT -m $MDT0 -u $CL_USER -l $LREPL_LOG \
+               -D $LRSYNC_LOG
 
-    check_diff ${DIR}/$tdir $TGT/$tdir
+       check_diff ${DIR}/$tdir $TGT/$tdir
 
     fini_changelog
     cleanup_src_tgt
@@ -585,9 +615,7 @@ test_9() {
 }
 run_test 9 "Replicate recursive directory removal"
 
-log "cleanup: ======================================================"
 cd $ORIG_PWD
+complete $SECONDS
 check_and_cleanup_lustre
-echo '=========================== finished ==============================='
-[ -f "$REPLLOG" ] && cat $REPLLOG && grep -q FAIL $REPLLOG && exit 1 || true
-echo "$0: completed"
+exit_status